X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fcommon%2Fsrc%2Fmbuf_api.c;h=4b6d218026ec48d183e9a2cd93ce06c337e9c320;hb=c1aee2b63a523a461e96a8d358c73dd8a9e9e6a2;hp=ef0c28f90c079faebb63bbbb2858f025e7f14154;hpb=d710957ed5d73bf2da2ceea3f5a1a3c509275c30;p=ric-plt%2Flib%2Frmr.git diff --git a/src/common/src/mbuf_api.c b/src/common/src/mbuf_api.c index ef0c28f..4b6d218 100644 --- a/src/common/src/mbuf_api.c +++ b/src/common/src/mbuf_api.c @@ -316,3 +316,28 @@ extern int rmr_get_trlen( rmr_mbuf_t* msg ) { return RMR_TR_LEN( hdr ); } + +/* + Returns the string in the source portion of the header. This is assumed to be + something that can be used for direct sends (hostname:port). Regardless, it + will be a nil terminated, ascii string with max of 64 characters including + the final nil. So, the user must ensure that dest is at least 64 bytes. + + As a convenience, the pointer to dest is returned on success; nil on failure + with errno set. +*/ +extern unsigned char* rmr_get_src( rmr_mbuf_t* msg, unsigned char* dest ) { + uta_mhdr_t* hdr = NULL; + + if( msg == NULL ) { + errno = EINVAL; + return NULL; + } + + if( dest != NULL ) { + hdr = msg->header; + strcpy( dest, hdr->src ); + } + + return dest; +}