tcpip.h
Go to the documentation of this file.00001 #ifndef _GPXE_TCPIP_H
00002 #define _GPXE_TCPIP_H
00003
00004
00005
00006
00007
00008
00009
00010 FILE_LICENCE ( GPL2_OR_LATER );
00011
00012 #include <stdint.h>
00013 #include <gpxe/socket.h>
00014 #include <gpxe/in.h>
00015 #include <gpxe/tables.h>
00016
00017 struct io_buffer;
00018 struct net_device;
00019
00020
00021
00022
00023
00024 #define TCPIP_EMPTY_CSUM 0xffff
00025
00026
00027
00028
00029
00030
00031
00032 struct sockaddr_tcpip {
00033
00034 sa_family_t st_family;
00035
00036 uint16_t st_port;
00037
00038
00039
00040
00041
00042
00043 char pad[ sizeof ( struct sockaddr ) -
00044 ( sizeof ( sa_family_t ) + sizeof ( uint16_t ) ) ];
00045 } __attribute__ (( may_alias ));
00046
00047
00048
00049
00050 struct tcpip_protocol {
00051
00052 const char *name;
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 int ( * rx ) ( struct io_buffer *iobuf, struct sockaddr_tcpip *st_src,
00065 struct sockaddr_tcpip *st_dest, uint16_t pshdr_csum );
00066
00067
00068
00069
00070
00071 uint8_t tcpip_proto;
00072 };
00073
00074
00075
00076
00077 struct tcpip_net_protocol {
00078
00079 const char *name;
00080
00081 sa_family_t sa_family;
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 int ( * tx ) ( struct io_buffer *iobuf,
00096 struct tcpip_protocol *tcpip_protocol,
00097 struct sockaddr_tcpip *st_src,
00098 struct sockaddr_tcpip *st_dest,
00099 struct net_device *netdev,
00100 uint16_t *trans_csum );
00101 };
00102
00103
00104 #define TCPIP_PROTOCOLS __table ( struct tcpip_protocol, "tcpip_protocols" )
00105
00106
00107 #define __tcpip_protocol __table_entry ( TCPIP_PROTOCOLS, 01 )
00108
00109
00110 #define TCPIP_NET_PROTOCOLS \
00111 __table ( struct tcpip_net_protocol, "tcpip_net_protocols" )
00112
00113
00114 #define __tcpip_net_protocol __table_entry ( TCPIP_NET_PROTOCOLS, 01 )
00115
00116 extern int tcpip_rx ( struct io_buffer *iobuf, uint8_t tcpip_proto,
00117 struct sockaddr_tcpip *st_src,
00118 struct sockaddr_tcpip *st_dest, uint16_t pshdr_csum );
00119 extern int tcpip_tx ( struct io_buffer *iobuf, struct tcpip_protocol *tcpip,
00120 struct sockaddr_tcpip *st_src,
00121 struct sockaddr_tcpip *st_dest,
00122 struct net_device *netdev,
00123 uint16_t *trans_csum );
00124 extern uint16_t tcpip_continue_chksum ( uint16_t partial,
00125 const void *data, size_t len );
00126 extern uint16_t tcpip_chksum ( const void *data, size_t len );
00127
00128 #endif