The Ethernet ports are handled by a task which despatches
PBUF
s to and from other layers of the stack.
0 equ LoseTX? \ -- u
When this EQU
is set non-zero, every uth transmit
packet will be discarded. This equate is used when testing
the TCP retry mechanism and for simulating lossy links.
0 equ LoseRX? \ -- u
When this EQU
is set non-zero, every uth receive
packet will be discarded. This equate is used when testing
the TCP retry mechanism and for simulating lossy links.
: Send>Ether \ *pb *rt -- len
Send the data in the supplied PBuf (chain).
params |
*pb is a pbuf set to the IP layer |
returns |
#bytes sent if OK else SOCKET_ERROR |
: EtherIpPacket \ *pb --
Process a PBUF which holds a received Ethernet IP packet.
: RxEtherPacket \ *pbuf --
The PBUF holds a received Ethernet packet which is
processed.
: RxEtherPkt \ -- ; SFP001
Get waiting packet from the Ethernet driver layer.
0 value Linked? \ --
Returns true if PowerNet is linked to the world by an active
connection.
create LinkUpChain \ -- addr
Anchors the chain of words executed when the link is
established.
This chain must be defined at compile time.
create LinkDnChain \ -- addr
Anchors the chain of words executed when the link fails.
This chain must be defined at compile time.
: AtLinkUp \ xt --
Add the word whose xt is given to link up chain.
INTERPRETER
word.
: AtLinkDn \ xt --
Add the word whose xt is given to link up chain.
INTERPRETER
word.
useDHCP? [if] ' runDHCP AtLinkUp [then]
Start DHCP when the link comes up.
useSNTP? [if] ' runSNTP AtLinkUp [then]
Start SNTP when the link comes up.
: checkLink \ -- flag
Check PowerNet's connection and set Linked?
. Returns
true if PowerNet is linked to the world by an active
connection.
variable CheckTime \ -- addr
Holds the time at which the Ethernet link should next be checked.
: nextCheck \ --
Set the next link check time. This is normally every 200 ms.
: CheckEther \ --
The Ethernet link is checked every so often for an
established link. If the link fails, the Ethernet
task halts until the link is re-established. When it
is re-established a user-extensible chain of actions
takes place. This permits the system to restart actions
such as DHCP and SNTP.
: DoRunEther \ --
The task action that handles all general background Ethernet
processing.
task EtherTask \ -- addr
The Ethernet handler task.
: RunEtherTask \ --
Launch the Ethernet support task.
: (AskForEtherRoute) \ ip -- addr|0
See if we can get a route using ARP.
: AskForEtherRoute \ ip -- addr|0
See if we can get a route using ARP, but retrying several
times.