diff options
| author | Anton <anton@picapica> | 2016-12-26 18:41:55 +0400 |
|---|---|---|
| committer | Anton <anton@picapica> | 2016-12-26 18:41:55 +0400 |
| commit | a4762905029bd8710ced13fcee80763bafba6ff3 (patch) | |
| tree | 4918b361b9dd5552385e063b260f5fea8c81b5e2 | |
| parent | a991eb82decec01d25ac39805ee60e4fea196ef7 (diff) | |
| download | pica-pica-a4762905029bd8710ced13fcee80763bafba6ff3.tar.gz pica-pica-a4762905029bd8710ced13fcee80763bafba6ff3.zip | |
implemented find_matching_c2c()
| -rw-r--r-- | PICA_client.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/PICA_client.c b/PICA_client.c index fe82195..709e817 100644 --- a/PICA_client.c +++ b/PICA_client.c @@ -1989,7 +1989,27 @@ static int process_c2c(struct PICA_c2c *c2c, fd_set *rfds, fd_set *wfds) static struct PICA_c2c * find_matching_c2c(struct PICA_c2n *c2n, struct PICA_directc2c *d) { - -- + struct PICA_c2c *c2c; + unsigned char idbuf[PICA_ID_SIZE]; + + if (!PICA_id_from_X509(d->peer_cert, idbuf)) + return NULL; + + c2c = c2n->chan_list_head; + + while(c2c) + { + if (c2c->directc2c_state == PICA_DIRECTC2C_STATE_WAITINGINCOMING) + { + if (memcmp(idbuf, c2c->peer_id, PICA_ID_SIZE) == 0) + { + return c2c; + } + } + c2c = c2c->next; + } + + return NULL; } static void process_directc2c(struct PICA_c2n *c2n) @@ -1997,8 +2017,8 @@ static void process_directc2c(struct PICA_c2n *c2n) //process accepted connections if (c2n->directc2c_listener) { - PICA_directc2c *d; - PICA_c2c *c2c; + struct PICA_directc2c *d; + struct PICA_c2c *c2c; d = c2n->directc2c_listener->accepted_connections; |
