Skip to content

Commit

Permalink
Add tests for hex xlat
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Jan 22, 2014
1 parent 7fbe429 commit 4a63c0e
Show file tree
Hide file tree
Showing 2 changed files with 146 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/tests/keywords/base64
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# PRE: update
# PRE: hex
#
update reply {
Filter-Id := "filter"
Expand All @@ -18,7 +18,7 @@ update request {
Tmp-Cast-Byte := 58
Tmp-Cast-Short := 14139
Tmp-Cast-Ethernet := 00:00:39:38:37:3c
Tmp-Cast-Integer64 := 1152921505566832400
Tmp-Cast-Integer64 := 1152921505566832445
Tmp-Cast-IPv4Prefix := 57.56.55.62/32
}

Expand Down Expand Up @@ -70,7 +70,7 @@ if (Tmp-String-4 != 'OTg3NA==') {
}
}

# Abinary - bin 0x0101000039383735000000000800110000000714000200000000000000000000
# Abinary - bin 0x0101000039383735000000002000110000000714000200000000000000000000
if (Tmp-String-5 != 'AQEAADk4NzUAAAAAIAARAAAABxQAAgAAAAAAAAAAAAA=') {
update reply {
Filter-Id += 'fail'
Expand All @@ -91,7 +91,7 @@ if (Tmp-String-7 != 'AAAAAAAAAAAAAAAAOTg3OA==') {
}
}

# ipv6addrprefix - bin 0x00800000000000000000000039383739
# ipv6addrprefix - bin 0x008000000000000000000000000039383739
if (Tmp-String-8 != 'AIAAAAAAAAAAAAAAAAA5ODc5') {
update reply {
Filter-ID += 'fail'
Expand Down Expand Up @@ -127,7 +127,7 @@ if (Tmp-String-1 != 'AAA5ODc8') {
}

# integer64 - bin 0x100000003938373d
if (Tmp-String-2 != 'EAAAADk4NxA=') {
if (Tmp-String-2 != 'EAAAADk4Nz0=') {
update reply {
Filter-Id += 'fail'
}
Expand Down
141 changes: 141 additions & 0 deletions src/tests/keywords/hex
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#
# PRE: update
#
update reply {
Filter-Id := "filter"
}

update request {
Tmp-String-0 := '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-String-0 := "%{hex:Tmp-String-0}"
Tmp-String-1 := "%{hex:Tmp-Octets-0}"
Tmp-String-2 := "%{hex:Tmp-IP-Address-0}"
Tmp-String-3 := "%{hex:Tmp-Date-0}"
Tmp-String-4 := "%{hex:Tmp-Integer-0}"
Tmp-String-5 := "%{hex:Tmp-Cast-Abinary}"
Tmp-String-6 := "%{hex:Tmp-Cast-Ifid}"
Tmp-String-7 := "%{hex:Tmp-Cast-IPv6Addr}"
Tmp-String-8 := "%{hex:Tmp-Cast-IPv6Prefix}"
Tmp-String-9 := "%{hex:Tmp-Cast-Byte}"
}

# String
if (Tmp-String-0 != '39383730') {
update reply {
Filter-Id += 'fail'
}
}

# Octets
if (Tmp-String-1 != '39383731') {
update reply {
Filter-Id += 'fail'
}
}

# IP Address
if (Tmp-String-2 != '39383732') {
update reply {
Filter-Id += 'fail'
}
}

# Date
if (Tmp-String-3 != '39383733') {
update reply {
Filter-Id += 'fail'
}
}

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

# Abinary
if (Tmp-String-5 != '0101000039383735000000002000110000000714000200000000000000000000') {
update reply {
Filter-Id += 'fail'
}
}

# ifid
if (Tmp-String-6 != '0000000039383737') {
update reply {
Filter-Id += 'fail'
}
}

# ipv6addr
if (Tmp-String-7 != '00000000000000000000000039383738') {
update reply {
Filter-ID += 'fail'
}
}

# ipv6addrprefix
if (Tmp-String-8 != '008000000000000000000000000039383739') {
update reply {
Filter-ID += 'fail'
}
}

# byte
if (Tmp-String-9 != '3a') {
update reply {
Filter-ID += 'fail'
}
}

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

# short
if (Tmp-String-0 != '373b') {
update reply {
Filter-ID += 'fail'
}
}

# ethernet
if (Tmp-String-1 != '00003938373c') {
update reply {
Filter-Id += 'fail'
}
}

# integer64
if (Tmp-String-2 != '100000003938373d') {
update reply {
Filter-Id += 'fail'
}
}

# ipv4prefix
if (Tmp-String-3 != '00203938373e') {
update reply {
Filter-Id += 'fail'
}
}

0 comments on commit 4a63c0e

Please sign in to comment.