diff options
-rw-r--r-- | src/tcpopt.c | 3 | ||||
-rw-r--r-- | tests/py/any/tcpopt.t | 1 | ||||
-rw-r--r-- | tests/py/any/tcpopt.t.json | 17 | ||||
-rw-r--r-- | tests/py/any/tcpopt.t.payload | 5 |
4 files changed, 25 insertions, 1 deletions
diff --git a/src/tcpopt.c b/src/tcpopt.c index 05b5ee6e..53fe9bc8 100644 --- a/src/tcpopt.c +++ b/src/tcpopt.c @@ -200,7 +200,8 @@ void tcpopt_init_raw(struct expr *expr, uint8_t type, unsigned int off, else datatype_set(expr, &integer_type); - if (type >= array_size(tcpopt_protocols)) + if (type >= array_size(tcpopt_protocols) || + !tcpopt_protocols[type]) return; expr->exthdr.desc = tcpopt_protocols[type]; diff --git a/tests/py/any/tcpopt.t b/tests/py/any/tcpopt.t index f17a20b5..bcc64eac 100644 --- a/tests/py/any/tcpopt.t +++ b/tests/py/any/tcpopt.t @@ -31,6 +31,7 @@ tcp option timestamp length 1;ok tcp option timestamp tsval 1;ok tcp option timestamp tsecr 1;ok tcp option 255 missing;ok +tcp option 6 exists;ok tcp option @255,8,8 255;ok tcp option foobar;fail diff --git a/tests/py/any/tcpopt.t.json b/tests/py/any/tcpopt.t.json index 139e97d8..a45b4c8b 100644 --- a/tests/py/any/tcpopt.t.json +++ b/tests/py/any/tcpopt.t.json @@ -414,6 +414,23 @@ } ] +# tcp option 6 exists +[ + { + "match": { + "left": { + "tcp option": { + "base": 6, + "len": 8, + "offset": 0 + } + }, + "op": "==", + "right": true + } + } +] + # tcp option 255 missing [ { diff --git a/tests/py/any/tcpopt.t.payload b/tests/py/any/tcpopt.t.payload index 1005df32..51f3a752 100644 --- a/tests/py/any/tcpopt.t.payload +++ b/tests/py/any/tcpopt.t.payload @@ -133,6 +133,11 @@ inet [ exthdr load tcpopt 1b @ 255 + 0 present => reg 1 ] [ cmp eq reg 1 0x00000000 ] +# tcp option 6 exists +inet + [ exthdr load tcpopt 1b @ 6 + 0 present => reg 1 ] + [ cmp eq reg 1 0x00000001 ] + # tcp option @255,8,8 255 inet [ exthdr load tcpopt 1b @ 255 + 1 => reg 1 ] |