Signed-off-by: itoyuichi <[email protected]>
---
ryu/lib/packet/ipv6.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/ryu/lib/packet/ipv6.py b/ryu/lib/packet/ipv6.py
index 4045b05..dba859d 100644
--- a/ryu/lib/packet/ipv6.py
+++ b/ryu/lib/packet/ipv6.py
@@ -374,3 +374,62 @@ class fragment(header):
def __len__(self):
return self._MIN_LEN
+
+
[email protected]_header_type(inet.IPPROTO_AH)
+class auth(header):
+ """IP Authentication header (RFC 2402) encoder/decoder class.
+
+ This is used with ryu.lib.packet.ipv6.ipv6.
+
+ An instance has the following attributes at least.
+ Most of them are same to the on-wire counterparts but in host byte order.
+ __init__ takes the correspondig args in this order.
+
+ .. tabularcolumns:: |l|L|
+
+ ============== =======================================
+ Attribute Description
+ ============== =======================================
+ size the length of the Authentication Header
+ in 64-bit words, subtracting 1.
+ spi security parameters index.
+ seq sequence number.
+ data authentication data.
+ ============== =======================================
+ """
+ TYPE = inet.IPPROTO_AH
+
+ _PACK_STR = '!BB2xII'
+ _MIN_LEN = struct.calcsize(_PACK_STR)
+
+ def __init__(self, size, spi, seq, data):
+ super(auth, self).__init__()
+ self.size = size
+ self.spi = spi
+ self.seq = seq
+ self.data = data
+
+ @classmethod
+ def _get_size(cls, size):
+ return (int(size) - 1) * 8
+
+ @classmethod
+ def parser(cls, buf):
+ (nxt, size, spi, seq) = struct.unpack_from(cls._PACK_STR, buf)
+ form = "%ds" % (cls._get_size(size) - cls._MIN_LEN)
+ (data, ) = struct.unpack_from(form, buf, cls._MIN_LEN)
+ ret = cls(size, spi, seq, data)
+ ret.set_nxt(nxt)
+ return ret
+
+ def serialize(self):
+ buf = struct.pack(self._PACK_STR, self.nxt, self.size, self.spi,
+ self.seq)
+ buf = bytearray(buf)
+ form = "%ds" % (auth._get_size(self.size) - self._MIN_LEN)
+ buf.extend(struct.pack(form, self.data))
+ return buf
+
+ def __len__(self):
+ return auth._get_size(self.size)
--
1.7.10.4
------------------------------------------------------------------------------
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13.
http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel