[Gd-chatter] r11676 - trunk/libraries/protocols
lobo at gwydiondylan.org
lobo at gwydiondylan.org
Sun Feb 17 01:28:19 CET 2008
Author: lobo
Date: Sun Feb 17 01:28:18 2008
New Revision: 11676
Added:
trunk/libraries/protocols/hdlc.dylan (contents, props changed)
Modified:
trunk/libraries/protocols/ethernet.dylan
trunk/libraries/protocols/ipv4.dylan
trunk/libraries/protocols/pcap.dylan
trunk/libraries/protocols/protocols-library.dylan
trunk/libraries/protocols/protocols.hdp
Log:
Bug: 7299
added protocol Cisco HDLC
added protocol SLARP
* only line-keepalive packets are supported atm.
Modified: trunk/libraries/protocols/ethernet.dylan
==============================================================================
--- trunk/libraries/protocols/ethernet.dylan (original)
+++ trunk/libraries/protocols/ethernet.dylan Sun Feb 17 01:28:18 2008
@@ -272,6 +272,7 @@
define protocol cdp-frame (container-frame)
over <ethernet-frame> #x2000;
+ over <cisco-hdlc-frame> #x2000;
summary "Cisco Discovery Protocol";
field version :: <unsigned-byte>;
field time-to-live :: <unsigned-byte>;
Added: trunk/libraries/protocols/hdlc.dylan
==============================================================================
--- (empty file)
+++ trunk/libraries/protocols/hdlc.dylan Sun Feb 17 01:28:18 2008
@@ -0,0 +1,49 @@
+module: hdlc
+
+// Cisco High-Level Data Link Control
+// http://www.nethelp.no/net/cisco-hdlc.txt
+define protocol cisco-hdlc-frame (header-frame)
+ summary "Cisco HDLC";
+ enum field address :: <unsigned-byte> = #x8f,
+ mappings: { #x0f <=> #"unicast",
+ #x8f <=> #"multicast" };
+ field control :: <unsigned-byte> = 0;
+ layering field protocol :: <2byte-big-endian-unsigned-integer> = #x800;
+ variably-typed-field payload,
+ type-function: payload-type(frame);
+end;
+
+// Serial Line Address Resolution Protocol
+define abstract protocol slarp (variably-typed-container-frame)
+ over <cisco-hdlc-frame> #x8035;
+ // layering field packet-type :: <big-endian-unsigned-integer-4byte> = 2;
+ field packet-type-first :: <unsigned-byte> = 0;
+ layering field packet-type :: <3byte-big-endian-unsigned-integer> = 2;
+end;
+
+define method summary (frame :: <slarp>) => (res :: <string>)
+ if(frame.packet-type = 0)
+ format-to-string("SLARP (request)")
+ elseif(frame.packet-type = 1)
+ format-to-string("SLARP (reply)")
+ elseif(frame.packet-type = 2)
+ format-to-string("SLARP (line keepalive)")
+ else
+ format-to-string("SLARP (packet-type: %=", frame.packet-type)
+ end;
+end;
+
+define protocol slarp-address-resolution (slarp)
+ over <slarp> 0;
+ over <slarp> 1;
+// field address :: <ipv4-address>;
+// field mask :: <ipv4-address>;
+// field unused :: <2byte-big-endian-unsigned-integer> = 0;
+end;
+
+define protocol slarp-line-keepalive (slarp)
+ over <slarp> 2;
+ field mysequence :: <big-endian-unsigned-integer-4byte>;
+ field yoursequence :: <big-endian-unsigned-integer-4byte>;
+ field reliability :: <2byte-big-endian-unsigned-integer> = #xffff;
+end;
Modified: trunk/libraries/protocols/ipv4.dylan
==============================================================================
--- trunk/libraries/protocols/ipv4.dylan (original)
+++ trunk/libraries/protocols/ipv4.dylan Sun Feb 17 01:28:18 2008
@@ -58,6 +58,7 @@
define protocol ipv4-frame (header-frame)
summary "IP SRC %= DST %=", source-address, destination-address;
over <ethernet-frame> #x800;
+ over <cisco-hdlc-frame> #x800;
over <link-control> #x800;
over <ppp> #x21;
field version :: <4bit-unsigned-integer> = 4;
Modified: trunk/libraries/protocols/pcap.dylan
==============================================================================
--- trunk/libraries/protocols/pcap.dylan (original)
+++ trunk/libraries/protocols/pcap.dylan Sun Feb 17 01:28:18 2008
@@ -4,10 +4,10 @@
// from pcap-bpf.h
define constant $DLT-EN10MB = 1;
+define constant $DLT-C-HDLC = 104;
define constant $DLT-PRISM-HEADER = 119;
define constant $DLT-80211-BSD-RADIO = 127;
-
define protocol pcap-file-header (container-frame)
field magic :: <little-endian-unsigned-integer-4byte>
= little-endian-unsigned-integer-4byte(#(#xd4, #xc3, #xb2, #xa1));
@@ -62,6 +62,7 @@
variably-typed-field payload,
type-function: select (frame.parent.header.linktype)
$DLT-EN10MB => <ethernet-frame>;
+ $DLT-C-HDLC => <cisco-hdlc-frame>;
$DLT-PRISM-HEADER => <prism2-frame>;
$DLT-80211-BSD-RADIO => <bsd-80211-radio-frame>;
otherwise => <raw-frame>;
Modified: trunk/libraries/protocols/protocols-library.dylan
==============================================================================
--- trunk/libraries/protocols/protocols-library.dylan (original)
+++ trunk/libraries/protocols/protocols-library.dylan Sun Feb 17 01:28:18 2008
@@ -21,7 +21,8 @@
ieee80211,
ppp,
pppoe,
- bittorrent;
+ bittorrent,
+ hdlc;
end;
define module logical-link
@@ -36,9 +37,19 @@
type-code, type-code-setter;
end;
+define module hdlc
+ use dylan;
+ use packetizer;
+ use format;
+ use format-out;
+
+ export <cisco-hdlc-frame>;
+end;
+
define module ethernet
use common-dylan;
use packetizer;
+ use hdlc, import: { <cisco-hdlc-frame> };
use common-extensions;
@@ -212,6 +223,7 @@
use ethernet, import: { <ethernet-frame> };
use prism2, import: { <prism2-frame>, <bsd-80211-radio-frame> };
+ use hdlc, import: { <cisco-hdlc-frame> };
export <pcap-file-header>,
magic, magic-setter,
@@ -246,6 +258,7 @@
use format;
use ethernet, export: { ipv4-address, <ipv4-address> };
+ use hdlc, import: { <cisco-hdlc-frame> };
use logical-link, import: { <link-control> };
use ppp, import: { <ppp> };
Modified: trunk/libraries/protocols/protocols.hdp
==============================================================================
--- trunk/libraries/protocols/protocols.hdp (original)
+++ trunk/libraries/protocols/protocols.hdp Sun Feb 17 01:28:18 2008
@@ -2,6 +2,7 @@
files: protocols-library
logical-link
ethernet
+ hdlc
ppp
pppoe
ipv4
More information about the chatter
mailing list