[openfirmware] r1615 - ofw/inet
svn at openfirmware.info
svn at openfirmware.info
Tue Dec 15 23:33:08 CET 2009
Author: wmb
Date: 2009-12-15 23:33:07 +0100 (Tue, 15 Dec 2009)
New Revision: 1615
Modified:
ofw/inet/ippkg.fth
ofw/inet/netload.fth
ofw/inet/tcp.fth
Log:
TCP - changed local port number assignment to use the IANA recommended
range. Also added a local port number assignment method for UDP.
Modified: ofw/inet/ippkg.fth
===================================================================
--- ofw/inet/ippkg.fth 2009-12-15 22:28:30 UTC (rev 1614)
+++ ofw/inet/ippkg.fth 2009-12-15 22:33:07 UTC (rev 1615)
@@ -62,6 +62,7 @@
call-tftp: oc-checksum ( n adr len -- n' )
call-tftp: link-mtu ( -- n )
call-tftp: max-ip-payload ( -- n )
+call-tftp: alloc-udp-port ( -- port# )
finish-device
device-end
Modified: ofw/inet/netload.fth
===================================================================
--- ofw/inet/netload.fth 2009-12-15 22:28:30 UTC (rev 1614)
+++ ofw/inet/netload.fth 2009-12-15 22:33:07 UTC (rev 1615)
@@ -374,7 +374,24 @@
use-nfs? if nfs-read else tftpread then
;
+h# c123 value next-udp-local-port
+true value first-time?
+: ?init-udp-local-port ( -- )
+ first-time? if
+[ifdef] random-long
+ random-long h# 3fff and h# c000 + to next-udp-local-port
+[then]
+ false to first-time?
+ then
+;
+
headers
+: alloc-udp-port ( -- port )
+ next-udp-local-port 1+ ( port )
+ \ Stay within the IANA-recommended dynamic port range
+ dup h# 10000 = if drop h# c000 then ( port' )
+ dup to next-udp-local-port ( port )
+;
: next-xid ( -- id ) rpc-xid 1+ dup to rpc-xid ;
: allocate-packet ( len -- adr ) allocate-udp ;
: free-packet ( len -- adr ) free-udp ;
@@ -477,6 +494,7 @@
configure
s-all
my-self to obp-tftp-ih \ Publish so IP redirector can attach to us
+ ?init-udp-local-port
true
;
Modified: ofw/inet/tcp.fth
===================================================================
--- ofw/inet/tcp.fth 2009-12-15 22:28:30 UTC (rev 1614)
+++ ofw/inet/tcp.fth 2009-12-15 22:33:07 UTC (rev 1615)
@@ -231,12 +231,13 @@
then
;
-h# 555 value next-tcp-local-port
+h# c999 value next-tcp-local-port
-: alloc-next-tcp-local-port ( -- port )
- next-tcp-local-port 1+ ( port )
- h# ffff and h# 555 max ( port )
- dup to next-tcp-local-port ( port )
+: alloc-tcp-port ( -- port )
+ next-tcp-local-port 1+ ( port )
+ \ Stay within the IANA-recommended dynamic port range
+ dup h# 10000 = if drop h# c000 then ( port' )
+ dup to next-tcp-local-port ( port )
;
\ send sequence variables
@@ -2342,7 +2343,7 @@
first-time? if
false to first-time?
[ifdef] random-long
- random-long h# f000 mod h# 555 + to next-tcp-local-port
+ random-long h# 3fff and h# c000 + to next-tcp-local-port
[then]
" next-xid" $call-parent to tcp_iss
@@ -2355,7 +2356,7 @@
['] protocol-tick d# 500 alarm
- alloc-next-tcp-local-port to my-tcp-port
+ alloc-tcp-port to my-tcp-port
true to alive?
true
More information about the openfirmware
mailing list