diff options
| author | me_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac> | 2012-09-29 15:09:20 +0000 |
|---|---|---|
| committer | me_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac> | 2012-09-29 15:09:20 +0000 |
| commit | 29a367041df5c041c066a2b1220b9667536ecc91 (patch) | |
| tree | 0bb931f453e02dfe4142ee9df77eec9fccd5fc05 | |
| parent | b2883e24e7ad2b0853ebbc5b6e611695f9a5f2d5 (diff) | |
| download | pica-pica-29a367041df5c041c066a2b1220b9667536ecc91.tar.gz pica-pica-29a367041df5c041c066a2b1220b9667536ecc91.zip | |
sending PINGREP from client, bugfix in sending PINGREQ from node
git-svn-id: svn://localhost/project_picapica/trunk@210 fb96df88-216d-11de-830c-f3023f12d8ac
| -rwxr-xr-x | PICA_client.c | 20 | ||||
| -rwxr-xr-x | PICA_node.c | 11 |
2 files changed, 28 insertions, 3 deletions
diff --git a/PICA_client.c b/PICA_client.c index 2675ae7..5456ae5 100755 --- a/PICA_client.c +++ b/PICA_client.c @@ -36,6 +36,7 @@ static unsigned int procmsg_FOUND(unsigned char*,unsigned int,void*); static unsigned int procmsg_CLNODELIST(unsigned char*,unsigned int,void*); static unsigned int procmsg_MSGUTF8(unsigned char*,unsigned int,void*); static unsigned int procmsg_MSGOK(unsigned char*,unsigned int,void*); +static unsigned int procmsg_PINGREQ(unsigned char*,unsigned int,void*); static struct PICA_proto_msg* c2n_writebuf_push(struct PICA_conninfo *ci, unsigned int msgid, unsigned int size); static struct PICA_proto_msg* c2c_writebuf_push(struct PICA_chaninfo *chn, unsigned int msgid, unsigned int size); @@ -45,7 +46,8 @@ const struct PICA_msginfo c2n_messages[] = { {PICA_PROTO_CONNREQINC, PICA_MSG_FIXED_SIZE, PICA_PROTO_CONNREQINC_SIZE, procmsg_CONNREQINC}, {PICA_PROTO_NOTFOUND, PICA_MSG_FIXED_SIZE, PICA_PROTO_NOTFOUND_SIZE, procmsg_NOTFOUND}, {PICA_PROTO_FOUND, PICA_MSG_FIXED_SIZE, PICA_PROTO_FOUND_SIZE, procmsg_FOUND}, - {PICA_PROTO_CLNODELIST, PICA_MSG_VAR_SIZE, PICA_MSG_VARSIZE_INT16, procmsg_CLNODELIST} + {PICA_PROTO_CLNODELIST, PICA_MSG_VAR_SIZE, PICA_MSG_VARSIZE_INT16, procmsg_CLNODELIST}, + {PICA_PROTO_PINGREQ, PICA_MSG_FIXED_SIZE, PICA_PROTO_PINGREQ_SIZE, procmsg_PINGREQ} };//---!!! PING!!! const struct PICA_msginfo c2c_messages[] = { @@ -543,6 +545,22 @@ callbacks.msgok_cb(chan -> peer_id); return 1; } +unsigned int procmsg_PINGREQ(unsigned char* buf,unsigned int nb,void* p) +{ +struct PICA_conninfo *ci=(struct PICA_conninfo *)p; +struct PICA_proto_msg *mp; + +mp = c2n_writebuf_push(ci, PICA_PROTO_PINGREP, PICA_PROTO_PINGREP_SIZE); + +if (mp) + { + RAND_bytes(mp->tail, 2); + } +else + return 0; + +return 1; +} #ifdef PICA_MULTITHREADED diff --git a/PICA_node.c b/PICA_node.c index 0ff6894..6084fbd 100755 --- a/PICA_node.c +++ b/PICA_node.c @@ -487,7 +487,7 @@ unsigned int procmsg_PINGREP_client(unsigned char* buf,unsigned int size,void* p { struct client *c = (struct client*)ptr; -PICA_debug3("PINGREP"); +PICA_debug3("PINGREP c2n"); c->disconnect_ticking = 0; c->tmst = time(0); @@ -516,7 +516,7 @@ unsigned int procmsg_PINGREP_node(unsigned char* buf,unsigned int size,void* ptr { struct nodelink *n=(struct nodelink *)ptr; -PICA_debug3("PINGREP"); +PICA_debug3("PINGREP n2n"); n->disconnect_ticking = 0; n->tmst = time(0); @@ -1521,6 +1521,7 @@ if (!ci->r_buf) } ci->buflen_r = DEFAULT_BUF_SIZE; +ci->tmst = time(0); return ci; } @@ -1643,6 +1644,8 @@ if (!nl->r_buf) } nl->buflen_r=DEFAULT_BUF_SIZE; +nl->tmst = time(0); + nodelink_list_count++; return nl; } @@ -1845,7 +1848,11 @@ while(i_ptr) if ((mp = client_wbuf_push(i_ptr, PICA_PROTO_PINGREQ, PICA_PROTO_PINGREQ_SIZE))) { + PICA_debug3("sending PINGREQ to %p", i_ptr); RAND_bytes(mp->tail, 2); + + i_ptr->tmst = time(0); + i_ptr->disconnect_ticking = 1; } else kill_ptr = i_ptr; |
