[Gd-chatter] r11043 - in trunk/libraries: packetizer protocols
hannes at gwydiondylan.org
hannes at gwydiondylan.org
Sat Dec 9 15:58:38 CET 2006
Author: hannes
Date: Sat Dec 9 15:58:35 2006
New Revision: 11043
Modified:
trunk/libraries/packetizer/packetizer.dylan
trunk/libraries/packetizer/protocol-definer-macro.dylan
trunk/libraries/protocols/dhcp.dylan
trunk/libraries/protocols/dns.dylan
trunk/libraries/protocols/ethernet.dylan
trunk/libraries/protocols/ipv4.dylan
trunk/libraries/protocols/rip.dylan
trunk/libraries/protocols/tcp.dylan
Log:
Bug: 7299
*support for abstract container frames (field-size returns $unknown-at-compile-time)
*fix length of repeated fields
Modified: trunk/libraries/packetizer/packetizer.dylan
==============================================================================
--- trunk/libraries/packetizer/packetizer.dylan (original)
+++ trunk/libraries/packetizer/packetizer.dylan Sat Dec 9 15:58:35 2006
@@ -693,8 +693,9 @@
define method get-field-size-aux (frame :: <container-frame>, field :: <repeated-field>)
//XXX: refactor this whole crap
- if (field-size(field.type))
- field-size(field.type) * size(field.getter(frame))
+ let fs = field-size(field.type);
+ if (fs & fs ~= $unknown-at-compile-time)
+ fs * size(field.getter(frame))
else
reduce(\+, 0, map(frame-size, field.getter(frame)));
end;
Modified: trunk/libraries/packetizer/protocol-definer-macro.dylan
==============================================================================
--- trunk/libraries/packetizer/protocol-definer-macro.dylan (original)
+++ trunk/libraries/packetizer/protocol-definer-macro.dylan Sat Dec 9 15:58:35 2006
@@ -35,7 +35,7 @@
end;
define macro real-class-definer
- { real-class-definer(?:name; ?superclasses:*; ?fields-aux:*) }
+ { real-class-definer(?attrs:*; ?:name; ?superclasses:*; ?fields-aux:*) }
=> { define abstract class ?name (?superclasses)
end;
define inline method frame-name (frame :: subclass(?name)) => (res :: <string>)
@@ -90,7 +90,11 @@
end;
end;
define inline method field-size (frame :: subclass(?name)) => (res :: <number>)
- static-end(last("$" ## ?name ## "-fields"));
+ if (?#"attrs" = #"abstract")
+ $unknown-at-compile-time;
+ else
+ static-end(last("$" ## ?name ## "-fields"));
+ end;
end;
define method make (class == ?name, #rest rest, #key, #all-keys) => (res :: ?name)
let frame = apply(make, decoded-class(?name), rest);
@@ -472,15 +476,15 @@
end;
define macro protocol-definer
- { define protocol ?:name (?superprotocol:name)
+ { define ?attrs:* protocol ?:name (?superprotocol:name)
summary ?summary:* ;
?fields:*
end } =>
{ summary-generator("<" ## ?name ## ">"; ?summary);
- define protocol ?name (?superprotocol) ?fields end; }
+ define ?attrs protocol ?name (?superprotocol) ?fields end; }
- { define protocol ?:name (container-frame) end } =>
+ { define ?attrs:* protocol ?:name (container-frame) end } =>
{ //protocol-module-definer(?name; container-frame; );
define abstract class "<" ## ?name ## ">" (<container-frame>) end;
define abstract class "<decoded-" ## ?name ## ">"
@@ -488,32 +492,32 @@
end;
gen-classes(?name; container-frame); }
- { define protocol ?:name (?superprotocol:name)
+ { define ?attrs:* protocol ?:name (?superprotocol:name)
over ?super:name ?magic:expression;
?fields:*
end } =>
{
- define protocol ?name (?superprotocol) ?fields end;
+ define ?attrs protocol ?name (?superprotocol) ?fields end;
stack-protocol(?super, "<" ## ?name ## ">", ?magic);
}
- { define protocol ?:name (?superprotocol:name)
+ { define ?attrs:* protocol ?:name (?superprotocol:name)
length ?container-frame-length:expression;
?fields:*
end } =>
{
- define protocol ?name (?superprotocol) ?fields end;
+ define ?attrs protocol ?name (?superprotocol) ?fields end;
define inline method container-frame-size (?=frame :: "<" ## ?name ## ">") => (res :: <integer>)
?container-frame-length
end;
}
- { define protocol ?:name (?superprotocol:name)
+ { define ?attrs:* protocol ?:name (?superprotocol:name)
?fields:*
end } =>
{ //protocol-module-definer(?name; ?superprotocol; ?fields);
- real-class-definer("<" ## ?name ## ">"; "<" ## ?superprotocol ## ">"; ?fields);
+ real-class-definer(?attrs; "<" ## ?name ## ">"; "<" ## ?superprotocol ## ">"; ?fields);
decoded-class-definer("<decoded-" ## ?name ## ">";
"<" ## ?name ## ">", "<decoded-" ## ?superprotocol ## ">";
?fields);
Modified: trunk/libraries/protocols/dhcp.dylan
==============================================================================
--- trunk/libraries/protocols/dhcp.dylan (original)
+++ trunk/libraries/protocols/dhcp.dylan Sat Dec 9 15:58:35 2006
@@ -25,7 +25,7 @@
reached-end?: instance?(frame, <dhcp-end-option>);
end;
-define protocol dhcp-option (variably-typed-container-frame)
+define abstract protocol dhcp-option (variably-typed-container-frame)
layering field option-code :: <unsigned-byte>;
end;
@@ -38,7 +38,7 @@
over <dhcp-option> 255;
end;
-define protocol dhcp-option-with-data (dhcp-option)
+define abstract protocol dhcp-option-with-data (dhcp-option)
length (frame.option-length + 2) * 8;
field option-length :: <unsigned-byte>,
fixup: byte-offset(frame-size(frame)) - 2;
@@ -54,7 +54,7 @@
field time-offset :: <big-endian-unsigned-integer-4byte>;
end;
-define protocol dhcp-option-with-addresses (dhcp-option-with-data)
+define abstract protocol dhcp-option-with-addresses (dhcp-option-with-data)
repeated field addresses :: <ipv4-address>, reached-end?: #f;
end;
@@ -129,7 +129,7 @@
field extensions-pathname :: <externally-delimited-string>;
end;
-define protocol dhcp-boolean-option (dhcp-option-with-data)
+define abstract protocol dhcp-boolean-option (dhcp-option-with-data)
field option-enabled :: <unsigned-byte>
end;
define protocol dhcp-ip-forwarding-option (dhcp-boolean-option)
Modified: trunk/libraries/protocols/dns.dylan
==============================================================================
--- trunk/libraries/protocols/dns.dylan (original)
+++ trunk/libraries/protocols/dns.dylan Sat Dec 9 15:58:35 2006
@@ -54,7 +54,7 @@
make(<domain-name>, fragment: map(curry(as, <label>), labels));
end;
-define protocol domain-name-fragment (variably-typed-container-frame)
+define abstract protocol domain-name-fragment (variably-typed-container-frame)
layering field type-code :: <2bit-unsigned-integer> = 0;
end;
Modified: trunk/libraries/protocols/ethernet.dylan
==============================================================================
--- trunk/libraries/protocols/ethernet.dylan (original)
+++ trunk/libraries/protocols/ethernet.dylan Sat Dec 9 15:58:35 2006
@@ -87,7 +87,7 @@
field bridge-address :: <mac-address>;
end;
-define protocol stp-frame (variably-typed-container-frame)
+define abstract protocol stp-frame (variably-typed-container-frame)
field protocol-identifier :: <2byte-big-endian-unsigned-integer>;
field protocol-version :: <unsigned-byte>;
layering field bpdu-type :: <unsigned-byte>;
@@ -112,18 +112,18 @@
summary "STP topology change notification";
end;
-define protocol cdp-record (variably-typed-container-frame)
+define abstract protocol cdp-record (variably-typed-container-frame)
length frame.cdp-length * 8;
layering field cdp-type :: <2byte-big-endian-unsigned-integer>;
field cdp-length :: <2byte-big-endian-unsigned-integer>,
fixup: byte-offset(frame-size(frame));
end;
-define protocol cdp-unknown-record (cdp-record)
+define abstract protocol cdp-unknown-record (cdp-record)
field cdp-value :: <raw-frame>;
end;
-define protocol cdp-string-record (cdp-record)
+define abstract protocol cdp-string-record (cdp-record)
field cdp-value :: <externally-delimited-string>;
end;
Modified: trunk/libraries/protocols/ipv4.dylan
==============================================================================
--- trunk/libraries/protocols/ipv4.dylan (original)
+++ trunk/libraries/protocols/ipv4.dylan Sat Dec 9 15:58:35 2006
@@ -2,7 +2,7 @@
Author: Andreas Bogk, Hannes Mehnert
Copyright: (C) 2005, 2006, All rights reserved. Free for non-commercial use.
-define protocol ip-option-frame (variably-typed-container-frame)
+define abstract protocol ip-option-frame (variably-typed-container-frame)
field copy-flag :: <1bit-unsigned-integer>;
layering field option-type :: <7bit-unsigned-integer>;
end;
Modified: trunk/libraries/protocols/rip.dylan
==============================================================================
--- trunk/libraries/protocols/rip.dylan (original)
+++ trunk/libraries/protocols/rip.dylan Sat Dec 9 15:58:35 2006
@@ -2,7 +2,7 @@
Author: Andreas Bogk, Hannes Mehnert
Copyright: (C) 2005, 2006, All rights reserved. Free for non-commercial use.
-define protocol rip (variably-typed-container-frame)
+define abstract protocol rip (variably-typed-container-frame)
over <udp-frame> 520;
field command :: <unsigned-byte>;
layering field version :: <unsigned-byte>;
Modified: trunk/libraries/protocols/tcp.dylan
==============================================================================
--- trunk/libraries/protocols/tcp.dylan (original)
+++ trunk/libraries/protocols/tcp.dylan Sat Dec 9 15:58:35 2006
@@ -55,7 +55,7 @@
list("U", "A", "P", "R", "S", "F")))
end;
-define protocol tcp-option (variably-typed-container-frame)
+define abstract protocol tcp-option (variably-typed-container-frame)
layering field tcp-option-type :: <unsigned-byte>;
end;
@@ -67,7 +67,7 @@
over <tcp-option> 1
end;
-define protocol tcp-option-with-data (tcp-option)
+define abstract protocol tcp-option-with-data (tcp-option)
length frame.tcp-option-length * 8;
field tcp-option-length :: <unsigned-byte>,
fixup: byte-offset(frame-size(frame));
More information about the chatter
mailing list