Rev 4731 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4731 | Rev 4756 | ||
|---|---|---|---|
| Line 38... | Line 38... | ||
| 38 | #define __NET_PACKET_HEADER_H__ |
38 | #define __NET_PACKET_HEADER_H__ |
| 39 | 39 | ||
| 40 | #include "packet.h" |
40 | #include "packet.h" |
| 41 | 41 | ||
| 42 | /** Returns the actual packet data length. |
42 | /** Returns the actual packet data length. |
| 43 | * @param header The packet header. Input parameter. |
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 ) (( header )->data_end - ( header )->data_start ) |
| 46 | 46 | ||
| 47 | /** Returns the maximum packet address length. |
47 | /** Returns the maximum packet address length. |
| 48 | * @param header The packet header. Input parameter. |
48 | * @param[in] header The packet header. |
| 49 | */ |
49 | */ |
| 50 | #define PACKET_MAX_ADDRESS_LENGTH( header ) (( header )->dest_addr - ( header )->src_addr ) |
50 | #define PACKET_MAX_ADDRESS_LENGTH( header ) (( header )->dest_addr - ( header )->src_addr ) |
| 51 | 51 | ||
| 52 | /** Returns the minimum packet suffix. |
52 | /** Returns the minimum packet suffix. |
| 53 | * @param header The packet header. Input parameter. |
53 | * @param[in] header The packet header. |
| 54 | */ |
54 | */ |
| 55 | #define PACKET_MIN_SUFFIX( header ) (( header )->length - ( header )->data_start - ( header )->max_content ) |
55 | #define PACKET_MIN_SUFFIX( header ) (( header )->length - ( header )->data_start - ( header )->max_content ) |
| 56 | 56 | ||
| 57 | /** Packet integrity check magic value. |
57 | /** Packet integrity check magic value. |
| 58 | */ |
58 | */ |
| Line 107... | Line 107... | ||
| 107 | */ |
107 | */ |
| 108 | int magic_value; |
108 | int magic_value; |
| 109 | }; |
109 | }; |
| 110 | 110 | ||
| 111 | /** Returns whether the packet is valid. |
111 | /** Returns whether the packet is valid. |
| 112 | * @param packet The packet to be checked. Input parameter. |
112 | * @param[in] packet The packet to be checked. |
| 113 | * @returns true if the packet is not NULL and the magic value is correct. |
113 | * @returns true if the packet is not NULL and the magic value is correct. |
| 114 | * @returns false otherwise. |
114 | * @returns false otherwise. |
| 115 | */ |
115 | */ |
| 116 | static inline int packet_is_valid( const packet_t packet ){ |
116 | static inline int packet_is_valid( const packet_t packet ){ |
| 117 | return packet && ( packet->magic_value == PACKET_MAGIC_VALUE ); |
117 | return packet && ( packet->magic_value == PACKET_MAGIC_VALUE ); |