X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Frmr%2Fsi%2Fsrc%2Fsi95%2Fsiaddress.c;h=1d76f71e9c04ed26857c667c0713db7ba7929824;hb=fa454008020483ac35e1d20300cddfe877d8dd6d;hp=7cec5dd10fb05e2ea81927de88c6a81648cafea9;hpb=69d7bfd7bbe046dda3afa50e0362448d60301258;p=ric-plt%2Flib%2Frmr.git diff --git a/src/rmr/si/src/si95/siaddress.c b/src/rmr/si/src/si95/siaddress.c index 7cec5dd..1d76f71 100644 --- a/src/rmr/si/src/si95/siaddress.c +++ b/src/rmr/si/src/si95/siaddress.c @@ -44,7 +44,7 @@ * hostent structure. It claims that h_addr_list is a pointer * to character pointers, but it is really a pointer to a list * of pointers to integers!!! -* +* *************************************************************************** */ #include "sisetup.h" // get necessary defs and other stuff @@ -148,6 +148,10 @@ extern int SIaddress( void *src, void **dest, int type ) { int i; int rlen = 0; // return len - len of address struct or string + if( src == NULL || dest == NULL ) { + return rlen; + } + switch( type ) { case AC_TODOT: // convert from a struct to human readable "dotted decimal" addr = (struct sockaddr_in *) src; @@ -155,13 +159,13 @@ extern int SIaddress( void *src, void **dest, int type ) { if( addr->sin_family == AF_INET6 ) { addr6 = (struct sockaddr_in6 *) src; // really an ip6 struct byte = (uint8_t *) &addr6->sin6_addr; - snprintf( wbuf, sizeof( wbuf ), "[%u:%u:%u:%u:%u:%u]:%d", + snprintf( wbuf, sizeof( wbuf ), "[%u:%u:%u:%u:%u:%u]:%d", *(byte+0), *(byte+1), *(byte+2), *(byte+3), *(byte+4), *(byte+5) , (int) ntohs( addr6->sin6_port ) ); } else { num = (char *) &addr->sin_addr.s_addr; // point at the long - snprintf( wbuf, sizeof( wbuf ), "%u.%u.%u.%u;%d", *(num+0), *(num+1), *(num+2), *(num+3), (int) ntohs(addr->sin_port) ); + snprintf( wbuf, sizeof( wbuf ), "%u.%u.%u.%u:%d", *(num+0), *(num+1), *(num+2), *(num+3), (int) ntohs(addr->sin_port) ); } *dest = (void *) strdup( wbuf );