X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2Fgscplftaaux%2Frts_options.c;fp=src%2Flib%2Fgscplftaaux%2Frts_options.c;h=44a0ed907687e0f38c43d70f3129c6cc8245b9b6;hb=c9783d8ea8b85d810483559e50dbf2297109e349;hp=0000000000000000000000000000000000000000;hpb=2f2369dfc58997659b3007b1cea68ad6bfc49a90;p=com%2Fgs-lite.git diff --git a/src/lib/gscplftaaux/rts_options.c b/src/lib/gscplftaaux/rts_options.c new file mode 100644 index 0000000..44a0ed9 --- /dev/null +++ b/src/lib/gscplftaaux/rts_options.c @@ -0,0 +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 */ +}