Changeset 0c37135 in mainline for uspace/srv/net/ethip/std.h
- Timestamp:
- 2012-04-18T07:32:58Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5f67cd61
- Parents:
- 3d93289a (diff), 63920b0 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/ethip/std.h
r3d93289a r0c37135 1 1 /* 2 * Copyright (c) 20 09 Lukas Mejdrech2 * Copyright (c) 2012 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libnet29 /** @addtogroup ethip 30 30 * @{ 31 31 */ 32 /** @file 33 * General CRC and checksum computation. 32 /** 33 * @file Ethernet, IP/Ethernet standard definitions 34 * 34 35 */ 35 36 36 #ifndef LIBNET_CHECKSUM_H_37 #define LIBNET_CHECKSUM_H_37 #ifndef ETHIP_STD_H_ 38 #define ETHIP_STD_H_ 38 39 39 #include <byteorder.h>40 40 #include <sys/types.h> 41 41 42 /** IP checksum value for computed zero checksum. 43 * 44 * Zero is returned as 0xFFFF (not flipped) 45 * 46 */ 47 #define IP_CHECKSUM_ZERO 0xffffU 42 #define ETH_ADDR_SIZE 6 43 #define IPV4_ADDR_SIZE 4 44 #define ETH_FRAME_MIN_SIZE 60 48 45 49 #ifdef __BE__ 46 /** Ethernet frame header */ 47 typedef struct { 48 /** Destination Address */ 49 uint8_t dest[ETH_ADDR_SIZE]; 50 /** Source Address */ 51 uint8_t src[ETH_ADDR_SIZE]; 52 /** Ethertype or Length */ 53 uint16_t etype_len; 54 } eth_header_t; 50 55 51 #define compute_crc32(seed, data, length) \ 52 compute_crc32_be(seed, (uint8_t *) data, length) 56 /** ARP packet format (for 48-bit MAC addresses and IPv4) */ 57 typedef struct { 58 /** Hardware address space */ 59 uint16_t hw_addr_space; 60 /** Protocol address space */ 61 uint16_t proto_addr_space; 62 /** Hardware address size */ 63 uint8_t hw_addr_size; 64 /** Protocol address size */ 65 uint8_t proto_addr_size; 66 /** Opcode */ 67 uint16_t opcode; 68 /** Sender hardware address */ 69 uint8_t sender_hw_addr[ETH_ADDR_SIZE]; 70 /** Sender protocol address */ 71 uint32_t sender_proto_addr; 72 /** Target hardware address */ 73 uint8_t target_hw_addr[ETH_ADDR_SIZE]; 74 /** Target protocol address */ 75 uint32_t target_proto_addr; 76 } __attribute__((packed)) arp_eth_packet_fmt_t; 53 77 54 #endif 78 enum arp_opcode_fmt { 79 AOP_REQUEST = 1, 80 AOP_REPLY = 2 81 }; 55 82 56 #ifdef __LE__ 83 enum arp_hw_addr_space { 84 AHRD_ETHERNET = 1 85 }; 57 86 58 #define compute_crc32(seed, data, length) \ 59 compute_crc32_le(seed, (uint8_t *) data, length) 87 /** IP Ethertype */ 88 enum ether_type { 89 ETYPE_ARP = 0x0806, 90 ETYPE_IP = 0x0800 91 }; 60 92 61 #endif62 63 extern uint32_t compute_crc32_le(uint32_t, uint8_t *, size_t);64 extern uint32_t compute_crc32_be(uint32_t, uint8_t *, size_t);65 extern uint32_t compute_checksum(uint32_t, uint8_t *, size_t);66 extern uint16_t compact_checksum(uint32_t);67 extern uint16_t flip_checksum(uint16_t);68 extern uint16_t ip_checksum(uint8_t *, size_t);69 93 70 94 #endif
Note:
See TracChangeset
for help on using the changeset viewer.