Changeset 49ff5f3 in mainline for uspace/srv/net/tcp/std.h
- Timestamp:
- 2012-04-18T20:55:21Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7769ec9
- Parents:
- e895352 (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
-
uspace/srv/net/tcp/std.h (moved) (moved from uspace/lib/net/include/net_checksum.h ) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tcp/std.h
re895352 r49ff5f3 1 1 /* 2 * Copyright (c) 20 09 Lukas Mejdrech2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libnet29 /** @addtogroup tcp 30 30 * @{ 31 31 */ 32 /** @file 33 * General CRC and checksum computation. 32 /** @file TCP header definitions 33 * 34 * Based on IETF RFC 793 34 35 */ 35 36 36 #ifndef LIBNET_CHECKSUM_H_37 #define LIBNET_CHECKSUM_H_37 #ifndef STD_H 38 #define 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 /** TCP Header (fixed part) */ 43 typedef struct { 44 /** Source port */ 45 uint16_t src_port; 46 /** Destination port */ 47 uint16_t dest_port; 48 /** Sequence number */ 49 uint32_t seq; 50 /** Acknowledgement number */ 51 uint32_t ack; 52 /** Data Offset, Reserved, Flags */ 53 uint16_t doff_flags; 54 /** Window */ 55 uint16_t window; 56 /* Checksum */ 57 uint16_t checksum; 58 /** Urgent pointer */ 59 uint16_t urg_ptr; 60 } tcp_header_t; 48 61 49 #ifdef __BE__ 62 /** Bits in tcp_header_t.doff_flags */ 63 enum doff_flags_bits { 64 DF_DATA_OFFSET_h = 15, 65 DF_DATA_OFFSET_l = 12, 66 DF_URG = 5, 67 DF_ACK = 4, 68 DF_PSH = 3, 69 DF_RST = 2, 70 DF_SYN = 1, 71 DF_FIN = 0 72 }; 50 73 51 #define compute_crc32(seed, data, length) \ 52 compute_crc32_be(seed, (uint8_t *) data, length) 74 /** TCP pseudo header */ 75 typedef struct { 76 /** Source address */ 77 uint32_t src_addr; 78 /** Destination address */ 79 uint32_t dest_addr; 80 /** Zero */ 81 uint8_t zero; 82 /** Protocol */ 83 uint8_t protocol; 84 /** TCP length */ 85 uint16_t tcp_length; 86 } tcp_phdr_t; 53 87 54 #endif 55 56 #ifdef __LE__ 57 58 #define compute_crc32(seed, data, length) \ 59 compute_crc32_le(seed, (uint8_t *) data, length) 60 61 #endif 62 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 extern uint64_t multicast_hash(const uint8_t addr[6]); 88 /** Option kind */ 89 enum opt_kind { 90 /** End of option list */ 91 OPT_END_LIST = 0, 92 /** No-operation */ 93 OPT_NOP = 1, 94 /** Maximum segment size */ 95 OPT_MAX_SEG_SIZE = 2 96 }; 70 97 71 98 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
