diff options
| author | me_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac> | 2013-09-19 18:08:52 +0000 |
|---|---|---|
| committer | me_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac> | 2013-09-19 18:08:52 +0000 |
| commit | 57d45923fc62be7d11ac20abba8618ca4b90bea4 (patch) | |
| tree | d9f5b7e8a8887d60caff5593e74eb237bada30ce /PICA_node.c | |
| parent | 698e81f37ccaddf40abbb31c0415f95bafa48b43 (diff) | |
| download | pica-pica-57d45923fc62be7d11ac20abba8618ca4b90bea4.tar.gz pica-pica-57d45923fc62be7d11ac20abba8618ca4b90bea4.zip | |
fixes for enabling build of pica-node on Windows using MinGW
git-svn-id: svn://localhost/project_picapica/trunk@275 fb96df88-216d-11de-830c-f3023f12d8ac
Diffstat (limited to 'PICA_node.c')
| -rwxr-xr-x | PICA_node.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/PICA_node.c b/PICA_node.c index 21f622e..b3cba2c 100755 --- a/PICA_node.c +++ b/PICA_node.c @@ -20,6 +20,12 @@ #include "PICA_rand_seed.h" #endif +#ifdef WIN32 +typedef u_long in_addr_t; +typedef u_short in_port_t; +typedef u_short uint16_t; +#endif + #define MAX_NEWCONNS 64 #define NEWCONN_TIMEOUT 10 //sec @@ -579,7 +585,7 @@ mp = nodelink_wbuf_push(n, PICA_PROTO_NEWNODE_IPV4, PICA_PROTO_NEWNODE_IPV4_SIZE if (mp) { *((in_addr_t*)(mp->tail))=inet_addr(nodecfg.announced_addr); - *((uint16_t*)(mp->tail+4))=(nodecfg.listen_port ? htons(atoi(nodecfg.listen_port)) : htons(PICA_COMM_PORT));//CONF; + *((in_port_t*)(mp->tail+4))=(nodecfg.listen_port ? htons(atoi(nodecfg.listen_port)) : htons(PICA_COMM_PORT));//CONF; } else return 0; @@ -619,7 +625,7 @@ PICA_debug1("received NEWNODE"); switch (buf[0]) { case PICA_PROTO_NEWNODE_IPV4: - PICA_debug1("NEWNODE_IPV4: ip %.16s port %hu\n",inet_ntoa(*(struct in_addr*)(buf+2)),ntohs(*(uint16_t*)(buf+6))); + PICA_debug1("NEWNODE_IPV4: ip %.16s port %hu\n",inet_ntoa(*(struct in_addr*)(buf+2)),ntohs(*(in_port_t*)(buf+6))); { struct PICA_nodeaddr_ipv4 na_ipv4; @@ -684,7 +690,7 @@ if (!nl_buf) //собственный адрес узла nl_buf[nl_size]=PICA_PROTO_NEWNODE_IPV4; *((in_addr_t*)(nl_buf+nl_size+1))=inet_addr(my_addr); -*((uint16_t*)(nl_buf+nl_size+5))=(nodecfg.listen_port ? htons(atoi(nodecfg.listen_port)) : htons(PICA_COMM_PORT));//CONF +*((in_port_t*)(nl_buf+nl_size+5))=(nodecfg.listen_port ? htons(atoi(nodecfg.listen_port)) : htons(PICA_COMM_PORT));//CONF nl_size+=PICA_PROTO_NODELIST_ITEM_IPV4_SIZE; } @@ -701,7 +707,7 @@ while(nlp && nl_size < 65532)//MAP nl_buf[nl_size]=PICA_PROTO_NEWNODE_IPV4; *((in_addr_t*)(nl_buf+nl_size+1)) = ((struct PICA_nodeaddr_ipv4*)nlp->node_addr)->addr; - *((uint16_t*)(nl_buf+nl_size+5)) = ((struct PICA_nodeaddr_ipv4*)nlp->node_addr)->port; + *((in_port_t*)(nl_buf+nl_size+5)) = ((struct PICA_nodeaddr_ipv4*)nlp->node_addr)->port; nl_size += PICA_PROTO_NODELIST_ITEM_IPV4_SIZE;//CONF break; } |
