Browse Source

mouse agent and sub hash

release/v0.1
jl777 9 years ago
parent
commit
62b053a7fc
  1. 131
      iguana/SuperNET.c
  2. 10
      iguana/SuperNET.h
  3. 20
      iguana/SuperNET_category.c
  4. 27
      iguana/SuperNET_hexmsg.c
  5. 2
      iguana/iguana777.h
  6. 34
      iguana/iguana_bitmap.c
  7. 4
      iguana/iguana_json.c
  8. 2
      iguana/iguana_rpc.c
  9. 2
      includes/iguana_api.h
  10. 9
      includes/iguana_apideclares.h
  11. 2
      includes/iguana_apidefs.h
  12. 2
      includes/iguana_apiundefs.h

131
iguana/SuperNET.c

@ -227,7 +227,8 @@ uint16_t SuperNET_checkc(bits256 privkey,bits256 otherpub,uint32_t x)
int32_t SuperNET_json2bits(char *myipaddr,bits256 privkey,bits256 mypubkey,uint8_t *serialized,int32_t maxsize,char *destip,cJSON *json,bits256 destpub,int16_t _othervalid) int32_t SuperNET_json2bits(char *myipaddr,bits256 privkey,bits256 mypubkey,uint8_t *serialized,int32_t maxsize,char *destip,cJSON *json,bits256 destpub,int16_t _othervalid)
{ {
uint16_t apinum,checkc; uint32_t tmp,ipbits,crc; char *agent,*method; //uint64_t tag; uint16_t apinum,checkc; bits256 categoryhash,subhash; uint32_t tmp,ipbits,crc;
char *agent,*method; //uint64_t tag;
char *hexmsg; uint8_t broadcastflag; int8_t othervalid; int32_t n,len = sizeof(uint32_t); char *hexmsg; uint8_t broadcastflag; int8_t othervalid; int32_t n,len = sizeof(uint32_t);
if ( _othervalid > 100 ) if ( _othervalid > 100 )
othervalid = 100; othervalid = 100;
@ -238,8 +239,14 @@ int32_t SuperNET_json2bits(char *myipaddr,bits256 privkey,bits256 mypubkey,uint8
if ( tmp > SUPERNET_MAXHOPS ) if ( tmp > SUPERNET_MAXHOPS )
broadcastflag = SUPERNET_MAXHOPS; broadcastflag = SUPERNET_MAXHOPS;
else broadcastflag = tmp; else broadcastflag = tmp;
if ( bits256_nonz(destpub) > 0 && memcmp(destpub.bytes,GENESIS_PUBKEY.bytes,sizeof(destpub)) != 0 ) categoryhash = jbits256(json,"categoryhash");
subhash = jbits256(json,"subhash");
if ( memcmp(categoryhash.bytes,GENESIS_PUBKEY.bytes,sizeof(categoryhash)) != 0 )
{
broadcastflag |= 0x40; broadcastflag |= 0x40;
if ( memcmp(subhash.bytes,GENESIS_PUBKEY.bytes,sizeof(subhash)) != 0 )
broadcastflag |= 0x20;
}
if ( juint(json,"plaintext") != 0 ) if ( juint(json,"plaintext") != 0 )
broadcastflag |= 0x80; broadcastflag |= 0x80;
//if ( (tag= j64bits(json,"tag")) == 0 ) //if ( (tag= j64bits(json,"tag")) == 0 )
@ -267,7 +274,11 @@ int32_t SuperNET_json2bits(char *myipaddr,bits256 privkey,bits256 mypubkey,uint8
len += iguana_rwnum(1,&serialized[len],sizeof(othervalid),&othervalid); len += iguana_rwnum(1,&serialized[len],sizeof(othervalid),&othervalid);
len += iguana_rwnum(1,&serialized[len],sizeof(broadcastflag),&broadcastflag); len += iguana_rwnum(1,&serialized[len],sizeof(broadcastflag),&broadcastflag);
if ( (broadcastflag & 0x40) != 0 ) if ( (broadcastflag & 0x40) != 0 )
len += iguana_rwbignum(1,&serialized[len],sizeof(bits256),destpub.bytes); {
len += iguana_rwbignum(1,&serialized[len],sizeof(bits256),categoryhash.bytes);
if ( (broadcastflag & 0x20) != 0 )
len += iguana_rwbignum(1,&serialized[len],sizeof(bits256),subhash.bytes);
}
if ( (hexmsg= jstr(json,"hexmsg")) != 0 ) if ( (hexmsg= jstr(json,"hexmsg")) != 0 )
{ {
n = (int32_t)strlen(hexmsg); n = (int32_t)strlen(hexmsg);
@ -291,7 +302,7 @@ cJSON *SuperNET_bits2json(struct iguana_peer *addr,uint8_t *serialized,int32_t d
{ {
char destip[64],method[64],checkstr[5],agent[64],myipaddr[64],str[65],*hexmsg; //uint64_t tag; char destip[64],method[64],checkstr[5],agent[64],myipaddr[64],str[65],*hexmsg; //uint64_t tag;
uint16_t apinum,checkc; int8_t othervalid; uint32_t destipbits,myipbits; uint16_t apinum,checkc; int8_t othervalid; uint32_t destipbits,myipbits;
bits256 destpub,senderpub; cJSON *json = cJSON_CreateObject(); bits256 categoryhash,subhash,senderpub; cJSON *json = cJSON_CreateObject();
int32_t len = 0; uint32_t crc; uint8_t broadcastflag,plaintext; int32_t len = 0; uint32_t crc; uint8_t broadcastflag,plaintext;
len += iguana_rwnum(0,&serialized[len],sizeof(uint32_t),&crc); len += iguana_rwnum(0,&serialized[len],sizeof(uint32_t),&crc);
len += iguana_rwnum(0,&serialized[len],sizeof(uint32_t),&destipbits); len += iguana_rwnum(0,&serialized[len],sizeof(uint32_t),&destipbits);
@ -303,7 +314,11 @@ cJSON *SuperNET_bits2json(struct iguana_peer *addr,uint8_t *serialized,int32_t d
len += iguana_rwnum(0,&serialized[len],sizeof(othervalid),&othervalid); len += iguana_rwnum(0,&serialized[len],sizeof(othervalid),&othervalid);
len += iguana_rwnum(0,&serialized[len],sizeof(broadcastflag),&broadcastflag); len += iguana_rwnum(0,&serialized[len],sizeof(broadcastflag),&broadcastflag);
if ( (broadcastflag & 0x40) != 0 ) if ( (broadcastflag & 0x40) != 0 )
len += iguana_rwbignum(0,&serialized[len],sizeof(bits256),destpub.bytes); {
len += iguana_rwbignum(0,&serialized[len],sizeof(bits256),categoryhash.bytes);
if ( (broadcastflag & 0x20) != 0 )
len += iguana_rwbignum(0,&serialized[len],sizeof(bits256),subhash.bytes);
}
plaintext = (broadcastflag & 0x80) != 0; plaintext = (broadcastflag & 0x80) != 0;
broadcastflag &= 0x3f; broadcastflag &= 0x3f;
if ( broadcastflag > SUPERNET_MAXHOPS ) if ( broadcastflag > SUPERNET_MAXHOPS )
@ -313,13 +328,18 @@ cJSON *SuperNET_bits2json(struct iguana_peer *addr,uint8_t *serialized,int32_t d
{ {
jaddstr(json,"agent",agent); jaddstr(json,"agent",agent);
jaddstr(json,"method",method); jaddstr(json,"method",method);
jaddbits256(json,"categoryhash",categoryhash);
jaddbits256(json,"subhash",subhash);
expand_ipbits(destip,destipbits), jaddstr(json,"yourip",destip); expand_ipbits(destip,destipbits), jaddstr(json,"yourip",destip);
expand_ipbits(myipaddr,myipbits), jaddstr(json,"myip",myipaddr); expand_ipbits(myipaddr,myipbits), jaddstr(json,"myip",myipaddr);
jaddstr(json,"mypub",bits256_str(str,senderpub)); jaddstr(json,"mypub",bits256_str(str,senderpub));
if ( broadcastflag != 0 ) categoryhash = subhash = GENESIS_PUBKEY;
jaddbits256(json,"destpub",GENESIS_PUBKEY); if ( (broadcastflag & 0x40) != 0 )
else if ( (broadcastflag & 0x40) != 0 ) {
jaddbits256(json,"destpub",destpub); jaddbits256(json,"categoryhash",categoryhash);
if ( (broadcastflag & 0x20) != 0 )
jaddbits256(json,"subhash",subhash);
}
//jadd64bits(json,"tag",tag); //jadd64bits(json,"tag",tag);
init_hexbytes_noT(checkstr,(void *)&checkc,sizeof(checkc)); init_hexbytes_noT(checkstr,(void *)&checkc,sizeof(checkc));
jaddstr(json,"check",checkstr); jaddstr(json,"check",checkstr);
@ -327,7 +347,7 @@ cJSON *SuperNET_bits2json(struct iguana_peer *addr,uint8_t *serialized,int32_t d
if ( plaintext != 0 ) if ( plaintext != 0 )
jaddnum(json,"plaintext",plaintext!=0); jaddnum(json,"plaintext",plaintext!=0);
if ( broadcastflag != 0 ) if ( broadcastflag != 0 )
jaddnum(json,"broadcast",broadcastflag); jaddnum(json,"broadcast",broadcastflag%SUPERNET_MAXHOPS);
if ( len < datalen ) if ( len < datalen )
{ {
//printf("len %d vs %d datalen\n",len,datalen); //printf("len %d vs %d datalen\n",len,datalen);
@ -425,7 +445,7 @@ int32_t DHT_dist(bits256 desthash,bits256 hash)
return(dist*0); return(dist*0);
} }
struct iguana_peer *iguana_peerfind(struct supernet_info *myinfo,struct iguana_info **coinp,uint32_t destipbits,bits256 destpub) struct iguana_peer *iguana_peerfind(struct supernet_info *myinfo,struct iguana_info **coinp,uint32_t destipbits,bits256 category,bits256 subhash)
{ {
int32_t i,j; struct iguana_peer *addr; int32_t i,j; struct iguana_peer *addr;
*coinp = 0; *coinp = 0;
@ -438,7 +458,7 @@ struct iguana_peer *iguana_peerfind(struct supernet_info *myinfo,struct iguana_i
addr = &Coins[i]->peers.active[j]; addr = &Coins[i]->peers.active[j];
if ( addr->usock >= 0 ) if ( addr->usock >= 0 )
{ {
if ( destipbits == addr->ipbits || category_peer(myinfo,Coins[i],addr,destpub) >= 0 ) if ( destipbits == addr->ipbits || category_peer(myinfo,addr,category,subhash) >= 0 )
{ {
*coinp = Coins[i]; *coinp = Coins[i];
return(addr); return(addr);
@ -450,9 +470,9 @@ struct iguana_peer *iguana_peerfind(struct supernet_info *myinfo,struct iguana_i
return(0); return(0);
} }
char *SuperNET_DHTsend(struct supernet_info *myinfo,uint32_t destipbits,bits256 destpub,char *hexmsg,int32_t maxdelay,int32_t broadcastflag,int32_t plaintext) char *SuperNET_DHTsend(struct supernet_info *myinfo,uint32_t destipbits,bits256 category,bits256 subhash,char *hexmsg,int32_t maxdelay,int32_t broadcastflag,int32_t plaintext)
{ {
int32_t i,j; char *jsonstr=0; bits256 hash; struct iguana_peer *addr; cJSON *json; struct iguana_info *coin; int32_t i,j; char *jsonstr=0; struct iguana_peer *addr; cJSON *json; struct iguana_info *coin;
if ( myinfo == 0 ) if ( myinfo == 0 )
return(clonestr("{\"error\":\"no supernet_info\"}")); return(clonestr("{\"error\":\"no supernet_info\"}"));
json = cJSON_CreateObject(); json = cJSON_CreateObject();
@ -464,11 +484,11 @@ char *SuperNET_DHTsend(struct supernet_info *myinfo,uint32_t destipbits,bits256
if ( plaintext != 0 ) if ( plaintext != 0 )
jaddnum(json,"plaintext",plaintext!=0); jaddnum(json,"plaintext",plaintext!=0);
jsonstr = jprint(json,1); jsonstr = jprint(json,1);
/*if ( SuperNET_hexmsgfind(myinfo,destpub,hexmsg,1) >= 0 ) if ( SuperNET_hexmsgfind(myinfo,category,subhash,hexmsg,1) >= 0 )
{ {
char str[65]; printf("duplicate hex.(%s) for %s\n",hexmsg,bits256_str(str,destpub)); char str[65]; printf("duplicate hex.(%s) for %s\n",hexmsg,bits256_str(str,category));
return(clonestr("{\"error\":\"duplicate packet rejected\"}")); return(clonestr("{\"error\":\"duplicate packet rejected\"}"));
}*/ }
if ( broadcastflag != 0 || destipbits == 0 ) if ( broadcastflag != 0 || destipbits == 0 )
{ {
for (i=0; i<IGUANA_MAXCOINS; i++) for (i=0; i<IGUANA_MAXCOINS; i++)
@ -478,24 +498,19 @@ char *SuperNET_DHTsend(struct supernet_info *myinfo,uint32_t destipbits,bits256
for (j=0; j<IGUANA_MAXPEERS; j++) for (j=0; j<IGUANA_MAXPEERS; j++)
{ {
addr = &Coins[i]->peers.active[j]; addr = &Coins[i]->peers.active[j];
if ( addr->usock >= 0 && addr->supernet != 0 && (broadcastflag != 0 || category_peer(myinfo,Coins[i],addr,destpub) >= 0) ) if ( addr->usock >= 0 && addr->supernet != 0 && (broadcastflag != 0 || category_peer(myinfo,addr,category,subhash) >= 0) )
{
hash = destpub, hash.uints[0] ^= addr->ipbits;
if ( SuperNET_hexmsgfind(myinfo,hash,hexmsg,1) >= 0 )
{ {
char str[65]; printf("BROADCAST[%d] %s SEND.(%ld) to %s\n",j,bits256_str(str,destpub),strlen(jsonstr),addr->ipaddr); char str[65]; printf("BROADCAST[%d] %s SEND.(%ld) to %s\n",j,bits256_str(str,category),strlen(jsonstr),addr->ipaddr);
iguana_send_supernet(Coins[i],addr,jsonstr,maxdelay==0?0:(rand()%maxdelay)); iguana_send_supernet(Coins[i],addr,jsonstr,maxdelay==0?0:(rand()%maxdelay));
} }
} }
} }
} }
}
return(clonestr("{\"result\":\"packet sent to all peers\"}")); return(clonestr("{\"result\":\"packet sent to all peers\"}"));
} }
if ( (addr= iguana_peerfind(myinfo,&coin,destipbits,destpub)) == 0 ) if ( (addr= iguana_peerfind(myinfo,&coin,destipbits,category,subhash)) == 0 )
return(clonestr("{\"error\":\"no route found\"}")); return(clonestr("{\"error\":\"no route found\"}"));
hash = destpub, hash.uints[0] ^= addr->ipbits; if ( SuperNET_hexmsgfind(myinfo,category,subhash,hexmsg,1) >= 0 )
if ( SuperNET_hexmsgfind(myinfo,hash,hexmsg,1) >= 0 )
{ {
printf("SEND.(%s) to %s\n",jsonstr,addr->ipaddr); printf("SEND.(%s) to %s\n",jsonstr,addr->ipaddr);
iguana_send_supernet(coin,addr,jsonstr,maxdelay==0?0:(rand()%maxdelay)); iguana_send_supernet(coin,addr,jsonstr,maxdelay==0?0:(rand()%maxdelay));
@ -504,45 +519,41 @@ char *SuperNET_DHTsend(struct supernet_info *myinfo,uint32_t destipbits,bits256
return(clonestr("{\"result\":\"no appropriate peers to send to\"}")); return(clonestr("{\"result\":\"no appropriate peers to send to\"}"));
} }
char *SuperNET_DHTencode(struct supernet_info *myinfo,char *destip,bits256 destpub,char *hexmsg,int32_t maxdelay,int32_t broadcastflag,int32_t plaintext) char *SuperNET_DHTencode(struct supernet_info *myinfo,char *destip,bits256 category,bits256 subhash,char *hexmsg,int32_t maxdelay,int32_t broadcastflag,int32_t plaintext)
{ {
uint32_t destipbits; char *retstr; uint32_t destipbits; char *retstr;
destipbits = (uint32_t)calc_ipbits(destip); destipbits = (uint32_t)calc_ipbits(destip);
if ( (retstr = SuperNET_DHTsend(myinfo,destipbits,destpub,hexmsg,maxdelay,broadcastflag,plaintext)) != 0 ) if ( (retstr = SuperNET_DHTsend(myinfo,destipbits,category,subhash,hexmsg,maxdelay,broadcastflag,plaintext)) != 0 )
free(retstr); free(retstr);
return(clonestr("{\"result\":\"DHT sent\"}")); return(clonestr("{\"result\":\"DHT sent\"}"));
} }
char *SuperNET_forward(struct supernet_info *myinfo,char *hexmsg,uint32_t destipbits,bits256 destpub,int32_t maxdelay,int32_t broadcastflag,int32_t plaintext) char *SuperNET_forward(struct supernet_info *myinfo,char *hexmsg,uint32_t destipbits,bits256 category,bits256 subhash,int32_t maxdelay,int32_t broadcastflag,int32_t plaintext)
{ {
return(SuperNET_DHTsend(myinfo,destipbits,destpub,hexmsg,maxdelay,broadcastflag,plaintext)); return(SuperNET_DHTsend(myinfo,destipbits,category,subhash,hexmsg,maxdelay,broadcastflag,plaintext));
} }
int32_t SuperNET_destination(struct supernet_info *myinfo,uint32_t *destipbitsp,bits256 *destpubp,int32_t *maxdelayp,cJSON *json,char *remoteaddr) int32_t SuperNET_destination(struct supernet_info *myinfo,uint32_t *destipbitsp,bits256 *categoryp,bits256 *subhashp,int32_t *maxdelayp,cJSON *json,char *remoteaddr)
{ {
char *destip; int32_t destflag = 0; char *destip; int32_t destflag = 0;
if ( (destip= jstr(json,"destip")) != 0 ) if ( (destip= jstr(json,"destip")) != 0 )
*destipbitsp = (uint32_t)calc_ipbits(destip); *destipbitsp = (uint32_t)calc_ipbits(destip);
else *destipbitsp = 0; else *destipbitsp = 0;
*maxdelayp = juint(json,"delay"); *maxdelayp = juint(json,"delay");
*destpubp = jbits256(json,"destpub"); *categoryp = jbits256(json,"categoryhash");
*subhashp = jbits256(json,"subhash");
if ( *destipbitsp != 0 ) if ( *destipbitsp != 0 )
{ {
if ( *destipbitsp == myinfo->myaddr.selfipbits ) if ( *destipbitsp == myinfo->myaddr.selfipbits )
destflag |= SUPERNET_ISMINE; destflag |= SUPERNET_ISMINE;
else destflag |= SUPERNET_FORWARD; else destflag |= SUPERNET_FORWARD;
} }
else if ( bits256_nonz(*destpubp) > 0 ) else if ( bits256_nonz(*categoryp) > 0 )
{ {
if ( memcmp(destpubp,myinfo->myaddr.pubkey.bytes,sizeof(*destpubp)) == 0 ) if ( category_peer(myinfo,0,*categoryp,*subhashp) > 0 )
destflag |= SUPERNET_ISMINE;
else
{
if ( memcmp(destpubp,GENESIS_PUBKEY.bytes,sizeof(*destpubp)) == 0 )
destflag |= SUPERNET_ISMINE; destflag |= SUPERNET_ISMINE;
destflag |= SUPERNET_FORWARD; destflag |= SUPERNET_FORWARD;
} }
}
if ( remoteaddr == 0 || remoteaddr[0] == 0 || strcmp(remoteaddr,"127.0.0.1") == 0 ) if ( remoteaddr == 0 || remoteaddr[0] == 0 || strcmp(remoteaddr,"127.0.0.1") == 0 )
destflag |= SUPERNET_ISMINE; destflag |= SUPERNET_ISMINE;
return(destflag); return(destflag);
@ -550,7 +561,8 @@ int32_t SuperNET_destination(struct supernet_info *myinfo,uint32_t *destipbitsp,
char *SuperNET_JSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr) char *SuperNET_JSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr)
{ {
int32_t destflag,maxdelay,flag=0; bits256 destpub; uint32_t destipbits; cJSON *retjson; char hexbuf[8192]; bits256 category,subhash;
int32_t hexlen,destflag,maxdelay,flag=0; uint32_t destipbits; cJSON *retjson;
char *forwardstr=0,*retstr=0,*agent=0,*method=0,*message,*hexmsg=0,*jsonstr=0; uint64_t tag; char *forwardstr=0,*retstr=0,*agent=0,*method=0,*message,*hexmsg=0,*jsonstr=0; uint64_t tag;
if ( remoteaddr != 0 && strcmp(remoteaddr,"127.0.0.1") == 0 ) if ( remoteaddr != 0 && strcmp(remoteaddr,"127.0.0.1") == 0 )
remoteaddr = 0; remoteaddr = 0;
@ -560,31 +572,33 @@ char *SuperNET_JSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr)
jadd64bits(json,"tag",tag); jadd64bits(json,"tag",tag);
} }
//printf("SuperNET_JSON.(%s) remote.(%s)\n",jprint(json,0),remoteaddr!=0?remoteaddr:""); //printf("SuperNET_JSON.(%s) remote.(%s)\n",jprint(json,0),remoteaddr!=0?remoteaddr:"");
destflag = SuperNET_destination(myinfo,&destipbits,&destpub,&maxdelay,json,remoteaddr); destflag = SuperNET_destination(myinfo,&destipbits,&category,&subhash,&maxdelay,json,remoteaddr);
//printf("destflag.%d\n",destflag); //printf("destflag.%d\n",destflag);
if ( (hexmsg= jstr(json,"hexmsg")) == 0 && (message= jstr(json,"message")) == 0 ) if ( (hexmsg= jstr(json,"hexmsg")) == 0 && (message= jstr(json,"message")) == 0 )
{ {
jsonstr = jprint(json,0); jsonstr = jprint(json,0);
hexmsg = malloc(strlen(jsonstr)*2+1); hexlen = (int32_t)strlen(jsonstr);
if ( hexlen*2+1 > sizeof(hexbuf) )
hexmsg = malloc(hexlen*2+1), flag = 1;
else hexmsg = hexbuf;
init_hexbytes_noT(hexmsg,(uint8_t *)jsonstr,(int32_t)strlen(jsonstr)+1); init_hexbytes_noT(hexmsg,(uint8_t *)jsonstr,(int32_t)strlen(jsonstr)+1);
flag = 1;
} }
if ( (destflag & SUPERNET_FORWARD) != 0 ) if ( (destflag & SUPERNET_FORWARD) != 0 )
{ {
if ( hexmsg != 0 ) if ( hexmsg != 0 )
{ {
//printf("check.(%s)\n",hexmsg); //printf("check.(%s)\n",hexmsg);
if ( SuperNET_hexmsgfind(myinfo,destpub,hexmsg,0) < 0 ) if ( SuperNET_hexmsgfind(myinfo,category,subhash,hexmsg,0) < 0 )
{ {
SuperNET_hexmsgadd(myinfo,destpub,hexmsg,tai_now()); SuperNET_hexmsgadd(myinfo,category,subhash,hexmsg,tai_now());
forwardstr = SuperNET_forward(myinfo,hexmsg,destipbits,destpub,maxdelay,juint(json,"broadcast"),juint(json,"plaintext")!=0); forwardstr = SuperNET_forward(myinfo,hexmsg,destipbits,category,subhash,maxdelay,juint(json,"broadcast"),juint(json,"plaintext")!=0);
} }
} }
} }
if ( (destflag & SUPERNET_ISMINE) != 0 && (agent= jstr(json,"agent")) != 0 && (method= jstr(json,"method")) != 0 ) if ( (destflag & SUPERNET_ISMINE) != 0 && (agent= jstr(json,"agent")) != 0 && (method= jstr(json,"method")) != 0 )
{ {
if ( hexmsg != 0 && SuperNET_hexmsgfind(myinfo,destpub,hexmsg,0) < 0 ) if ( hexmsg != 0 && SuperNET_hexmsgfind(myinfo,category,subhash,hexmsg,0) < 0 )
SuperNET_hexmsgadd(myinfo,destpub,hexmsg,tai_now()); SuperNET_hexmsgadd(myinfo,category,subhash,hexmsg,tai_now());
if ( (retstr= SuperNET_processJSON(myinfo,json,remoteaddr)) != 0 ) if ( (retstr= SuperNET_processJSON(myinfo,json,remoteaddr)) != 0 )
{ {
//printf("retstr.(%s)\n",retstr); //printf("retstr.(%s)\n",retstr);
@ -600,7 +614,7 @@ char *SuperNET_JSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr)
} }
} else printf("null retstr from SuperNET_JSON\n"); } else printf("null retstr from SuperNET_JSON\n");
} }
if ( flag != 0 && hexmsg != 0 ) if ( flag != 0 && hexmsg != 0 && hexmsg != hexbuf )
free(hexmsg); free(hexmsg);
if ( retstr == 0 ) if ( retstr == 0 )
retstr = forwardstr, forwardstr = 0; retstr = forwardstr, forwardstr = 0;
@ -614,8 +628,9 @@ char *SuperNET_JSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr)
char *SuperNET_p2p(struct iguana_info *coin,struct iguana_peer *addr,int32_t *delaymillisp,char *ipaddr,uint8_t *data,int32_t datalen,int32_t compressed) char *SuperNET_p2p(struct iguana_info *coin,struct iguana_peer *addr,int32_t *delaymillisp,char *ipaddr,uint8_t *data,int32_t datalen,int32_t compressed)
{ {
struct supernet_info *myinfo;char *myipaddr,*method,*retstr,*checkstr; void *ptr=0; struct supernet_info *myinfo;char *myipaddr,*method,*retstr,*checkstr; void *ptr=0;
bits256 senderpub,privkey,pubkey,nextprivkey,nextpubkey,nextdestpub; uint16_t checkc,othercheckc; bits256 senderpub,privkey,pubkey,nextprivkey,nextpubkey,nextdestpub;
cJSON *json,*retjson; int32_t offset,maxdelay,msglen = datalen; uint8_t space[8192],*msgbits = 0; uint16_t checkc,othercheckc; cJSON *json,*retjson; int32_t offset,maxdelay,msglen = datalen;
uint8_t space[8192],*msgbits = 0;
myinfo = SuperNET_MYINFO(0); myinfo = SuperNET_MYINFO(0);
retstr = 0; retstr = 0;
*delaymillisp = 0; *delaymillisp = 0;
@ -991,13 +1006,13 @@ STRING_ARG(SuperNET,getpeers,activecoin)
return(jprint(retjson,1)); return(jprint(retjson,1));
} }
TWOSTRINGS_AND_HASH_AND_TWOINTS(SuperNET,DHT,hexmsg,destip,destpub,maxdelay,broadcast) TWOSTRINGS_AND_TWOHASHES_AND_TWOINTS(SuperNET,DHT,hexmsg,destip,categoryhash,subhash,maxdelay,broadcast)
{ {
if ( remoteaddr != 0 ) if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"cant remote DHT\"}")); return(clonestr("{\"error\":\"cant remote DHT\"}"));
else if ( hexmsg == 0 || is_hexstr(hexmsg,(int32_t)strlen(hexmsg)) <= 0 ) else if ( hexmsg == 0 || is_hexstr(hexmsg,(int32_t)strlen(hexmsg)) <= 0 )
return(clonestr("{\"error\":\"hexmsg missing or not in hex\"}")); return(clonestr("{\"error\":\"hexmsg missing or not in hex\"}"));
return(SuperNET_DHTencode(myinfo,destip,destpub,hexmsg,maxdelay,broadcast,juint(json,"plaintext")!=0)); return(SuperNET_DHTencode(myinfo,destip,categoryhash,subhash,hexmsg,maxdelay,broadcast,juint(json,"plaintext")!=0));
} }
HASH_AND_STRING(SuperNET,saveconf,wallethash,confjsonstr) HASH_AND_STRING(SuperNET,saveconf,wallethash,confjsonstr)
@ -1012,15 +1027,17 @@ HASH_ARRAY_STRING(SuperNET,layer,mypriv,otherpubs,str)
THREE_STRINGS(SuperNET,announce,category,subcategory,message) THREE_STRINGS(SuperNET,announce,category,subcategory,message)
{ {
bits256 categoryhash; bits256 categoryhash,subhash;
vcalc_sha256(0,categoryhash.bytes,(uint8_t *)category,(int32_t)strlen(category)); vcalc_sha256(0,categoryhash.bytes,(uint8_t *)category,(int32_t)strlen(category));
return(SuperNET_categorymulticast(myinfo,0,categoryhash,subcategory,message,juint(json,"maxdelay"),juint(json,"broadcast"),juint(json,"plaintext"))); vcalc_sha256(0,subhash.bytes,(uint8_t *)subcategory,(int32_t)strlen(subcategory));
return(SuperNET_categorymulticast(myinfo,0,categoryhash,subhash,message,juint(json,"maxdelay"),juint(json,"broadcast"),juint(json,"plaintext")));
} }
THREE_STRINGS(SuperNET,survey,category,subcategory,message) THREE_STRINGS(SuperNET,survey,category,subcategory,message)
{ {
bits256 categoryhash; bits256 categoryhash,subhash;
vcalc_sha256(0,categoryhash.bytes,(uint8_t *)category,(int32_t)strlen(category)); vcalc_sha256(0,categoryhash.bytes,(uint8_t *)category,(int32_t)strlen(category));
return(SuperNET_categorymulticast(myinfo,1,categoryhash,subcategory,message,juint(json,"maxdelay"),juint(json,"broadcast"),juint(json,"plaintext"))); vcalc_sha256(0,subhash.bytes,(uint8_t *)subcategory,(int32_t)strlen(subcategory));
return(SuperNET_categorymulticast(myinfo,1,categoryhash,subhash,message,juint(json,"maxdelay"),juint(json,"broadcast"),juint(json,"plaintext")));
} }
#include "../includes/iguana_apiundefs.h" #include "../includes/iguana_apiundefs.h"

10
iguana/SuperNET.h

@ -115,10 +115,10 @@ void SuperNET_init(void *args);
char *SuperNET_JSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr); char *SuperNET_JSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr);
char *SuperNET_jsonstr(struct supernet_info *myinfo,char *jsonstr,char *remoteaddr); char *SuperNET_jsonstr(struct supernet_info *myinfo,char *jsonstr,char *remoteaddr);
char *SuperNET_DHTencode(struct supernet_info *myinfo,char *destip,bits256 destpub,char *hexmsg,int32_t maxdelay,int32_t broadcastflag,int32_t plaintext); char *SuperNET_DHTencode(struct supernet_info *myinfo,char *destip,bits256 category,bits256 subhash,char *hexmsg,int32_t maxdelay,int32_t broadcastflag,int32_t plaintext);
char *SuperNET_parser(struct supernet_info *myinfo,char *agent,char *method,cJSON *json,char *remoteaddr); char *SuperNET_parser(struct supernet_info *myinfo,char *agent,char *method,cJSON *json,char *remoteaddr);
char *SuperNET_processJSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr); char *SuperNET_processJSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr);
char *SuperNET_DHTsend(struct supernet_info *myinfo,uint32_t destipbits,bits256 destpub,char *hexmsg,int32_t maxdelay,int32_t broadcastflag,int32_t plaintext); char *SuperNET_DHTsend(struct supernet_info *myinfo,uint32_t destipbits,bits256 category,bits256 subhash,char *hexmsg,int32_t maxdelay,int32_t broadcastflag,int32_t plaintext);
uint16_t SuperNET_API2num(char *agent,char *method); uint16_t SuperNET_API2num(char *agent,char *method);
int32_t SuperNET_num2API(char *agent,char *method,uint16_t num); int32_t SuperNET_num2API(char *agent,char *method,uint16_t num);
bits256 SuperNET_sharedseed(bits256 privkey,bits256 otherpub); bits256 SuperNET_sharedseed(bits256 privkey,bits256 otherpub);
@ -126,10 +126,10 @@ int32_t SuperNET_decrypt(bits256 *senderpubp,uint64_t *senderbitsp,uint32_t *tim
int32_t SuperNET_str2hex(uint8_t *hex,char *str); int32_t SuperNET_str2hex(uint8_t *hex,char *str);
void SuperNET_hex2str(char *str,uint8_t *hex,int32_t len); void SuperNET_hex2str(char *str,uint8_t *hex,int32_t len);
void SuperNET_hexmsgadd(struct supernet_info *myinfo,bits256 destpub,char *hexmsg,struct tai now); void SuperNET_hexmsgadd(struct supernet_info *myinfo,bits256 category,bits256 subhash,char *hexmsg,struct tai now);
int32_t SuperNET_hexmsgfind(struct supernet_info *myinfo,bits256 dest,char *hexmsg,int32_t addflag); int32_t SuperNET_hexmsgfind(struct supernet_info *myinfo,bits256 category,bits256 subhash,char *hexmsg,int32_t addflag);
char *SuperNET_categorymulticast(struct supernet_info *myinfo,int32_t surveyflag,bits256 categoryhash,char *subcategory,char *message,int32_t maxdelay,int32_t broadcastflag,int32_t plaintext); char *SuperNET_categorymulticast(struct supernet_info *myinfo,int32_t surveyflag,bits256 categoryhash,bits256 subcategory,char *message,int32_t maxdelay,int32_t broadcastflag,int32_t plaintext);
#endif #endif

20
iguana/SuperNET_category.c

@ -15,24 +15,22 @@
#include "iguana777.h" #include "iguana777.h"
int32_t category_peer(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,bits256 destpub) int32_t category_peer(struct supernet_info *myinfo,struct iguana_peer *addr,bits256 category,bits256 subhash)
{ {
if ( memcmp(addr->pubkey.bytes,destpub.bytes,sizeof(destpub)) == 0 )
return(1); return(1);
else return(-1);
} }
int32_t category_plaintext(struct supernet_info *myinfo,bits256 categoryhash,int32_t plaintext) int32_t category_plaintext(struct supernet_info *myinfo,bits256 category,bits256 subhash,int32_t plaintext)
{ {
return(plaintext); return(plaintext);
} }
int32_t category_maxdelay(struct supernet_info *myinfo,bits256 categoryhash,int32_t maxdelay) int32_t category_maxdelay(struct supernet_info *myinfo,bits256 category,bits256 subhash,int32_t maxdelay)
{ {
return(maxdelay); return(maxdelay);
} }
int32_t category_broadcast(struct supernet_info *myinfo,bits256 categoryhash,int32_t broadcastflag) int32_t category_broadcast(struct supernet_info *myinfo,bits256 category,bits256 subhash,int32_t broadcastflag)
{ {
if ( broadcastflag < 1 ) if ( broadcastflag < 1 )
broadcastflag = 1; broadcastflag = 1;
@ -41,7 +39,7 @@ int32_t category_broadcast(struct supernet_info *myinfo,bits256 categoryhash,int
return(broadcastflag); return(broadcastflag);
} }
char *SuperNET_categorymulticast(struct supernet_info *myinfo,int32_t surveyflag,bits256 categoryhash,char *subcategory,char *message,int32_t maxdelay,int32_t broadcastflag,int32_t plaintext) char *SuperNET_categorymulticast(struct supernet_info *myinfo,int32_t surveyflag,bits256 category,bits256 subhash,char *message,int32_t maxdelay,int32_t broadcastflag,int32_t plaintext)
{ {
char *hexmsg,*retstr; int32_t len; char *hexmsg,*retstr; int32_t len;
len = (int32_t)strlen(message); len = (int32_t)strlen(message);
@ -50,10 +48,10 @@ char *SuperNET_categorymulticast(struct supernet_info *myinfo,int32_t surveyflag
hexmsg = malloc((len << 1) + 1); hexmsg = malloc((len << 1) + 1);
init_hexbytes_noT(hexmsg,(uint8_t *)message,len+1); init_hexbytes_noT(hexmsg,(uint8_t *)message,len+1);
} else hexmsg = message; } else hexmsg = message;
plaintext = category_plaintext(myinfo,categoryhash,plaintext); plaintext = category_plaintext(myinfo,category,subhash,plaintext);
broadcastflag = category_broadcast(myinfo,categoryhash,broadcastflag); broadcastflag = category_broadcast(myinfo,category,subhash,broadcastflag);
maxdelay = category_maxdelay(myinfo,categoryhash,maxdelay); maxdelay = category_maxdelay(myinfo,category,subhash,maxdelay);
retstr = SuperNET_DHTsend(myinfo,0,categoryhash,hexmsg,maxdelay,broadcastflag,plaintext); retstr = SuperNET_DHTsend(myinfo,0,category,subhash,hexmsg,maxdelay,broadcastflag,plaintext);
if ( hexmsg != message) if ( hexmsg != message)
free(hexmsg); free(hexmsg);
return(retstr); return(retstr);

27
iguana/SuperNET_hexmsg.c

@ -15,16 +15,18 @@
#include "iguana777.h" #include "iguana777.h"
int32_t SuperNET_hexmsgfind(struct supernet_info *myinfo,bits256 dest,char *hexmsg,int32_t addflag) int32_t SuperNET_hexmsgfind(struct supernet_info *myinfo,bits256 category,bits256 subhash,char *hexmsg,int32_t addflag)
{ {
static int lastpurge; static uint64_t Packetcache[1024]; static int lastpurge; static uint64_t Packetcache[1024];
bits256 packethash; int32_t i,datalen; bits256 packethash; int32_t i,datalen;
datalen = (int32_t)strlen(hexmsg) + 1; datalen = (int32_t)strlen(hexmsg) + 1;
vcalc_sha256(0,packethash.bytes,(void *)hexmsg,datalen); vcalc_sha256(0,packethash.bytes,(void *)hexmsg,datalen);
if ( bits256_nonz(dest) == 0 ) if ( bits256_nonz(category) == 0 )
dest = GENESIS_PUBKEY; category = GENESIS_PUBKEY;
packethash = curve25519(dest,packethash); if ( bits256_nonz(subhash) == 0 )
printf("addflag.%d packethash.%llx dest.%llx\n",addflag,(long long)packethash.txid,(long long)dest.txid); subhash = GENESIS_PUBKEY;
packethash = curve25519(category,packethash);
printf("addflag.%d packethash.%llx dest.%llx\n",addflag,(long long)packethash.txid,(long long)category.txid);
for (i=0; i<sizeof(Packetcache)/sizeof(*Packetcache); i++) for (i=0; i<sizeof(Packetcache)/sizeof(*Packetcache); i++)
{ {
if ( Packetcache[i] == 0 ) if ( Packetcache[i] == 0 )
@ -55,11 +57,16 @@ int32_t SuperNET_hexmsgfind(struct supernet_info *myinfo,bits256 dest,char *hexm
return(-1); return(-1);
} }
void SuperNET_hexmsgadd(struct supernet_info *myinfo,bits256 destpub,char *hexmsg,struct tai now) void SuperNET_hexmsgadd(struct supernet_info *myinfo,bits256 category,bits256 subhash,char *hexmsg,struct tai now)
{ {
char str[65]; char str[512],str2[65];
if ( memcmp(destpub.bytes,GENESIS_PUBKEY.bytes,sizeof(destpub)) == 0 ) if ( memcmp(category.bytes,GENESIS_PUBKEY.bytes,sizeof(category)) == 0 )
strcpy(str,"BROADCAST"); strcpy(str,"BROADCAST.");
else bits256_str(str,destpub); else bits256_str(str,category);
if ( memcmp(subhash.bytes,GENESIS_PUBKEY.bytes,sizeof(subhash)) != 0 )
{
bits256_str(str2,subhash);
strcat(str,str2);
}
printf("HEXMSG.(%s) -> %s\n",hexmsg,str); printf("HEXMSG.(%s) -> %s\n",hexmsg,str);
} }

2
iguana/iguana777.h

@ -696,7 +696,7 @@ char *iguana_blockingjsonstr(struct supernet_info *myinfo,char *jsonstr,uint64_t
void iguana_iAkill(struct iguana_info *coin,struct iguana_peer *addr,int32_t markflag); void iguana_iAkill(struct iguana_info *coin,struct iguana_peer *addr,int32_t markflag);
cJSON *SuperNET_bits2json(struct iguana_peer *addr,uint8_t *serialized,int32_t datalen); cJSON *SuperNET_bits2json(struct iguana_peer *addr,uint8_t *serialized,int32_t datalen);
int32_t SuperNET_sendmsg(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,bits256 destpub,bits256 mypriv,bits256 mypub,uint8_t *msg,int32_t len,uint8_t *data,int32_t delaymillis); int32_t SuperNET_sendmsg(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,bits256 destpub,bits256 mypriv,bits256 mypub,uint8_t *msg,int32_t len,uint8_t *data,int32_t delaymillis);
int32_t category_peer(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,bits256 destpub); int32_t category_peer(struct supernet_info *myinfo,struct iguana_peer *addr,bits256 category,bits256 subhash);
extern queue_t bundlesQ; extern queue_t bundlesQ;

34
iguana/iguana_bitmap.c

@ -1159,3 +1159,37 @@ void iguana_bitmap(char *space,int32_t max,char *name)
//printf("BIGMAP.(%s)\n",space); //printf("BIGMAP.(%s)\n",space);
} }
} }
#include "../includes/iguana_apidefs.h"
#include "../includes/iguana_apideclares.h"
STRING_AND_TWOINTS(mouse,change,name,x,y)
{
return(clonestr("{\"result\":\"changed\"}"));
}
STRING_ARG(mouse,leave,name)
{
return(clonestr("{\"result\":\"left\"}"));
}
STRING_AND_TWOINTS(mouse,click,name,x,y)
{
return(clonestr("{\"result\":\"click\"}"));
}
STRING_AND_INT(keyboard,key,name,c)
{
return(clonestr("{\"result\":\"key\"}"));
}
STRING_AND_TWOINTS(mouse,image,name,x,y)
{
return(clonestr("{\"result\":\"opened\"}"));
}
STRING_ARG(mouse,close,name)
{
return(clonestr("{\"result\":\"closed\"}"));
}
#include "../includes/iguana_apiundefs.h"

4
iguana/iguana_json.c

@ -85,6 +85,7 @@ cJSON *SuperNET_helpjson()
#define IGUANA_HELP_SSH(agent,name,str,str2,hash) array = helpjson(IGUANA_ARGS,#agent,#name,helparray3(cJSON_CreateArray(),helpitem(#str,"string"),helpitem(#str2,"string"),helpitem(#hash,"hash"))) #define IGUANA_HELP_SSH(agent,name,str,str2,hash) array = helpjson(IGUANA_ARGS,#agent,#name,helparray3(cJSON_CreateArray(),helpitem(#str,"string"),helpitem(#str2,"string"),helpitem(#hash,"hash")))
#define IGUANA_HELP_SSHI(agent,name,str,str2,hash,val) array = helpjson(IGUANA_ARGS,#agent,#name,helparray4(cJSON_CreateArray(),helpitem(#str,"string"),helpitem(#str2,"string"),helpitem(#hash,"hash"),helpitem(#val,"int"))) #define IGUANA_HELP_SSHI(agent,name,str,str2,hash,val) array = helpjson(IGUANA_ARGS,#agent,#name,helparray4(cJSON_CreateArray(),helpitem(#str,"string"),helpitem(#str2,"string"),helpitem(#hash,"hash"),helpitem(#val,"int")))
#define IGUANA_HELP_SSHII(agent,name,str,str2,hash,val,val2) array = helpjson(IGUANA_ARGS,#agent,#name,helparray5(cJSON_CreateArray(),helpitem(#str,"string"),helpitem(#str2,"string"),helpitem(#hash,"hash"),helpitem(#val,"int"),helpitem(#val2,"int"))) #define IGUANA_HELP_SSHII(agent,name,str,str2,hash,val,val2) array = helpjson(IGUANA_ARGS,#agent,#name,helparray5(cJSON_CreateArray(),helpitem(#str,"string"),helpitem(#str2,"string"),helpitem(#hash,"hash"),helpitem(#val,"int"),helpitem(#val2,"int")))
#define IGUANA_HELP_SSHHII(agent,name,str,str2,hash,hash2,val,val2) array = helpjson(IGUANA_ARGS,#agent,#name,helparray6(cJSON_CreateArray(),helpitem(#str,"string"),helpitem(#str2,"string"),helpitem(#hash,"hash"),helpitem(#hash2,"hash"),helpitem(#val,"int"),helpitem(#val2,"int")))
#define IGUANA_HELP_SI(agent,name,str,val) array = helpjson(IGUANA_ARGS,#agent,#name,helparray2(cJSON_CreateArray(),helpitem(#str,"string"),helpitem(#val,"int"))) #define IGUANA_HELP_SI(agent,name,str,val) array = helpjson(IGUANA_ARGS,#agent,#name,helparray2(cJSON_CreateArray(),helpitem(#str,"string"),helpitem(#val,"int")))
#define IGUANA_HELP_SII(agent,name,str,val,val2) array = helpjson(IGUANA_ARGS,#agent,#name,helparray3(cJSON_CreateArray(),helpitem(#str,"string"),helpitem(#val,"int"),helpitem(#val2,"int"))) #define IGUANA_HELP_SII(agent,name,str,val,val2) array = helpjson(IGUANA_ARGS,#agent,#name,helparray3(cJSON_CreateArray(),helpitem(#str,"string"),helpitem(#val,"int"),helpitem(#val2,"int")))
#define IGUANA_HELP_SSI(agent,name,str,str2,val) array = helpjson(IGUANA_ARGS,#agent,#name,helparray3(cJSON_CreateArray(),helpitem(#str,"string"),helpitem(#str2,"string"),helpitem(#val,"int"))) #define IGUANA_HELP_SSI(agent,name,str,str2,val) array = helpjson(IGUANA_ARGS,#agent,#name,helparray3(cJSON_CreateArray(),helpitem(#str,"string"),helpitem(#str2,"string"),helpitem(#val,"int")))
@ -143,6 +144,7 @@ cJSON *SuperNET_helpjson()
#define TWOSTRINGS_AND_INT IGUANA_HELP_SSI #define TWOSTRINGS_AND_INT IGUANA_HELP_SSI
#define TWOSTRINGS_AND_HASH IGUANA_HELP_SSH #define TWOSTRINGS_AND_HASH IGUANA_HELP_SSH
#define TWOSTRINGS_AND_HASH_AND_TWOINTS IGUANA_HELP_SSHII #define TWOSTRINGS_AND_HASH_AND_TWOINTS IGUANA_HELP_SSHII
#define TWOSTRINGS_AND_TWOHASHES_AND_TWOINTS IGUANA_HELP_SSHHII
#define THREE_INTS IGUANA_HELP_III #define THREE_INTS IGUANA_HELP_III
#define TWOHASHES_AND_STRING IGUANA_HELP_HHS #define TWOHASHES_AND_STRING IGUANA_HELP_HHS
#define HASH_ARRAY_STRING IGUANA_HELP_HAS #define HASH_ARRAY_STRING IGUANA_HELP_HAS
@ -708,6 +710,7 @@ char *SuperNET_parser(struct supernet_info *myinfo,char *agent,char *method,cJSO
#define IGUANA_DISPATCH_SSH(agent,name,str,str2,hash) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jstr(json,#str),jstr(json,#str2),jbits256(json,#hash))) #define IGUANA_DISPATCH_SSH(agent,name,str,str2,hash) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jstr(json,#str),jstr(json,#str2),jbits256(json,#hash)))
#define IGUANA_DISPATCH_SSHI(agent,name,str,str2,hash,val) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jstr(json,#str),jstr(json,#str2),jbits256(json,#hash),juint(json,#val))) #define IGUANA_DISPATCH_SSHI(agent,name,str,str2,hash,val) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jstr(json,#str),jstr(json,#str2),jbits256(json,#hash),juint(json,#val)))
#define IGUANA_DISPATCH_SSHII(agent,name,str,str2,hash,val,val2) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jstr(json,#str),jstr(json,#str2),jbits256(json,#hash),juint(json,#val),juint(json,#val2))) #define IGUANA_DISPATCH_SSHII(agent,name,str,str2,hash,val,val2) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jstr(json,#str),jstr(json,#str2),jbits256(json,#hash),juint(json,#val),juint(json,#val2)))
#define IGUANA_DISPATCH_SSHHII(agent,name,str,str2,hash,hash2,val,val2) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jstr(json,#str),jstr(json,#str2),jbits256(json,#hash),jbits256(json,#hash2),juint(json,#val),juint(json,#val2)))
#define IGUANA_DISPATCH_SI(agent,name,str,val) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jstr(json,#str),juint(json,#val))) #define IGUANA_DISPATCH_SI(agent,name,str,val) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jstr(json,#str),juint(json,#val)))
#define IGUANA_DISPATCH_SII(agent,name,str,val,val2) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jstr(json,#str),juint(json,#val),juint(json,#val2))) #define IGUANA_DISPATCH_SII(agent,name,str,val,val2) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jstr(json,#str),juint(json,#val),juint(json,#val2)))
#define IGUANA_DISPATCH_SSI(agent,name,str,str2,val) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jstr(json,#str),jstr(json,#str2),juint(json,#val))) #define IGUANA_DISPATCH_SSI(agent,name,str,str2,val) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jstr(json,#str),jstr(json,#str2),juint(json,#val)))
@ -767,6 +770,7 @@ char *SuperNET_parser(struct supernet_info *myinfo,char *agent,char *method,cJSO
#define TWOSTRINGS_AND_INT IGUANA_DISPATCH_SSI #define TWOSTRINGS_AND_INT IGUANA_DISPATCH_SSI
#define TWOSTRINGS_AND_HASH IGUANA_DISPATCH_SSH #define TWOSTRINGS_AND_HASH IGUANA_DISPATCH_SSH
#define TWOSTRINGS_AND_HASH_AND_TWOINTS IGUANA_DISPATCH_SSHII #define TWOSTRINGS_AND_HASH_AND_TWOINTS IGUANA_DISPATCH_SSHII
#define TWOSTRINGS_AND_TWOHASHES_AND_TWOINTS IGUANA_DISPATCH_SSHHII
#define THREE_INTS IGUANA_DISPATCH_III #define THREE_INTS IGUANA_DISPATCH_III
#define TWOHASHES_AND_STRING IGUANA_DISPATCH_HHS #define TWOHASHES_AND_STRING IGUANA_DISPATCH_HHS
#define HASH_ARRAY_STRING IGUANA_DISPATCH_HAS #define HASH_ARRAY_STRING IGUANA_DISPATCH_HAS

2
iguana/iguana_rpc.c

@ -720,7 +720,7 @@ char *SuperNET_rpcparse(struct supernet_info *myinfo,char *retbuf,int32_t bufsiz
j = i = 0; j = i = 0;
if ( strcmp(&url[i],"/") == 0 && strcmp(urlmethod,"GET") == 0 ) if ( strcmp(&url[i],"/") == 0 && strcmp(urlmethod,"GET") == 0 )
return(OS_filestr(&filesize,"index7778.html")); return(OS_filestr(&filesize,"index7778.html"));
printf("url.(%s) method.(%s)\n",&url[i],urlmethod); //printf("url.(%s) method.(%s)\n",&url[i],urlmethod);
if ( strncmp(&url[i],"/api",strlen("/api")) == 0 ) if ( strncmp(&url[i],"/api",strlen("/api")) == 0 )
{ {
*jsonflagp = 1; *jsonflagp = 1;

2
includes/iguana_api.h

@ -18,8 +18,6 @@
#include "../includes/iguana_apidefs.h" #include "../includes/iguana_apidefs.h"
#include "../includes/iguana_apideclares.h" #include "../includes/iguana_apideclares.h"
//#undef IGUANA_ARGS
#include "../includes/iguana_apiundefs.h" #include "../includes/iguana_apiundefs.h"
#endif #endif

9
includes/iguana_apideclares.h

@ -16,7 +16,14 @@
ZERO_ARGS(SuperNET,help); ZERO_ARGS(SuperNET,help);
TWO_STRINGS(SuperNET,html,agentform,htmlfile); TWO_STRINGS(SuperNET,html,agentform,htmlfile);
STRING_ARG(SuperNET,bitcoinrpc,setcoin); STRING_ARG(SuperNET,bitcoinrpc,setcoin);
TWOSTRINGS_AND_HASH_AND_TWOINTS(SuperNET,DHT,hexmsg,destip,destpub,maxdelay,broadcast); TWOSTRINGS_AND_TWOHASHES_AND_TWOINTS(SuperNET,DHT,hexmsg,destip,categoryhash,subhash,maxdelay,broadcast);
STRING_AND_TWOINTS(mouse,image,name,x,y);
STRING_AND_TWOINTS(mouse,change,name,x,y);
STRING_AND_TWOINTS(mouse,click,name,x,y);
STRING_ARG(mouse,close,name);
STRING_ARG(mouse,leave,name);
STRING_AND_INT(keyboard,key,name,c);
THREE_STRINGS(SuperNET,rosetta,passphrase,pin,showprivkey); THREE_STRINGS(SuperNET,rosetta,passphrase,pin,showprivkey);
ZERO_ARGS(SuperNET,keypair); ZERO_ARGS(SuperNET,keypair);

2
includes/iguana_apidefs.h

@ -22,6 +22,7 @@
#define IGUANA_CFUNC_SSH(agent,name,str,str2,hash) char *agent ## _ ## name(IGUANA_ARGS,char *str,char *str2,bits256 hash) #define IGUANA_CFUNC_SSH(agent,name,str,str2,hash) char *agent ## _ ## name(IGUANA_ARGS,char *str,char *str2,bits256 hash)
#define IGUANA_CFUNC_SSHI(agent,name,str,str2,hash,val) char *agent ## _ ## name(IGUANA_ARGS,char *str,char *str2,bits256 hash,int32_t val) #define IGUANA_CFUNC_SSHI(agent,name,str,str2,hash,val) char *agent ## _ ## name(IGUANA_ARGS,char *str,char *str2,bits256 hash,int32_t val)
#define IGUANA_CFUNC_SSHII(agent,name,str,str2,hash,val,val2) char *agent ## _ ## name(IGUANA_ARGS,char *str,char *str2,bits256 hash,int32_t val,int32_t val2) #define IGUANA_CFUNC_SSHII(agent,name,str,str2,hash,val,val2) char *agent ## _ ## name(IGUANA_ARGS,char *str,char *str2,bits256 hash,int32_t val,int32_t val2)
#define IGUANA_CFUNC_SSHHII(agent,name,str,str2,hash,hash2,val,val2) char *agent ## _ ## name(IGUANA_ARGS,char *str,char *str2,bits256 hash,bits256 hash2,int32_t val,int32_t val2)
#define IGUANA_CFUNC_SSS(agent,name,str,str2,str3) char *agent ## _ ## name(IGUANA_ARGS,char *str,char *str2,char *str3) #define IGUANA_CFUNC_SSS(agent,name,str,str2,str3) char *agent ## _ ## name(IGUANA_ARGS,char *str,char *str2,char *str3)
#define IGUANA_CFUNC_SI(agent,name,str,val) char *agent ## _ ## name(IGUANA_ARGS,char *str,int32_t val) #define IGUANA_CFUNC_SI(agent,name,str,val) char *agent ## _ ## name(IGUANA_ARGS,char *str,int32_t val)
#define IGUANA_CFUNC_SII(agent,name,str,val,val2) char *agent ## _ ## name(IGUANA_ARGS,char *str,int32_t val,int32_t val2) #define IGUANA_CFUNC_SII(agent,name,str,val,val2) char *agent ## _ ## name(IGUANA_ARGS,char *str,int32_t val,int32_t val2)
@ -66,6 +67,7 @@
#define TWOSTRINGS_AND_INT IGUANA_CFUNC_SSI #define TWOSTRINGS_AND_INT IGUANA_CFUNC_SSI
#define TWOSTRINGS_AND_HASH IGUANA_CFUNC_SSH #define TWOSTRINGS_AND_HASH IGUANA_CFUNC_SSH
#define TWOSTRINGS_AND_HASH_AND_TWOINTS IGUANA_CFUNC_SSHII #define TWOSTRINGS_AND_HASH_AND_TWOINTS IGUANA_CFUNC_SSHII
#define TWOSTRINGS_AND_TWOHASHES_AND_TWOINTS IGUANA_CFUNC_SSHHII
#define THREE_INTS IGUANA_CFUNC_III #define THREE_INTS IGUANA_CFUNC_III
#define HASH_ARRAY_STRING IGUANA_CFUNC_HAS #define HASH_ARRAY_STRING IGUANA_CFUNC_HAS
#define U64_AND_ARRAY IGUANA_CFUNC_64A #define U64_AND_ARRAY IGUANA_CFUNC_64A

2
includes/iguana_apiundefs.h

@ -31,7 +31,7 @@
#undef U64_AND_ARRAY #undef U64_AND_ARRAY
#undef HASH_ARG #undef HASH_ARG
#undef TWO_HASHES #undef TWO_HASHES
#undef TWOSTRINGS_AND_TWOHASHES_AND_TWOINTS
#undef IGUANA_ARGS #undef IGUANA_ARGS
#undef IGUANA_CALLARGS #undef IGUANA_CALLARGS

Loading…
Cancel
Save