X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Frmr%2Fsi%2Fsrc%2Fsi95%2Fsiestablish.c;h=794ea0772c53c87853f55bb28ec586ce8e40dfd0;hb=d324fe4bfea9daa22aa16c605bd3157a875a8ccd;hp=53c8db54341858fb49191cc3eca20247cc5ff63f;hpb=cc314e0c526a0ed0ce9295e490b3f2bb29c3332c;p=ric-plt%2Flib%2Frmr.git diff --git a/src/rmr/si/src/si95/siestablish.c b/src/rmr/si/src/si95/siestablish.c index 53c8db5..794ea07 100644 --- a/src/rmr/si/src/si95/siestablish.c +++ b/src/rmr/si/src/si95/siestablish.c @@ -57,43 +57,39 @@ Family is one of the AF_* constants (AF_ANY, AF_INET or AF_INET6) The address should be one of these forms: - [::1]:port // v6 localhost device (loop back) - localhost:port // v4 or 6 loopback depending on /etc/hosts - 0.0.0.0:port // any interface - addr:port // an address assigned to one of the devices + [::1]:port v6 localhost device (loop back) + localhost:port v4 or 6 loopback depending on /etc/hosts + 0.0.0.0:port any interface + addr:port an address assigned to one of the devices Returns a transport struct which is the main context for the listener. */ -extern struct tp_blk *SIlisten_prep( struct ginfo_blk *gptr, int type, char* abuf, int family ) { - struct tp_blk *tptr; // pointer at new tp block - int status = SI_OK; // processing status +extern struct tp_blk *SIlisten_prep( int type, char* abuf, int family ) { + struct tp_blk *tptr; // pointer at new tp block struct sockaddr *addr; // IP address we are requesting - int protocol; // protocol for socket call - char buf[256]; // buffer to build request address in int optval = 0; int alen = 0; + int status = SI_OK; // processing status + int protocol; // protocol for socket call - tptr = (struct tp_blk *) SInew( TP_BLK ); // new transport info block + tptr = (struct tp_blk *) SInew( TP_BLK ); // transport info - if( tptr != NULL ) - { + if( tptr != NULL ) { addr = NULL; - switch( type ) // things specifc to tcp or udp - { - case UDP_DEVICE: - tptr->type = SOCK_DGRAM; - protocol = IPPROTO_UDP; - break; - - case TCP_DEVICE: - default: - tptr->type = SOCK_STREAM; - protocol = IPPROTO_TCP; + if( type == UDP_DEVICE ) { + tptr->type = SOCK_DGRAM; + protocol = IPPROTO_UDP; + } else { + tptr->type = SOCK_STREAM; + protocol = IPPROTO_TCP; } alen = SIgenaddr( abuf, protocol, family, tptr->type, &addr ); // family == 0 for type that suits the address passed in if( alen <= 0 ) { + if( addr != NULL ) { + free( addr ); // not needed, but scanners complain if we don't overtly do this + } return NULL; } @@ -190,6 +186,9 @@ extern struct tp_blk *SIconn_prep( struct ginfo_blk *gptr, int type, char *abuf, alen = SIgenaddr( abuf, protocol, family, tptr->type, &addr ); // family == 0 for type that suits the address passed in if( alen <= 0 ) { + if( addr != NULL ) { // not needed, but scanners complain if we don't overtly do this + free( addr ); + } return NULL; }