|
AquilaOS documentation
How it works, and its code
|
Ethernet, and the Internet checksum. More...
Go to the source code of this file.
Functions | |
| void | ether_input (struct netif *netif, struct netbuf *nb) |
| Takes in a frame that an interface received, and passes it to ARP or IPv4. | |
| int | ether_output (struct netif *netif, const uint8_t dst[6], uint16_t type, struct netbuf *nb) |
| Sends a frame: adds its Ethernet header and gives it to the interface. | |
| uint16_t | inet_checksum (const void *data, size_t len) |
| Computes the Internet checksum (RFC 1071): the ones' complement of the ones' complement sum of the data's 16-bit words. | |
| uint16_t | inet_checksum_pseudo (uint32_t src, uint32_t dst, uint8_t proto, const void *data, size_t len) |
| Computes the Internet checksum of data with the IPv4 pseudo-header before it (the addresses, the protocol and the length), as UDP and TCP do. | |
Ethernet, and the Internet checksum.
A frame that arrives goes to the protocol its type says (ARP or IPv4); a frame to send gets its Ethernet header here. The Internet checksum, which IPv4, ICMP, UDP and TCP use, is here too.
Definition in file ether.c.
Takes in a frame that an interface received, and passes it to ARP or IPv4.
A frame of another type, or too short, is dropped.
| netif | the interface it came in on |
| nb | the frame; it is freed or passed on |
Definition at line 21 of file ether.c.
References arp_input(), ether_input(), ETHER_TYPE_ARP, ETHER_TYPE_IPV4, ipv4_input(), netbuf_free(), netbuf_pull(), ntohs, ether_hdr::src, netif::stats, and ether_hdr::type.
Referenced by ether_input(), and net_main().
Sends a frame: adds its Ethernet header and gives it to the interface.
The netbuf is freed in every case.
| netif | the interface to send it on |
| dst | the destination MAC address |
| type | the frame's type (ETHER_TYPE_*) |
| nb | the frame's data, with room for the header before it |
Definition at line 54 of file ether.c.
References ether_hdr::dst, ether_output(), htons, netif::mac, memcpy(), netbuf_free(), netbuf_push(), netif_output(), ether_hdr::src, and ether_hdr::type.
Referenced by arp_input(), arp_request(), ether_output(), ipv4_output(), and pending_flush().
Computes the Internet checksum (RFC 1071): the ones' complement of the ones' complement sum of the data's 16-bit words.
| data | the data |
| len | its length, in bytes |
Definition at line 76 of file ether.c.
References htons, and inet_checksum().
Referenced by icmp_input(), icmp_unreachable(), inet_checksum(), ipv4_input(), ipv4_output(), and socket_inet_send().
| uint16_t inet_checksum_pseudo | ( | uint32_t | src, |
| uint32_t | dst, | ||
| uint8_t | proto, | ||
| const void * | data, | ||
| size_t | len ) |
Computes the Internet checksum of data with the IPv4 pseudo-header before it (the addresses, the protocol and the length), as UDP and TCP do.
| src | the source address |
| dst | the destination address |
| proto | the protocol (IP_PROTO_*) |
| data | the UDP or TCP header and data |
| len | their length, in bytes |
Definition at line 106 of file ether.c.
References __packed, ether_hdr::dst, htons, inet_checksum_pseudo(), and ether_hdr::src.
Referenced by inet_checksum_pseudo(), segment(), socket_inet_send(), tcp_input(), tcp_reply_rst(), and udp_input().