X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Flib%2Fgscplftaaux%2Frts_options.c;h=0557662c17f1f3c5d841fd07548f464ca2861c74;hb=07495effe193ca3f73c3bf0ce417068f9ac9dcdd;hp=44a0ed907687e0f38c43d70f3129c6cc8245b9b6;hpb=93d248304a68de7a8f9daf4aa74f9ee4cd27410c;p=com%2Fgs-lite.git diff --git a/src/lib/gscplftaaux/rts_options.c b/src/lib/gscplftaaux/rts_options.c index 44a0ed9..0557662 100644 --- a/src/lib/gscplftaaux/rts_options.c +++ b/src/lib/gscplftaaux/rts_options.c @@ -1,58 +1,58 @@ -#include "md_stdlib.h" -#include "gsconfig.h" -#include "gstypes.h" -#include "rts_external.h" - -/* ------------------------------------------------ -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. - ------------------------------------------- */ - - -gs_retval_t has_ipv4_option( struct gs_string * s, gs_uint32_t ipoption) { - gs_int32_t x=0; - gs_int32_t on; - gs_int32_t len; - - if (s->length==0) return 0; /* no match */ - - while(0==0) { - if ((on=s->data[x]&0x1f)==ipoption) return 1; /* got a match */ - switch (on) { - case 0: - return 0; /* no match and end of list */ - case 1: - x++; /* one byte options */ - break; - case 2: /* 11 byte security option */ - x+=11; - break; - case 8: - x+=4; /* stream id option */ - break; - case 3: - case 9: - case 7: - case 4: - if (x+1>=s->length) return 0; /* run out of data no match */ - len=s->data[x+1]; - x+=len; - break; - default: - return 0; /* don't undestand the option */ - } - if (x>=s->length) return 0; /* run out of data no match */ - } - - return 0; /* should never be reached */ -} +#include "md_stdlib.h" +#include "gsconfig.h" +#include "gstypes.h" +#include "rts_external.h" + +/* ------------------------------------------------ +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. + ------------------------------------------- */ + + +gs_retval_t has_ipv4_option( struct gs_string * s, gs_uint32_t ipoption) { + gs_int32_t x=0; + gs_int32_t on; + gs_int32_t len; + + if (s->length==0) return 0; /* no match */ + + while(0==0) { + if ((on=s->data[x]&0x1f)==ipoption) return 1; /* got a match */ + switch (on) { + case 0: + return 0; /* no match and end of list */ + case 1: + x++; /* one byte options */ + break; + case 2: /* 11 byte security option */ + x+=11; + break; + case 8: + x+=4; /* stream id option */ + break; + case 3: + case 9: + case 7: + case 4: + if (x+1>=s->length) return 0; /* run out of data no match */ + len=s->data[x+1]; + x+=len; + break; + default: + return 0; /* don't undestand the option */ + } + if (x>=s->length) return 0; /* run out of data no match */ + } + + return 0; /* should never be reached */ +}