X-Git-Url: http://www.project-moonshot.org/gitweb/?p=trust_router.git;a=blobdiff_plain;f=common%2Ftr_util.c;h=cb624609e73a2650bed7a1c0aba9d4c3715b2e0c;hp=527a74375697d94daccff984a2185cecd54f5b42;hb=7d902566f139ab6603c2b4a534c12f465526790d;hpb=b9776b2a5e8fa45749148e34c3f2df6ec4249ead diff --git a/common/tr_util.c b/common/tr_util.c index 527a743..cb62460 100644 --- a/common/tr_util.c +++ b/common/tr_util.c @@ -39,6 +39,7 @@ #include #include #include +#include void tr_bin_to_hex(const unsigned char * bin, size_t bin_len, char * hex_out, size_t hex_len) @@ -306,3 +307,22 @@ int tr_parse_hostname_and_port(const char *s, TR_NAME **hn_dest, int *p_dest) return 0; } +TR_NAME *tr_hostname_and_port_to_name(TR_NAME *hn, int port) +{ + TR_NAME *retval = NULL; + char *s = NULL; + char *hn_s = tr_name_strdup(hn); + + if (!hn_s) + return NULL; + + s = talloc_asprintf(NULL, "%s:%d", hn_s, port); + free(hn_s); + + if (s) { + retval = tr_new_name(s); + talloc_free(s); + } + + return retval; +}