1 #ifndef _GPXE_INTERFACE_H
2 #define _GPXE_INTERFACE_H
6 * Transport-network layer interface
12 #include <gpxe/tables.h>
16 struct tcpip_protocol;
17 struct tcpip_net_protocol;
20 * A transport-layer protocol of the TCPIP stack (eg. UDP, TCP, etc)
22 struct tcpip_protocol {
26 * Process received packet
28 * @v pkb Packet buffer
29 * @v netdev Network device
30 * @v ll_source Link-layer source address
32 * This method takes ownership of the packet buffer.
34 void ( * rx ) ( struct pk_buff *pkb, struct in_addr *src_net_addr, struct in_addr *dest_net_addr );
36 * Transport-layer protocol number
38 * This is a constant of the type IP_XXX
44 * A negative number indicates that the protocol does not require
45 * checksumming to be performed by the network layer. A positive number is
46 * the offset of the checksum field in the transport-layer header.
52 * A TCPIP supporting network-layer protocol
54 struct tcpip_net_protocol {
55 /** Network protocol */
56 struct net_protocol *net_protocol;
57 /** Network address family */
58 sa_family_t sa_family;
59 /** Complete transport-layer checksum calculation
61 * @v pkb Packet buffer
62 * @v tcpip Transport-layer protocol
65 void ( * tx_csum ) ( struct pk_buff *pkb,
66 struct tcpip_protocol *tcpip );
70 * Register a transport-layer protocol
72 * @v protocol Transport-layer protocol
74 #define TCPIP_PROTOCOL( protocol ) \
75 struct tcpip_protocol protocol __table ( tcpip_protocols, 01 )
77 #define TCPIP_NET_PROTOCOL( protocol ) \
78 struct tcpip_net_protocol protocol __table ( tcpip_net_protocols, 01 )
80 extern void trans_rx ( struct pk_buff *pkb, uint8_t trans_proto,
81 struct in_addr *src, struct in_addr *dest );
83 extern int trans_tx ( struct pk_buff *pkb, struct tcpip_protocol *tcpip,
84 struct sockaddr *dest );
86 extern uint16_t calc_chksum ( void *data, size_t len );
88 extern struct tcpip_protocol * find_tcpip_protocol ( uint8_t trans_proto );
89 extern struct tcpip_net_protocol * find_tcpip_net_protocol ( sa_family_t sa_family );
91 #endif /* _GPXE_INTERFACE_H */