Changeset 0b749a3 in mainline for uspace/lib/c/include/net/packet_header.h
- Timestamp:
- 2010-11-22T15:39:53Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0eddb76, aae339e9
- Parents:
- 9a1d8ab (diff), 8cd1aa5e (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/lib/c/include/net/packet_header.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup packet29 /** @addtogroup libc 30 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * 34 * Packet header. 35 35 */ 36 36 37 #ifndef __NET_PACKET_HEADER_H__38 #define __NET_PACKET_HEADER_H__37 #ifndef LIBC_PACKET_HEADER_H_ 38 #define LIBC_PACKET_HEADER_H_ 39 39 40 #include < packet/packet.h>40 #include <net/packet.h> 41 41 42 42 /** Returns the actual packet data length. 43 * @param[in] headerThe packet header.43 * @param[in] header The packet header. 44 44 */ 45 #define PACKET_DATA_LENGTH(header) ((header)->data_end - (header)->data_start) 45 #define PACKET_DATA_LENGTH(header) \ 46 ((header)->data_end - (header)->data_start) 46 47 47 48 /** Returns the maximum packet address length. 48 * @param[in] headerThe packet header.49 * @param[in] header The packet header. 49 50 */ 50 #define PACKET_MAX_ADDRESS_LENGTH(header) ((header)->dest_addr - (header)->src_addr) 51 #define PACKET_MAX_ADDRESS_LENGTH(header) \ 52 ((header)->dest_addr - (header)->src_addr) 51 53 52 54 /** Returns the minimum packet suffix. 53 * @param[in] header 55 * @param[in] header The packet header. 54 56 */ 55 #define PACKET_MIN_SUFFIX(header) ((header)->length - (header)->data_start - (header)->max_content) 57 #define PACKET_MIN_SUFFIX(header) \ 58 ((header)->length - (header)->data_start - (header)->max_content) 56 59 57 /** Packet integrity check magic value. 58 */ 60 /** Packet integrity check magic value. */ 59 61 #define PACKET_MAGIC_VALUE 0x11227788 60 62 61 /** Packet header. 62 */ 63 struct packet{ 64 /** Packet identifier. 65 */ 63 /** Packet header. */ 64 struct packet { 65 /** Packet identifier. */ 66 66 packet_id_t packet_id; 67 /** Packet queue sorting value. 68 * The packet queue is sorted the ascending order. 67 68 /** 69 * Packet queue sorting value. 70 * The packet queue is sorted the ascending order. 69 71 */ 70 72 size_t order; 71 /** Packet metric. 72 */73 74 /** Packet metric. */ 73 75 size_t metric; 74 /** Previous packet in the queue. 75 */ 76 /** Previous packet in the queue. */ 76 77 packet_id_t previous; 77 /** Next packet in the queue. 78 */ 78 /** Next packet in the queue. */ 79 79 packet_id_t next; 80 /** Total length of the packet. 81 * Contains the header, the addresses and the data of the packet. 82 * Corresponds to the mapped sharable memory block. 80 81 /** 82 * Total length of the packet. 83 * Contains the header, the addresses and the data of the packet. 84 * Corresponds to the mapped sharable memory block. 83 85 */ 84 86 size_t length; 85 /** Stored source and destination addresses length. 86 */87 88 /** Stored source and destination addresses length. */ 87 89 size_t addr_len; 88 /** Souce address offset in bytes from the beginning of the packet header. 90 91 /** 92 * Souce address offset in bytes from the beginning of the packet 93 * header. 89 94 */ 90 95 size_t src_addr; 91 /** Destination address offset in bytes from the beginning of the packet header. 96 97 /** 98 * Destination address offset in bytes from the beginning of the packet 99 * header. 92 100 */ 93 101 size_t dest_addr; 94 /** Reserved data prefix length in bytes. 95 */102 103 /** Reserved data prefix length in bytes. */ 96 104 size_t max_prefix; 97 /** Reserved content length in bytes. 98 */ 105 /** Reserved content length in bytes. */ 99 106 size_t max_content; 100 /** Actual data start offset in bytes from the beginning of the packet header. 107 108 /** 109 * Actual data start offset in bytes from the beginning of the packet 110 * header. 101 111 */ 102 112 size_t data_start; 103 /** Actual data end offset in bytes from the beginning of the packet header. 113 114 /** 115 * Actual data end offset in bytes from the beginning of the packet 116 * header. 104 117 */ 105 118 size_t data_end; 106 /** Integrity check magic value. 107 */119 120 /** Integrity check magic value. */ 108 121 int magic_value; 109 122 }; 110 123 111 124 /** Returns whether the packet is valid. 112 * @param[in] packet The packet to be checked. 113 * @returns true if the packet is not NULL and the magic value is correct. 114 * @returns false otherwise. 125 * @param[in] packet The packet to be checked. 126 * @return True if the packet is not NULL and the magic value is 127 * correct. 128 * @return False otherwise. 115 129 */ 116 static inline int packet_is_valid(const packet_t packet){ 130 static inline int packet_is_valid(const packet_t *packet) 131 { 117 132 return packet && (packet->magic_value == PACKET_MAGIC_VALUE); 118 133 }
Note:
See TracChangeset
for help on using the changeset viewer.