X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Flib%2Fgscphost%2Flappregistries.c;h=0ef78bd321ca0bc6c14e852f40bf7d8132c42c17;hb=e981e864b812c938d3df8b555b6bb98bb89273e7;hp=f81b1082b69c5d6f3a3f77b62a321af40514aa06;hpb=44ea17511358ebc75952066580e31cba8b38ddb8;p=com%2Fgs-lite.git diff --git a/src/lib/gscphost/lappregistries.c b/src/lib/gscphost/lappregistries.c index f81b108..0ef78bd 100644 --- a/src/lib/gscphost/lappregistries.c +++ b/src/lib/gscphost/lappregistries.c @@ -1,159 +1,159 @@ -/* ------------------------------------------------ - Copyright 2014 AT&T Intellectual Property - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ------------------------------------------- */ - -#include -#include -#include - -/* datastructure to keep track of streamids used by the lapp */ -struct streamregistry { - gs_int32_t used; - FTAID ftaid; - struct ringbuf * r; -}; - -struct streamregistry * sreg =0; -gs_int32_t lsreg=0; - -struct ringbuf ** rbr=0; -gs_int32_t lrbr=0; - -FTAID ** rms=0; -gs_int32_t lrms=0; - -/* adds the remote streamid with its associated msgid and ringbuf - */ -gs_retval_t streamregistry_add(FTAID ftaid,struct ringbuf * r) -{ - gs_int32_t x; - if (lsreg == 0) { - if ((sreg = malloc(sizeof(struct streamregistry)*STARTSZ))==0) { - gslog(LOG_EMERG,"ERROR:Out of memory streanregistry\n"); - return -1; - } - memset(sreg,0,sizeof(struct streamregistry)*STARTSZ); - lsreg = STARTSZ; - } - for(x=0;(x=lrbr) { - rbr[y]=sreg[x].r; - lrbr++; - } - } - } - return 0; -} - -struct ringbuf * streamregistry_getactiveringbuf() -{ - if (lrbr>0) { - lrbr --; - return rbr[lrbr]; - } - return 0; -} - - -gs_retval_t streamregistry_getactiveftaid_reset() -{ - gs_int32_t x,y; - /* XXXOS this is not the most effective way of doing - this needs improvment. */ - /* Build a list of at least one ftaid per process - */ - if (rms!=0) (free(rms)); - if ((rms=malloc(sizeof(FTAID *)*lsreg))==0) { - gslog(LOG_EMERG,"Can't allocate memory in ftaregistry\n"); - return -1; - } - memset(rms,0,sizeof(gs_int32_t *)*lsreg); - lrms=0; - for(x=0;xip!=sreg[x].ftaid.ip) - &&(rms[y]->port!=sreg[x].ftaid.port);y++); - if (y>=lrms) { - rms[y]=&(sreg[x].ftaid); - lrms++; - } - } - } - return 0; -} - -FTAID * streamregistry_getactiveftaid() -{ - if (lrms>0) { - lrms --; - return rms[lrms]; - } - return 0; -} +/* ------------------------------------------------ + Copyright 2014 AT&T Intellectual Property + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ------------------------------------------- */ + +#include +#include +#include + +/* datastructure to keep track of streamids used by the lapp */ +struct streamregistry { + gs_int32_t used; + FTAID ftaid; + struct ringbuf * r; +}; + +struct streamregistry * sreg =0; +gs_int32_t lsreg=0; + +struct ringbuf ** rbr=0; +gs_int32_t lrbr=0; + +FTAID ** rms=0; +gs_int32_t lrms=0; + +/* adds the remote streamid with its associated msgid and ringbuf + */ +gs_retval_t streamregistry_add(FTAID ftaid,struct ringbuf * r) +{ + gs_int32_t x; + if (lsreg == 0) { + if ((sreg = malloc(sizeof(struct streamregistry)*STARTSZ))==0) { + gslog(LOG_EMERG,"ERROR:Out of memory streanregistry\n"); + return -1; + } + memset(sreg,0,sizeof(struct streamregistry)*STARTSZ); + lsreg = STARTSZ; + } + for(x=0;(x=lrbr) { + rbr[y]=sreg[x].r; + lrbr++; + } + } + } + return 0; +} + +struct ringbuf * streamregistry_getactiveringbuf() +{ + if (lrbr>0) { + lrbr --; + return rbr[lrbr]; + } + return 0; +} + + +gs_retval_t streamregistry_getactiveftaid_reset() +{ + gs_int32_t x,y; + /* XXXOS this is not the most effective way of doing + this needs improvment. */ + /* Build a list of at least one ftaid per process + */ + if (rms!=0) (free(rms)); + if ((rms=malloc(sizeof(FTAID *)*lsreg))==0) { + gslog(LOG_EMERG,"Can't allocate memory in ftaregistry\n"); + return -1; + } + memset(rms,0,sizeof(gs_int32_t *)*lsreg); + lrms=0; + for(x=0;xip!=sreg[x].ftaid.ip) + &&(rms[y]->port!=sreg[x].ftaid.port);y++); + if (y>=lrms) { + rms[y]=&(sreg[x].ftaid); + lrms++; + } + } + } + return 0; +} + +FTAID * streamregistry_getactiveftaid() +{ + if (lrms>0) { + lrms --; + return rms[lrms]; + } + return 0; +}