Skip to content

Commit

Permalink
Merge pull request #39 from shun159/fix/mpls_tests
Browse files Browse the repository at this point in the history
pkt_mpls: Fix test cases
  • Loading branch information
msantos committed Jul 25, 2016
2 parents f11829c + 27b5b76 commit 6ae07de
Showing 1 changed file with 18 additions and 63 deletions.
81 changes: 18 additions & 63 deletions test/pkt_mpls_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,72 +9,27 @@ codec_test_() ->

decode_single_tagging() ->
Frame = pkt:decapsulate(single()),
[#ether{dhost = <<194,5,99,77,0,0>>,
shost = <<194,3,99,62,0,0>>,
type = 34887,crc = 0},
#mpls{labels = [#shim{label = 18,
tc = 0,
s = true,
ttl = 254}]},
#ipv4{v = 4,
hl = 5,
tos = 0,
len = 100,
id = 25,
df = 0,mf = 0,
off = 0,
ttl = 254,
p = 1,
sum = 2349,
saddr = {192,168,10,1},
daddr = {192,168,40,1},
opt = <<>>},
#icmp{type = 8,
code = 0,checksum = 28057,id = 5,
sequence = 0,
gateway = {127,0,0,1},
un = <<0,0,0,0>>,
mtu = 0,
pointer = 0,
ts_orig = 0,
ts_recv = 0,
ts_tx = 0},
_] = Frame.
Expect = [{ether,<<194,5,99,77,0,0>>,<<194,3,99,62,0,0>>,34887,0},
{mpls,[{shim,18,0,true,254}]},
{ipv4,4,5,0,100,25,0,0,0,254,1,2349,{192,168,10,1},{192,168,40,1},<<>>},
{icmp,8,0,28057,5,0,{127,0,0,1},<<0,0,0,0>>,0,0,0,0,0},
<<0,0,0,0,0,36,16,136,171,205,171,205,171,205,171,205,171,205,171,205,171,
205,171,205,171,205,171,205,171,205,171,205,171,205,171,205,171,205,171,
205,171,205,171,205,171,205,171,205,171,205,171,205,171,205,171,205,171,
205,171,205,171,205,171,205,171,205,171,205,171,205,171,205>>],
?_assertEqual(Frame, Expect).

decode_double_tagging() ->
Frame = pkt:decapsulate(double()),
[#ether{dhost = <<0,48,150,230,252,57>>,
shost = <<0,48,150,5,40,56>>,
type = 34887,crc = 0},
#mpls{labels = [#shim{label = 18,tc = 0,s = false,ttl = 255},
#shim{label = 16,tc = 0,s = true,ttl = 255}]},
#ipv4{v = 4,
hl = 5,
tos = 0,
len = 100,
id = 80,
df = 0,
mf = 0,
off = 0,
ttl = 255,
p = 1,
sum = 42758,
saddr = {10,31,0,1},
daddr = {10,34,0,1},
opt = <<>>},
#icmp{type = 8,
code = 0,
checksum = 48401,
id = 3941,
sequence = 4768,
gateway = {127,0,0,1},
un = <<0,0,0,0>>,
mtu = 0,
pointer = 0,
ts_orig = 0,
ts_recv = 0,
ts_tx = 0},
_] = Frame.
Expect = [{ether,<<0,48,150,230,252,57>>,<<0,48,150,5,40,56>>,34887,0},
{mpls,[{shim,18,0,false,255},{shim,16,0,true,255}]},
{ipv4,4,5,0,100,80,0,0,0,255,1,42758,{10,31,0,1},{10,34,0,1},<<>>},
{icmp,8,0,48401,3941,4768,{127,0,0,1},<<0,0,0,0>>,0,0,0,0,0},
<<0,0,0,0,0,83,158,224,171,205,171,205,171,205,171,205,171,205,171,205,171,
205,171,205,171,205,171,205,171,205,171,205,171,205,171,205,171,205,171,
205,171,205,171,205,171,205,171,205,171,205,171,205,171,205,171,205,171,
205,171,205,171,205,171,205,171,205,171,205,171,205,171,205>>],
?_assertEqual(Frame, Expect).

single() ->
<<16#c2, 16#05, 16#63, 16#4d, 16#00, 16#00, 16#c2, 16#03,
Expand Down

0 comments on commit 6ae07de

Please sign in to comment.