Skip to content

Commit

Permalink
Merge d4e821e into 3ce39d2
Browse files Browse the repository at this point in the history
  • Loading branch information
prorealize committed Apr 8, 2022
2 parents 3ce39d2 + d4e821e commit 0d3978c
Show file tree
Hide file tree
Showing 35 changed files with 325 additions and 96 deletions.
2 changes: 1 addition & 1 deletion dpkt/ah.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class AH(dpkt.Packet):
"""Authentication Header.
TODO: Longer class information....
The Authentication Header (AH) protocol provides data origin authentication, data integrity, and replay protection.
Attributes:
__hdr__: Header fields of AH.
Expand Down
4 changes: 3 additions & 1 deletion dpkt/bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ class BGP(dpkt.Packet):
Attributes:
__hdr__: Header fields of BGP.
#TODO
marker: (bytes): Marker. Included for compatibility, must be set to all ones. (16 bytes)
len: (int): Length: Total length of the message in octets, including the header. (2 bytes)
type: (int): Type: Type of BGP message. (1 byte)
"""

__hdr__ = (
Expand Down
18 changes: 16 additions & 2 deletions dpkt/cdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,19 @@
class CDP(dpkt.Packet):
"""Cisco Discovery Protocol.
Cisco Discovery Protocol (CDP) is a proprietary Data Link Layer protocol developed by Cisco Systems in 1994
by Keith McCloghrie and Dino Farinacci. It is used to share information about other directly connected
Cisco equipment, such as the operating system version and IP address.
See more on
https://en.wikipedia.org/wiki/Cisco_Discovery_Protocol
Attributes:
__hdr__: Header fields of CDP.
#TODO
version: (int): CDP protocol version. (1 byte)
ttl: (int): Time to live. The amount of time in seconds that a receiver should retain the information
contained in this packet. (1 byte)
sum: (int): Checksum. (2 bytes)
"""

__hdr__ = (
Expand All @@ -42,8 +49,15 @@ class CDP(dpkt.Packet):
)

class TLV(dpkt.Packet):
"""When constructing the packet, len is not mandatory:
"""Type–length–value
When constructing the packet, len is not mandatory:
if not provided, then self.data must be this exact TLV payload
Attributes:
__hdr__: Header fields of TLV.
type: (int): Type (2 bytes)
len: (int): The total length in bytes of the Type, Length and Data fields. (2 bytes)
"""

__hdr__ = (
Expand Down
34 changes: 32 additions & 2 deletions dpkt/dhcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,41 @@
class DHCP(dpkt.Packet):
"""Dynamic Host Configuration Protocol.
TODO: Longer class information....
The Dynamic Host Configuration Protocol (DHCP) is a network management protocol used on Internet Protocol (IP)
networks for automatically assigning IP addresses and other communication parameters to devices connected
to the network using a client–server architecture.
Attributes:
__hdr__: Header fields of DHCP.
TODO.
op: (int): Operation. Message op code / message type. 1 = BOOTREQUEST, 2 = BOOTREPLY. (1 byte)
hrd: (int): Hardware type. Hardware address type, see ARP section in "Assigned
Numbers" RFC; e.g., '1' = 10mb ethernet. (1 byte)
hln: (int): Hardware Length. Hardware address length (e.g. '6' for 10mb
ethernet). (1 byte)
hops: (int): Hops. Client sets to zero, optionally used by relay agents
when booting via a relay agent. (1 byte)
xid: (int): Transaction ID. A random number chosen by the
client, used by the client and server to associate
messages and responses between a client and a
server. (4 bytes)
secs: (int): Seconds. Filled in by client, seconds elapsed since client
began address acquisition or renewal process. (2 bytes)
flags: (int): DHCP Flags. (2 bytes)
ciaddr: (int): Client IP address. Only filled in if client is in
BOUND, RENEW or REBINDING state and can respond
to ARP requests. (4 bytes)
yiaddr: (int): User IP address. (4 bytes)
siaddr: (int): Server IP address. IP address of next server to use in bootstrap;
returned in DHCPOFFER, DHCPACK by server. (4 bytes)
giaddr: (int): Gateway IP address. Relay agent IP address, used in booting via a
relay agent. (4 bytes)
chaddr: (int): Client hardware address. (16 bytes)
sname: (int): Server Hostname. Optional, null terminated string. (64 bytes)
file: (int): Boot file name. Null terminated string; "generic"
name or null in DHCPDISCOVER, fully qualified
directory-path name in DHCPOFFER. (128 bytes)
magic: (int): Magic cookie. Optional parameters field. See the options
documents for a list of defined options. (4 bytes)
"""

__hdr__ = (
Expand Down
16 changes: 14 additions & 2 deletions dpkt/diameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,23 @@
class Diameter(dpkt.Packet):
"""Diameter.
TODO: Longer class information....
Diameter is an authentication, authorization, and accounting protocol for computer networks. It evolved from the
earlier RADIUS protocol. It belongs to the application layer protocols in the internet protocol suite.
Attributes:
__hdr__: Header fields of Diameter.
TODO.
v: (int) Version. The version of the Diameter Base Protocol.
As of 2014, the only value supported is 1. (1 byte)
len: (bytes): Message Length. The Message Length field indicates the length of the Diameter message in
bytes, including the header fields and the padded AVPs. (3 bytes)
flags: (int): Command flags. (Request, Proxiable, Error, Potentially re-transmitted message) (1 byte)
cmd: (bytes): Commands. Determine the action that is to be taken for a particular message. (3 bytes)
app_id: (int): Application-ID. Application-ID is used to identify for which Diameter application the
message is applicable. (4 bytes)
hop_id: (int): Hop-by-Hop Identifier. Used to match the requests with their answers as the same value in
the request is used in the response. (4 bytes)
end_id: (int): End-to-End Identifier. used to detect duplicate messages along with the combination of the
Origin-Host AVP. (4 bytes)
"""

__hdr__ = (
Expand Down
23 changes: 20 additions & 3 deletions dpkt/dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,18 @@ def unpack_name(buf, off):
class DNS(dpkt.Packet):
"""Domain Name System.
TODO: Longer class information....
The Domain Name System (DNS) is the hierarchical and decentralized naming system used to identify computers,
services, and other resources reachable through the Internet or other Internet Protocol (IP) networks.
The resource records contained in the DNS associate domain names with other forms of information.
Attributes:
__hdr__: Header fields of DNS.
TODO.
__hdr__ (tuple(header_name, c_type, offset)): Header fields of DNS.
id: (int): Identification. Used to match request/reply packets.
op: (int): Operation
qd: (int): Query Definition
an: (int): Answer
ns: (int): Name Server
ar: (int): Additional Record
"""

__hdr__ = (
Expand All @@ -144,6 +151,7 @@ class DNS(dpkt.Packet):

@property
def qr(self):
"""DNS Query/Response. 1 bit"""
return int((self.op & DNS_QR) == DNS_QR)

@qr.setter
Expand All @@ -155,6 +163,7 @@ def qr(self, v):

@property
def opcode(self):
"""Operation code. 4 bits."""
return (self.op >> 11) & 0xf

@opcode.setter
Expand All @@ -163,6 +172,8 @@ def opcode(self, v):

@property
def aa(self):
"""Authoritative Answer. 1 bit.
Specifies that the responding name server is an authority for the domain name in question section."""
return int((self.op & DNS_AA) == DNS_AA)

@aa.setter
Expand All @@ -174,6 +185,7 @@ def aa(self, v):

@property
def tc(self):
"""Truncated. 1 bit. Indicates that only the first 512 bytes of the reply was returned."""
return int((self.op & DNS_TC) == DNS_TC)

@tc.setter
Expand All @@ -185,6 +197,8 @@ def tc(self, v):

@property
def rd(self):
"""Recursion Desired. 1 bit. May be set in a query and is copied into the response.
If set, the name server is directed to pursue the query recursively. Recursive query support is optional."""
return int((self.op & DNS_RD) == DNS_RD)

@rd.setter
Expand All @@ -196,6 +210,7 @@ def rd(self, v):

@property
def ra(self):
"""Recursion Available. 1 bit. Indicates if recursive query support is available in the name server."""
return int((self.op & DNS_RA) == DNS_RA)

@ra.setter
Expand All @@ -207,6 +222,7 @@ def ra(self, v):

@property
def zero(self):
"""Zero 1 bit"""
return int((self.op & DNS_Z) == DNS_Z)

@zero.setter
Expand All @@ -218,6 +234,7 @@ def zero(self, v):

@property
def rcode(self):
"""Return code. 4 bits."""
return self.op & 0xf

@rcode.setter
Expand Down
5 changes: 4 additions & 1 deletion dpkt/dpkt.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# $Id: dpkt.py 43 2007-08-02 22:42:59Z jon.oberheide $
# -*- coding: utf-8 -*-
"""Simple packet creation and parsing."""
"""Simple packet creation and parsing.
The dpkt project is a python module for fast, simple packet parsing, with definitions for the basic TCP/IP protocols.
"""
from __future__ import absolute_import, print_function

import copy
Expand Down
7 changes: 5 additions & 2 deletions dpkt/dtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
class DTP(dpkt.Packet):
"""Dynamic Trunking Protocol.
TODO: Longer class information....
The Dynamic Trunking Protocol (DTP) is a proprietary networking protocol developed by Cisco Systems for the purpose
of negotiating trunking on a link between two VLAN-aware switches, and for negotiating the type of trunking
encapsulation to be used. It works on Layer 2 of the OSI model. VLAN trunks formed using DTP may utilize either
IEEE 802.1Q or Cisco ISL trunking protocols.
Attributes:
__hdr__: Header fields of DTP.
TODO.
v: (int) Version. (1 byte)
"""

__hdr__ = (
Expand Down
8 changes: 6 additions & 2 deletions dpkt/esp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
class ESP(dpkt.Packet):
"""Encapsulated Security Protocol.
TODO: Longer class information....
Encapsulating Security Payload (ESP) is a member of the Internet Protocol Security (IPsec) set of protocols that
encrypt and authenticate the packets of data between computers using a Virtual Private Network (VPN). The focus
and layer on which ESP operates makes it possible for VPNs to function securely.
Attributes:
__hdr__: Header fields of ESP.
TODO.
spi: (int): Security Parameters Index. An arbitrary value that, in combination with the destination
IP address and security protocol (ESP), uniquely identifies the SA for this datagram. (4 bytes)
spi: (int): Sequence number. This field contains a monotonically increasing counter value. (4 bytes)
"""

__hdr__ = (
Expand Down
4 changes: 3 additions & 1 deletion dpkt/ethernet.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ class Ethernet(dpkt.Packet):
Attributes:
__hdr__: Header fields of Ethernet.
TODO.
dst: (bytes): Destination MAC address
src: (bytes): Source MAC address
type: (int): Ethernet frame type (Ethernet II, Novell raw IEEE 802.3, IEEE 802.2 LLC, IEEE 802.2 SNAP)
"""

__hdr__ = (
Expand Down
10 changes: 8 additions & 2 deletions dpkt/gre.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@
class GRE(dpkt.Packet):
"""Generic Routing Encapsulation.
TODO: Longer class information....
Generic Routing Encapsulation, or GRE, is a protocol for encapsulating data packets that use one routing protocol
inside the packets of another protocol. "Encapsulating" means wrapping one data packet within another data packet,
like putting a box inside another box. GRE is one way to set up a direct point-to-point connection across a network,
for the purpose of simplifying connections between separate networks. It works with a variety of network layer
protocols.
Attributes:
__hdr__: Header fields of GRE.
TODO.
flags: (int): Flag bits. (2 bytes)
p: (int): Protocol Type (2 bytes)
"""

__hdr__ = (
Expand All @@ -49,6 +54,7 @@ def v(self, v):

@property
def recur(self):
"""Recursion control bits. (3 bits)"""
return (self.flags >> 5) & 0x7

@recur.setter
Expand Down
7 changes: 5 additions & 2 deletions dpkt/h225.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,14 @@
class H225(dpkt.Packet):
"""ITU-T H.225.0 Call Signaling.
TODO: Longer class information....
H.225.0 is a key protocol in the H.323 VoIP architecture defined by ITU-T. H.225.0 describes how audio, video,
data and control information on a packet based network can be managed to provide conversational services in H.323
equipment. H.225.0 has two major parts: Call signaling and RAS (Registration, Admission and Status).
Attributes:
__hdr__: Header fields of H225.
TODO.
proto: (int): Protocol Discriminator. The Protocol Discriminator identifies the Layer 3 protocol. (1 byte)
ref_len: (int): Call Reference Value. Contains the length of the Call Reference Value (CRV) field. (1 byte)
"""

__hdr__ = (
Expand Down
17 changes: 15 additions & 2 deletions dpkt/hsrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,24 @@
class HSRP(dpkt.Packet):
"""Cisco Hot Standby Router Protocol.
TODO: Longer class information....
It is a Cisco proprietary redundancy protocol for establishing a fault-tolerant default gateway. Version 1 of the
protocol was described in RFC 2281 in 1998. Version 2 of the protocol includes improvements and supports IPv6 but
there is no corresponding RFC published for this version.
Attributes:
__hdr__: Header fields of HSRP.
TODO.
version: (int): Version. HSRP version number. (1 byte)
opcode: (int): Operation code. (Hello - 0, Coup - 1, Resign - 2) (1 byte)
state: (int): State. This field describes the current state of the router sending the message. (1 byte)
hello: (int): Hellotime. This field is only meaningful in Hello messages. It contains the approximate period
between the Hello messages that the router sends. The time is given in seconds.(1 byte)
hold: (int): Holdtime. This field is only meaningful in Hello messages. It contains the amount of time that
the current Hello message should be considered valid. The time is given in seconds. (1 byte)
priority: (int): Priority. This field is used to elect the active and standby routers. (1 byte)
group: (int): Group. This field identifies the standby group. (1 byte)
rsvd: (int): Reserved. (1 byte)
auth: (bytes): Authentication Data. This field contains a clear text 8 character reused password. (8 bytes)
vip: (bytes): Virtual IP Address. The virtual IP address used by this group. (4 bytes)
"""

__hdr__ = (
Expand Down

0 comments on commit 0d3978c

Please sign in to comment.