Revision 039c45ac
net_helper-ml.c | ||
---|---|---|
648 | 648 |
return remote; |
649 | 649 |
} |
650 | 650 |
|
651 |
const char *node_ip(const struct nodeID *s) { |
|
652 |
static char ip[64]; |
|
651 |
int node_ip(const struct nodeID *s, char *ip, int size) { |
|
653 | 652 |
int len; |
654 | 653 |
const char *start, *end; |
655 |
const char *tmp = node_addr(s); |
|
654 |
char tmp[256]; |
|
655 |
|
|
656 |
node_addr(s, tmp, 256); |
|
657 |
|
|
656 | 658 |
start = strstr(tmp, "-") + 1; |
657 | 659 |
end = strstr(start, ":"); |
658 | 660 |
len = end - start; |
661 |
if (len >= size) { |
|
662 |
return -1; |
|
663 |
} |
|
659 | 664 |
memcpy(ip, start, len); |
660 | 665 |
ip[len] = 0; |
661 | 666 |
|
662 |
return (const char *)ip;
|
|
667 |
return 1;
|
|
663 | 668 |
} |
664 | 669 |
|
665 | 670 |
// TODO: check why closing the connection is annoying for the ML |
... | ... | |
677 | 682 |
} |
678 | 683 |
|
679 | 684 |
|
680 |
const char *node_addr(const struct nodeID *s)
|
|
685 |
int node_addr(const struct nodeID *s, char *addr, int len)
|
|
681 | 686 |
{ |
682 |
static char addr[256]; |
|
683 | 687 |
// TODO: mlSocketIDToString always return 0 !!! |
684 |
int r = mlSocketIDToString(s->addr,addr,256);
|
|
688 |
int r = mlSocketIDToString(s->addr,addr,len);
|
|
685 | 689 |
if (!r) |
686 |
return addr;
|
|
690 |
return 1;
|
|
687 | 691 |
else |
688 |
return "";
|
|
692 |
return -1;
|
|
689 | 693 |
} |
690 | 694 |
|
691 | 695 |
struct nodeID *nodeid_dup(struct nodeID *s) |
Also available in: Unified diff