Skip to content

Commit

Permalink
Add tests for length xlat
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Jan 23, 2014
1 parent 6cbf622 commit 703ce3e
Showing 1 changed file with 155 additions and 0 deletions.
155 changes: 155 additions & 0 deletions src/tests/keywords/length
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
#
# PRE: hex
#
update reply {
Filter-Id := "filter"
}

update request {
Tmp-String-0 := '\
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'
Tmp-String-2 := '9870'
Tmp-Octets-0 := 0x39383731
Tmp-IP-Address-0 := 57.56.55.50
Tmp-Date-0 := 959985459
Tmp-Integer-0 := 959985460
Tmp-Cast-Abinary := 'ip out forward srcip 57.56.55.53/32 udp dstport = 1812'
Tmp-Cast-IfId := '0000:0000:3938:3737'
Tmp-Cast-IPv6Addr := '::3938:3738'
Tmp-Cast-IPv6Prefix := '::3938:3739/128'
Tmp-Cast-Byte := 58
Tmp-Cast-Short := 14139
Tmp-Cast-Ethernet := 00:00:39:38:37:3c
Tmp-Cast-Integer64 := 1152921505566832445
Tmp-Cast-IPv4Prefix := 57.56.55.62/32
}

update request {
Tmp-Integer-0 := "%{length:Tmp-String-0}"
}

if (Tmp-Integer-0 != 260) {
update reply {
Filter-Id += 'fail'
}
}

update request {
Tmp-Integer-0 := "%{length:Tmp-String-2}"
Tmp-Integer-1 := "%{length:Tmp-Octets-0}"
Tmp-Integer-2 := "%{length:Tmp-IP-Address-0}"
Tmp-Integer-3 := "%{length:Tmp-Date-0}"
Tmp-Integer-4 := "%{length:Tmp-Integer-0}"
Tmp-Integer-5 := "%{length:Tmp-Cast-Abinary}"
Tmp-Integer-6 := "%{length:Tmp-Cast-Ifid}"
Tmp-Integer-7 := "%{length:Tmp-Cast-IPv6Addr}"
Tmp-Integer-8 := "%{length:Tmp-Cast-IPv6Prefix}"
Tmp-Integer-9 := "%{length:Tmp-Cast-Byte}"
}

# String - bin 0x39383730
if (Tmp-Integer-0 != 4) {
update reply {
Filter-Id += 'fail'
}
}

# Octets - bin 0x39383731
if (Tmp-Integer-1 != 4) {
update reply {
Filter-Id += 'fail'
}
}

# IP Address - bin 0x39383732
if (Tmp-Integer-2 != 4) {
update reply {
Filter-Id += 'fail'
}
}

# Date - bin 0x39383733
if (Tmp-Integer-3 != 4) {
update reply {
Filter-Id += 'fail'
}
}

# Integer - bin 0x39383734
if (Tmp-Integer-4 != 4) {
update reply {
Filter-Id += 'fail'
}
}

# Abinary - bin 0x0101000039383735000000002000110000000714000200000000000000000000
if (Tmp-Integer-5 != 32) {
update reply {
Filter-Id += 'fail'
}
}

# ifid - bin 0x0000000039383737
if (Tmp-Integer-6 != 8) {
update reply {
Filter-Id += 'fail'
}
}

# ipv6addr - bin 0x00000000000000000000000039383738
if (Tmp-Integer-7 != 16) {
update reply {
Filter-ID += 'fail'
}
}

# ipv6addrprefix - bin 0x008000000000000000000000000039383739
if (Tmp-Integer-8 != 18) {
update reply {
Filter-ID += 'fail'
}
}

# byte - bin 0x3a
if (Tmp-Integer-9 != 1) {
update reply {
Filter-ID += 'fail'
}
}

update request {
Tmp-Integer-0 := "%{length:Tmp-Cast-Short}"
Tmp-Integer-1 := "%{length:Tmp-Cast-Ethernet}"
Tmp-Integer-2 := "%{length:Tmp-Cast-Integer64}"
Tmp-Integer-3 := "%{length:Tmp-Cast-IPv4Prefix}"
}

# short - bin 0x373b
if (Tmp-Integer-0 != 2) {
update reply {
Filter-ID += 'fail'
}
}

# ethernet - bin 0x00003938373c
if (Tmp-Integer-1 != 6) {
update reply {
Filter-Id += 'fail'
}
}

# integer64 - bin 0x100000003938373d
if (Tmp-Integer-2 != 8) {
update reply {
Filter-Id += 'fail'
}
}

# ipv4prefix - bin 0x00203938373e
if (Tmp-Integer-3 != 6) {
update reply {
Filter-Id += 'fail'
}
}

0 comments on commit 703ce3e

Please sign in to comment.