Permalink
Browse files

Use 8-tuples to represent IPv6 addresses

  • Loading branch information...
1 parent ddaaa48 commit b8ba58694038438518e05d1adb3f1e9eb0697e1d @msantos committed Mar 13, 2012
Showing with 10 additions and 6 deletions.
  1. +1 −0 include/pkt.hrl
  2. +9 −6 src/pkt.erl
View
@@ -68,6 +68,7 @@
-define(IPPROTO_TCP, 6).
-define(IPPROTO_UDP, 17).
-define(IPPROTO_SCTP, 132).
+-define(IPPROTO_RAW, 255).
-define(ICMP_ECHOREPLY, 0).
-define(ICMP_DEST_UNREACH, 3).
View
@@ -132,6 +132,7 @@ proto(?IPPROTO_ICMP) -> icmp;
proto(?IPPROTO_TCP) -> tcp;
proto(?IPPROTO_UDP) -> udp;
proto(?IPPROTO_SCTP) -> sctp;
+proto(?IPPROTO_RAW) -> raw;
proto(_) -> unsupported.
@@ -254,24 +255,26 @@ ipv4(#ipv4{
ipv6(
<<6:4, Class:8, Flow:20,
Len:16, Next:8, Hop:8,
- Src:128,
- Dst:128,
+ SA1:16, SA2:16, SA3:16, SA4:16, SA5:16, SA6:16, SA7:16, SA8:16,
+ DA1:16, DA2:16, DA3:16, DA4:16, DA5:16, DA6:16, DA7:16, DA8:16,
Payload/binary>>
) ->
{#ipv6{
class = Class, flow = Flow,
len = Len, next = Next, hop = Hop,
- saddr = Src, daddr = Dst
+ saddr = {SA1, SA2, SA3, SA4, SA5, SA6, SA7, SA8},
+ daddr = {DA1, DA2, DA3, DA4, DA5, DA6, DA7, DA8}
}, Payload};
ipv6(#ipv6{
class = Class, flow = Flow,
len = Len, next = Next, hop = Hop,
- saddr = Src, daddr = Dst
+ saddr = {SA1, SA2, SA3, SA4, SA5, SA6, SA7, SA8},
+ daddr = {DA1, DA2, DA3, DA4, DA5, DA6, DA7, DA8}
}) ->
<<6:4, Class:8, Flow:20,
Len:16, Next:8, Hop:8,
- Src:128,
- Dst:128>>.
+ SA1:16, SA2:16, SA3:16, SA4:16, SA5:16, SA6:16, SA7:16, SA8:16,
+ DA1:16, DA2:16, DA3:16, DA4:16, DA5:16, DA6:16, DA7:16, DA8:16>>.
%%

0 comments on commit b8ba586

Please sign in to comment.