The TCP code uses Ethernet constants for protocol numbers and 48 bits for address. Also, 0xFF:FF:FF:FF:FF:FF is assumed to be a broadcast. Except for ARCNET where broadcast is 0x00.
If you need to write a new driver, implement it at this level and use the above mentioned constants as this program's constants, not device dependent constants.
The packet driver or WinPcap interface code lies below this module.
Definition in file pcsed.c.
Go to the source code of this file.
Functions | |
| void * | _eth_formatpacket (const void *mac_dest, WORD eth_type) |
| _eth_format_packet() places the next packet to be transmitted into the above link-layer output packet. | |
| int | send_loopback (link_Packet pkt, BOOL is_ip6, unsigned *err_line) |
| Enqueue a link-layer frame (IPv4/v6 only) to the internal loopback device. | |
| int | _eth_send (WORD len, const void *sock, const char *file, unsigned line) |
| _eth_send() does the actual transmission once we are complete with filling the buffer. | |
| void * | eth_mac_format (void *mac_buf, const void *mac_dest, WORD type) |
| Format the MAC-header for Ethernet. | |
| void * | tok_mac_format (void *mac_buf, const void *mac_dest, WORD type) |
| Format the MAC-header for Token-Ring. | |
| void * | fddi_mac_format (void *mac_buf, const void *mac_dest, WORD type) |
| Format the MAC-header for FDDI. | |
| void * | arcnet_mac_format (void *mac_buf, const void *mac_dest, WORD type) |
| Format the MAC-header for ARCNET. | |
| void * | null_mac_format (void *mac_buf, const void *mac_dest, WORD type) |
| Format MAC-header for protocols without MAC-headers. | |
| int | eth_mac_xmit (const void *buf, WORD len) |
| Functions called via function pointer `mac_transmit' to actually send the data. | |
| int | fddi_mac_xmit (const void *buf, WORD len) |
| int | arcnet_mac_xmit (const void *buf, WORD len) |
| int | tok_mac_xmit (const void *buf, WORD len) |
| int | null_mac_xmit (const void *buf, WORD len) |
| int | _eth_init (void) |
| Initialize the network driver interface. | |
| int | _eth_set_addr (const void *addr) |
| Sets a new MAC address for our interface. | |
| BYTE | _eth_get_hwtype (BYTE *hwtype, BYTE *hwlen) |
| Fill in hardware address type/length for BOOTP/DHCP packets. | |
| void | _eth_free (const void *pkt) |
| Free an input buffer once it is no longer needed. | |
| void | fix_tok_head (tok_Header **trp) |
| BOOL | fix_arc_head (const arcnet_Header *head, WORD *type) |
| link_Packet * | poll_recv_queue (WORD *type) |
| Poll the packet queue. | |
| void | fix_llc_head (void **mac) |
| void * | _eth_arrived (WORD *type_ptr, BOOL *broadcast) |
| Poll for arrival of new packets (IP/ARP/RARP/PPPoE protocol). | |
| void * | _eth_mac_hdr (const in_Header *ip) |
| Return pointer to MAC header start address of an IP packet. | |
| void * | _eth_mac_dst (const in_Header *ip) |
| Return pointer to MAC destination address of an IP packet. | |
| void * | _eth_mac_src (const in_Header *ip) |
| Return pointer to MAC source address of an IP packet. | |
| WORD | _eth_mac_typ (const in_Header *ip) |
| Return value of protocol-type given an IP packet. | |
| BOOL | _eth_join_mcast_group (const struct MultiCast *mc) |
| Joins a multicast group (at the physical layer). | |
| BOOL | _eth_leave_mcast_group (const struct MultiCast *mc) |
| Leaves a multicast group (at the physical layer). | |
| void | _eth_release (void) |
| Release the hardware driver. | |
Variables | |
| mac_address | _eth_addr |
| Local link-layer source address. | |
| mac_address | _eth_brdcast |
| Link-layer broadcast address. | |
| mac_address | _eth_loop_addr |
| Link-layer loopback address. | |
| mac_address | _eth_real_addr |
| Our real MAC address. | |
| BYTE | _eth_mac_len |
| Size of a MAC address. | |
| BOOL | _eth_is_init = FALSE |
| we are initialised | |
| BOOL | _ip_recursion = FALSE |
| avoid recursion in arp_resolve() | |
| BOOL | _eth_ndis3pkt = FALSE |
| for DOS-programs only | |
| BOOL | _eth_SwsVpkt = FALSE |
| for DOS *and* Win32 programs | |
| BOOL | _eth_airpcap = FALSE |
| for Win32 using the AirPcap adapter | |
| const char * | _eth_not_init = "Packet driver not initialised" |
| _eth_last_info | _eth_last |
| Sizes and timestamps of last packet recv/sent. | |
| void *(* | _eth_recv_hook )(WORD *type)=NULL |
| Pointer to functions that when set changes the behaviour of polling and send functions _eth_arrived() and _eth_send(). | |
| int(* | _eth_recv_peek )(void *mac_buf)=NULL |
| int(* | _eth_xmit_hook )(const void *mac_buf, unsigned len)=NULL |
| void *(* | mac_tx_format )(void *mac_buf, const void *mac_dest, WORD type) |
| Pointer to functions that does the filling of correct MAC-header and sends the link-layer packet. | |
| int(* | mac_transmit )(const void *mac_buf, WORD len) |
| WORD | proto |
| void * | nw_pkt |
| link_Packet | outbuf |
|
||||||||||||
|
Poll for arrival of new packets (IP/ARP/RARP/PPPoE protocol). Sets protocol-type of packet received in 'type'.
For Ethernet/TokenRing-type drivers:
<
References _eth_brdcast, _eth_free(), _eth_is_init, _eth_recv_hook, _ip_recursion, _pktdevclass, _pktserial, BYTE, fix_llc_head(), macstat::num_ip_recurse, poll_recv_queue(), update_in_stat(), and WORD. |
|
||||||||||||
|
_eth_format_packet() places the next packet to be transmitted into the above link-layer output packet.
References WORD. |
|
||||||||||||
|
Fill in hardware address type/length for BOOTP/DHCP packets. Also used for ARP/RARP packets. Should never be called for PPP/SLIP. Definition at line 740 of file pcsed.c. References _pktdevclass, arcnet_address, ax25_address, BYTE, eth_address, fddi_address, and tok_address. |
|
|
Initialize the network driver interface.
References _eth_addr, _eth_brdcast, _eth_get_hwtype(), _eth_is_init, _eth_loop_addr, _eth_mac_len, _eth_ndis3pkt, _eth_real_addr, _eth_release(), _eth_SwsVpkt, _pktdevclass, arcnet_mac_format(), eth_address, eth_mac_format(), eth_mac_xmit(), fddi_mac_format(), mac_tx_format, null_mac_format(), pkt_buf_wipe(), pkt_eth_init(), and tok_mac_format(). |
|
|
Joins a multicast group (at the physical layer).
References _pkt_errno, _pkt_rxmode, eth_address, MultiCast::ethaddr, pkt_get_multicast_list(), pkt_set_multicast_list(), pkt_set_rcv_mode(), RXMODE_MULTICAST1, RXMODE_MULTICAST2, and RXMODE_PROMISCOUS. |
|
|
Leaves a multicast group (at the physical layer).
References _pkt_errno, _pkt_rxmode, eth_address, MultiCast::ethaddr, pkt_get_multicast_list(), pkt_set_multicast_list(), pkt_set_rcv_mode(), and RXMODE_MULTICAST2. |
|
||||||||||||||||||||
|
_eth_send() does the actual transmission once we are complete with filling the buffer. Do any last minute patches here, like fix the size. Send to "loopback" device if it's IP and destination matches loopback network (127.x.x.x.). Return length of network-layer packet (not length of link-layer packet). Definition at line 302 of file pcsed.c. References _eth_is_init, _eth_last, _pkt_ip_ofs, _pktdevclass, in_Header::destination, in6_Header::destination, has_rdtsc, send_loopback(), update_out_stat(), and WORD. |
|
|
References _eth_free(). |
|
||||||||||||||||
|
Format MAC-header for protocols without MAC-headers. Nothing done here. Definition at line 573 of file pcsed.c. References WORD. |
|
|
Poll the packet queue. Return first packet in queue. Optionally do receiver profiling.
References _eth_last, _pkt_inf, _pktdevclass, _pktserial, arcnet_Packet::data, fddi_Packet::head, arcnet_Packet::head, pkt_free_pkt(), pkt_info::pkt_queue, fddi_Header::type, tok_Header::type, uint64, and WORD. |
|
||||||||||||||||
|
Enqueue a link-layer frame (IPv4/v6 only) to the internal loopback device.
References _eth_addr, _eth_loop_addr, _pkt_inf, _pkt_ip_ofs, _pktserial, BYTE, pkt_ringbuf::num_buf, and pkt_info::pkt_queue. |
|
|
Pointer to functions that when set changes the behaviour of polling and send functions _eth_arrived() and _eth_send(). _eth_recv_hook: If set, must point to a function that supplies frames ready to be received. Return NULL if no frame is ready. Otherwise points to a raw MAC frame. If not a serial-driver, must also set '*type'. _eth_recv_peek: If set, must point to a function that gets a chance to peek at the raw received frame. It can modify it or even consume it by returning zero. To prevent recursion, this function cannot call tcp_tick(). It should return as fast as possible in order not to block reception of other frames waiting in the receive buffer. _eth_xmit_hook: If set, must point to a function that should transmit all frames generated by Watt-32. Must return length of frame sent or <= 0 if it failed. Definition at line 88 of file pcsed.c. |
|
|
Pointer to functions that does the filling of correct MAC-header and sends the link-layer packet. We store 'proto' between calls. Definition at line 96 of file pcsed.c. |
1.3.8