Fixed newline characters throughout the code
[com/gs-lite.git] / src / lib / gscplftaaux / rts_options.c
1 #include "md_stdlib.h"
2 #include "gsconfig.h"
3 #include "gstypes.h"
4 #include "rts_external.h"
5
6 /* ------------------------------------------------
7 Copyright 2014 AT&T Intellectual Property
8    Licensed under the Apache License, Version 2.0 (the "License");
9    you may not use this file except in compliance with the License.
10    You may obtain a copy of the License at
11
12      http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19  ------------------------------------------- */
20
21
22 gs_retval_t has_ipv4_option( struct gs_string * s, gs_uint32_t ipoption) {
23     gs_int32_t x=0;
24     gs_int32_t on;
25     gs_int32_t len;
26
27     if (s->length==0) return 0; /* no match */
28
29     while(0==0) {
30         if ((on=s->data[x]&0x1f)==ipoption) return 1; /* got a match */
31         switch (on) {
32           case 0:
33             return 0; /* no match and end of list */
34           case 1:
35             x++; /* one byte options */
36             break;
37           case 2: /* 11 byte security option */
38             x+=11;
39             break;
40           case 8:
41             x+=4; /* stream id option */
42             break;
43           case 3:
44           case 9:
45           case 7:
46           case 4:
47             if (x+1>=s->length) return 0; /* run out of data no match */
48             len=s->data[x+1];
49             x+=len;
50             break;
51           default:
52             return 0; /* don't undestand the option */
53         }
54         if (x>=s->length) return 0; /* run out of data no match */
55     }
56                 
57     return 0; /* should never be reached */
58 }