[Gd-chatter] r11618 - trunk/libraries/protocols
lobo at gwydiondylan.org
lobo at gwydiondylan.org
Sat Jan 12 23:14:18 CET 2008
Author: lobo
Date: Sat Jan 12 23:14:17 2008
New Revision: 11618
Added:
trunk/libraries/protocols/hsrp.dylan (contents, props changed)
trunk/libraries/protocols/ntp.dylan (contents, props changed)
Modified:
trunk/libraries/protocols/protocols-library.dylan
trunk/libraries/protocols/protocols.hdp
Log:
Bug: 7299
added protocol hsrp and ntp
Added: trunk/libraries/protocols/hsrp.dylan
==============================================================================
--- (empty file)
+++ trunk/libraries/protocols/hsrp.dylan Sat Jan 12 23:14:17 2008
@@ -0,0 +1,58 @@
+module: hsrp
+
+//Cisco Hot Standby Router Protocol (HSRP) RFC 2281
+define protocol hsrp (container-frame)
+ over <udp-frame> 1985;
+ field version :: <unsigned-byte> = 0;
+ /*
+ 0 Hello
+ 1 Coup
+ 2 Resign
+ */
+ field opcode :: <unsigned-byte> = 0;
+ /*
+ 0 Initial
+ 1 Learn
+ 2 Listen
+ 4 Speak
+ 8 Standby
+ 16 Active
+ */
+ field state :: <unsigned-byte> = 16;
+ field hello-time :: <unsigned-byte> = 3;
+ field hold-time :: <unsigned-byte> = 10;
+ field priority :: <unsigned-byte> = 120;
+ field group :: <unsigned-byte> = 1;
+ field reserved :: <unsigned-byte> = 0;
+ //recommended default value 0x63 0x69 0x73 0x63 0x6F 0x00 0x00 0x00
+ field authentication-data :: <raw-frame>, static-length: 8 * 8;
+ field virtual-ip :: <ipv4-address>;
+end;
+
+
+define method summary (frame :: <hsrp>) => (res :: <string>)
+ if(frame.opcode = 0)
+ if(frame.state = 0)
+ format-to-string("HSRP v%= Hello (Initial)", frame.version)
+ elseif(frame.state = 1)
+ format-to-string("HSRP v%= Hello (Learn)", frame.version)
+ elseif(frame.state = 2)
+ format-to-string("HSRP v%= Hello (Listen)", frame.version)
+ elseif(frame.state = 4)
+ format-to-string("HSRP v%= Hello (Speak)", frame.version)
+ elseif(frame.state = 8)
+ format-to-string("HSRP v%= Hello (Standby)", frame.version)
+ elseif(frame.state = 16)
+ format-to-string("HSRP v%= Hello (Active)", frame.version)
+ else
+ format-to-string("HSRP v%= Hello state: %=",
+ frame.version,
+ frame.state)
+ end
+ else
+ format-to-string("HSRP v%= opcode: %= state: %=",
+ frame.version,
+ frame.opcode,
+ frame.state)
+ end
+end;
Added: trunk/libraries/protocols/ntp.dylan
==============================================================================
--- (empty file)
+++ trunk/libraries/protocols/ntp.dylan Sat Jan 12 23:14:17 2008
@@ -0,0 +1,61 @@
+module: ntp
+
+// Simple Network Time Protocol (SNTP) RFC 1769
+define protocol ntp (container-frame)
+ over <udp-frame> 123;
+ field leap-indicator :: <2bit-unsigned-integer> = 0;
+ /*
+ 0 nowarning
+ 1 longminute, last minute has 61 seconds
+ 2 shortminute, last minute has 59 seconds
+ 3 notsync, alarm condition (clock not synchronized)
+ */
+ field version :: <3bit-unsigned-integer> = 3;
+ /*
+ 0 reserved
+ 1 symmetric active
+ 2 symmetric passive
+ 3 client
+ 4 server
+ 5 broadcast
+ 6 control
+ 7 private
+ */
+ field mode :: <3bit-unsigned-integer> = 3;
+ /*
+ 0 unspecified or unavailable
+ 1 primary reference (e.g., radio clock)
+ 2-15 secondary reference (via NTP or SNTP)
+ 16-255 reserved
+ */
+ field stratum :: <unsigned-byte> = 2;
+ field poll-interval :: <unsigned-byte> = 10;
+ field precision :: <unsigned-byte> = 0;
+ field root-delay :: <big-endian-unsigned-integer-4byte> = 0;
+ field root-dispersion :: <big-endian-unsigned-integer-4byte> = 0;
+ field reference-clock-id :: <ipv4-address>;
+ field reference-timestamp :: <unix-time-value>;
+ field originate-timestamp :: <unix-time-value>;
+ field receive-timestamp :: <unix-time-value>;
+ field transmit-timestamp :: <unix-time-value>;
+/* Authenticator (optional)
+ field key-id :: <big-endian-unsigned-integer-4byte>;
+ field message-authentication-code :: 16 bytes
+*/
+end;
+
+define method summary (frame :: <ntp>) => (res :: <string>)
+ if(frame.mode = 1)
+ format-to-string("NTP v%= Symmetric active", frame.version)
+ elseif(frame.mode = 2)
+ format-to-string("NTP v%= Symmetric passive", frame.version)
+ elseif(frame.mode = 3)
+ format-to-string("NTP v%= Client", frame.version)
+ elseif(frame.mode = 4)
+ format-to-string("NTP v%= Server", frame.version)
+ else
+ format-to-string("NTP v%= mode: %=",
+ frame.version,
+ frame.mode)
+ end
+end;
Modified: trunk/libraries/protocols/protocols-library.dylan
==============================================================================
--- trunk/libraries/protocols/protocols-library.dylan (original)
+++ trunk/libraries/protocols/protocols-library.dylan Sat Jan 12 23:14:17 2008
@@ -457,8 +457,19 @@
netmask-from-byte-vector;
end;
-define module eap
+define module hsrp
use dylan;
use packetizer;
- use ethernet, import: { <ethernet-frame> };
-end;
\ No newline at end of file
+ use format;
+
+ use ipv4, import: { <ipv4-address>, <udp-frame> };
+end;
+
+define module ntp
+ use dylan;
+ use packetizer;
+ use format;
+
+ use ipv4, import: { ipv4-address, <ipv4-address>, <udp-frame> };
+ use pcap, import: { <unix-time-value> };
+end;
Modified: trunk/libraries/protocols/protocols.hdp
==============================================================================
--- trunk/libraries/protocols/protocols.hdp (original)
+++ trunk/libraries/protocols/protocols.hdp Sat Jan 12 23:14:17 2008
@@ -12,4 +12,6 @@
prism2
pcap
rip
- cidr
\ No newline at end of file
+ cidr
+ hsrp
+ ntp
More information about the chatter
mailing list