summaryrefslogtreecommitdiffstats
path: root/scripts/external_libs/dpkt-1.8.6/dpkt/stun.py
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2015-09-20 17:34:55 +0300
committerHanoh Haim <hhaim@cisco.com>2015-09-20 17:34:55 +0300
commit3fe28431157f7b2ed2ed8184ed85017c42a4cb6c (patch)
tree41fa17684842885e1664cc63ff1520157f191261 /scripts/external_libs/dpkt-1.8.6/dpkt/stun.py
parent588bb20e9c8f8438db4eb3e8db85111f41bd7306 (diff)
parent28fef018f75b5a54ac69ac7c919127bf47f5b61f (diff)
Merge branch 'master' of csi-sceasr-b45:/auto/proj-pcube-b/apps/PL-b/tools/repo//trex-core into wen
Diffstat (limited to 'scripts/external_libs/dpkt-1.8.6/dpkt/stun.py')
-rw-r--r--scripts/external_libs/dpkt-1.8.6/dpkt/stun.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/scripts/external_libs/dpkt-1.8.6/dpkt/stun.py b/scripts/external_libs/dpkt-1.8.6/dpkt/stun.py
new file mode 100644
index 00000000..5706f0ef
--- /dev/null
+++ b/scripts/external_libs/dpkt-1.8.6/dpkt/stun.py
@@ -0,0 +1,45 @@
+# $Id: stun.py 47 2008-05-27 02:10:00Z jon.oberheide $
+
+"""Simple Traversal of UDP through NAT."""
+
+import struct
+import dpkt
+
+# STUN - RFC 3489
+# http://tools.ietf.org/html/rfc3489
+# Each packet has a 20 byte header followed by 0 or more attribute TLVs.
+
+# Message Types
+BINDING_REQUEST = 0x0001
+BINDING_RESPONSE = 0x0101
+BINDING_ERROR_RESPONSE = 0x0111
+SHARED_SECRET_REQUEST = 0x0002
+SHARED_SECRET_RESPONSE = 0x0102
+SHARED_SECRET_ERROR_RESPONSE = 0x0112
+
+# Message Attributes
+MAPPED_ADDRESS = 0x0001
+RESPONSE_ADDRESS = 0x0002
+CHANGE_REQUEST = 0x0003
+SOURCE_ADDRESS = 0x0004
+CHANGED_ADDRESS = 0x0005
+USERNAME = 0x0006
+PASSWORD = 0x0007
+MESSAGE_INTEGRITY = 0x0008
+ERROR_CODE = 0x0009
+UNKNOWN_ATTRIBUTES = 0x000a
+REFLECTED_FROM = 0x000b
+
+class STUN(dpkt.Packet):
+ __hdr__ = (
+ ('type', 'H', 0),
+ ('len', 'H', 0),
+ ('xid', '16s', 0)
+ )
+
+def tlv(buf):
+ n = 4
+ t, l = struct.unpack('>HH', buf[:n])
+ v = buf[n:n+l]
+ buf = buf[n+l:]
+ return (t,l,v, buf)