Rev 3914 | Rev 4075 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3914 | Rev 3990 | ||
|---|---|---|---|
| Line 52... | Line 52... | ||
| 52 | * @param type The type to be allocated at the beginning of the packet content. Input parameter. |
52 | * @param type The type to be allocated at the beginning of the packet content. Input parameter. |
| 53 | * @returns The typed pointer to the allocated memory. |
53 | * @returns The typed pointer to the allocated memory. |
| 54 | * @returns NULL if the packet is not valid. |
54 | * @returns NULL if the packet is not valid. |
| 55 | * @returns NULL if there is not enough memory left. |
55 | * @returns NULL if there is not enough memory left. |
| 56 | */ |
56 | */ |
| 57 | #define PACKET_PREFIX( packet, type ) ( type * ) packet_prepend(( packet ), sizeof( type )) |
57 | #define PACKET_PREFIX( packet, type ) ( type * ) packet_prefix(( packet ), sizeof( type )) |
| 58 | 58 | ||
| 59 | /** Allocates the specified type right after the actual packet content and returns its pointer. |
59 | /** Allocates the specified type right after the actual packet content and returns its pointer. |
| 60 | * The wrapper of the packet_append() function. |
60 | * The wrapper of the packet_append() function. |
| 61 | * @param packet The packet to be used. Input parameter. |
61 | * @param packet The packet to be used. Input parameter. |
| 62 | * @param type The type to be allocated at the end of the packet content. Input parameter. |
62 | * @param type The type to be allocated at the end of the packet content. Input parameter. |
| 63 | * @returns The typed pointer to the allocated memory. |
63 | * @returns The typed pointer to the allocated memory. |
| 64 | * @returns NULL if the packet is not valid. |
64 | * @returns NULL if the packet is not valid. |
| 65 | * @returns NULL if there is not enough memory left. |
65 | * @returns NULL if there is not enough memory left. |
| 66 | */ |
66 | */ |
| 67 | #define PACKET_SUFFIX( packet, type ) ( type * ) packet_append(( packet ), sizeof( type )) |
67 | #define PACKET_SUFFIX( packet, type ) ( type * ) packet_suffix(( packet ), sizeof( type )) |
| 68 | 68 | ||
| 69 | /** Trims the actual packet content by the specified prefix and suffix types. |
69 | /** Trims the actual packet content by the specified prefix and suffix types. |
| 70 | * The wrapper of the packet_trim() function. |
70 | * The wrapper of the packet_trim() function. |
| 71 | * @param packet The packet to be trimmed. Input parameter. |
71 | * @param packet The packet to be trimmed. Input parameter. |
| 72 | * @param prefix The type of the prefix to be removed from the beginning of the packet content. Input parameter. |
72 | * @param prefix The type of the prefix to be removed from the beginning of the packet content. Input parameter. |
| Line 101... | Line 101... | ||
| 101 | * @returns EINVAL if the packet is not valid. |
101 | * @returns EINVAL if the packet is not valid. |
| 102 | * @returns ENOMEM if there is not enough memory left. |
102 | * @returns ENOMEM if there is not enough memory left. |
| 103 | */ |
103 | */ |
| 104 | int packet_trim( packet_t packet, size_t prefix, size_t suffix ); |
104 | int packet_trim( packet_t packet, size_t prefix, size_t suffix ); |
| 105 | 105 | ||
| 106 | /** Copies the packet content. |
- | |
| 107 | * Obtains the new packet from the packet server. |
- | |
| 108 | * @param phone The packet server module phone. Input parameter. |
- | |
| 109 | * @param owner The owner of the new packet. Input parameter. |
- | |
| 110 | * @param packet The packet reference. Input parameter. |
- | |
| 111 | * @returns The packet copy. |
- | |
| 112 | * @returns NULL if the source packet ids not valid. |
- | |
| 113 | * @returns NULL on error. |
- | |
| 114 | * \todo other error? |
- | |
| 115 | */ |
- | |
| 116 | packet_t packet_copy( int phone, services_t owner, const packet_t packet ); |
- | |
| 117 | - | ||
| 118 | /** Copies the specified data to the beginning of the actual packet content. |
106 | /** Copies the specified data to the beginning of the actual packet content. |
| 119 | * Pushes the content end if needed. |
107 | * Pushes the content end if needed. |
| 120 | * @param packet The packet to be filled. Input parameter. |
108 | * @param packet The packet to be filled. Input parameter. |
| 121 | * @param data The data to be copied. Input parameter. |
109 | * @param data The data to be copied. Input parameter. |
| 122 | * @param length The length of the copied data. Input parameter. |
110 | * @param length The length of the copied data. Input parameter. |
| Line 156... | Line 144... | ||
| 156 | * @returns EINVAL if the packet is not valid. |
144 | * @returns EINVAL if the packet is not valid. |
| 157 | * @returns EINVAL if the src and/or the dest parameter is NULL. |
145 | * @returns EINVAL if the src and/or the dest parameter is NULL. |
| 158 | */ |
146 | */ |
| 159 | int packet_get_addr( const packet_t packet, uint8_t ** src, uint8_t ** dest ); |
147 | int packet_get_addr( const packet_t packet, uint8_t ** src, uint8_t ** dest ); |
| 160 | 148 | ||
| 161 | /** Returns the packet operation mode. |
- | |
| 162 | * @param packet The packet. Input parameter. |
- | |
| 163 | * @returns The packet operation mode. |
- | |
| 164 | * @see packet_mode |
- | |
| 165 | */ |
- | |
| 166 | packet_mode_t packet_get_mode( const packet_t packet ); |
- | |
| 167 | - | ||
| 168 | /** Sets the packet addresses. |
149 | /** Sets the packet addresses. |
| 169 | * @param packet The packet. Input parameter. |
150 | * @param packet The packet. Input parameter. |
| 170 | * @param src The new source address. Output parameter. |
151 | * @param src The new source address. Output parameter. |
| 171 | * @param dest The new destination address. Output parameter. |
152 | * @param dest The new destination address. Output parameter. |
| 172 | * @param addr_len The addresses length. |
153 | * @param addr_len The addresses length. |
| Line 174... | Line 155... | ||
| 174 | * @returns EINVAL if the packet is not valid. |
155 | * @returns EINVAL if the packet is not valid. |
| 175 | * @returns ENOMEM if there is not enough memory left. |
156 | * @returns ENOMEM if there is not enough memory left. |
| 176 | */ |
157 | */ |
| 177 | int packet_set_addr( packet_t packet, const uint8_t * src, const uint8_t * dest, size_t addr_len ); |
158 | int packet_set_addr( packet_t packet, const uint8_t * src, const uint8_t * dest, size_t addr_len ); |
| 178 | 159 | ||
| 179 | /** Sets the packet operation mode. |
- | |
| 180 | * @param packet The packet. Input parameter. |
- | |
| 181 | * @param mode The new packet operation mode. Input parameter. |
- | |
| 182 | * @returns EOK on success. |
- | |
| 183 | * @returns EINVAL if the packet is not valid. |
- | |
| 184 | * @see packet_mode |
- | |
| 185 | */ |
- | |
| 186 | int packet_set_mode( packet_t packet, packet_mode_t mode ); |
- | |
| 187 | - | ||
| 188 | /** Sets the packet owner. |
- | |
| 189 | * @param packet The packet. Input parameter. |
- | |
| 190 | * @param owner The new packet owner. Input parameter. |
- | |
| 191 | * @returns EOK on success. |
- | |
| 192 | * @returns EINVAL if the packet is not valid. |
- | |
| 193 | */ |
- | |
| 194 | int packet_set_owner( packet_t packet, services_t owner ); |
- | |
| 195 | - | ||
| 196 | /** Translates the packet identifier to the packet reference. |
160 | /** Translates the packet identifier to the packet reference. |
| 197 | * Tries to find mapping first. |
161 | * Tries to find mapping first. |
| 198 | * Contacts the packet server to share the packet if the mapping is not present. |
162 | * Contacts the packet server to share the packet if the mapping is not present. |
| 199 | * @param phone The packet server module phone. Input parameter. |
163 | * @param phone The packet server module phone. Input parameter. |
| 200 | * @param packet The packet reference. Output parameter. |
164 | * @param packet The packet reference. Output parameter. |
| Line 207... | Line 171... | ||
| 207 | int packet_translate( int phone, packet_ref packet, packet_id_t packet_id ); |
171 | int packet_translate( int phone, packet_ref packet, packet_id_t packet_id ); |
| 208 | 172 | ||
| 209 | /** Obtains the packet of the given dimensions. |
173 | /** Obtains the packet of the given dimensions. |
| 210 | * Contacts the packet server to return the appropriate packet. |
174 | * Contacts the packet server to return the appropriate packet. |
| 211 | * @param phone The packet server module phone. Input parameter. |
175 | * @param phone The packet server module phone. Input parameter. |
| 212 | * @param owner The owner of the new packet. Input parameter. |
- | |
| 213 | * @param addr_len The source and destination addresses maximal length in bytes. Input parameter. |
176 | * @param addr_len The source and destination addresses maximal length in bytes. Input parameter. |
| 214 | * @param max_prefix The maximal prefix length in bytes. Input parameter. |
177 | * @param max_prefix The maximal prefix length in bytes. Input parameter. |
| 215 | * @param max_content The maximal content length in bytes. Input parameter. |
178 | * @param max_content The maximal content length in bytes. Input parameter. |
| 216 | * @param max_suffix The maximal suffix length in bytes. Input parameter. |
179 | * @param max_suffix The maximal suffix length in bytes. Input parameter. |
| 217 | * @returns The packet reference. |
180 | * @returns The packet reference. |
| 218 | * @returns NULL on error. |
181 | * @returns NULL on error. |
| 219 | * \todo error as NET_PACKET_CREATE_5, packet_return() |
182 | * \todo error as NET_PACKET_CREATE_4, packet_return() |
| 220 | */ |
183 | */ |
| 221 | packet_t packet_get_5( int phone, services_t owner, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix ); |
184 | packet_t packet_get_4( int phone, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix ); |
| 222 | 185 | ||
| 223 | /** Obtains the packet of the given content size. |
186 | /** Obtains the packet of the given content size. |
| 224 | * Contacts the packet server to return the appropriate packet. |
187 | * Contacts the packet server to return the appropriate packet. |
| 225 | * @param phone The packet server module phone. Input parameter. |
188 | * @param phone The packet server module phone. Input parameter. |
| 226 | * @param owner The owner of the new packet. Input parameter. |
- | |
| 227 | * @param content The maximal content length in bytes. Input parameter. |
189 | * @param content The maximal content length in bytes. Input parameter. |
| 228 | * @returns The packet reference. |
190 | * @returns The packet reference. |
| 229 | * @returns NULL on error. |
191 | * @returns NULL on error. |
| 230 | * \todo error as NET_PACKET_CREATE_1, packet_return() |
192 | * \todo error as NET_PACKET_CREATE_1, packet_return() |
| 231 | */ |
193 | */ |
| 232 | packet_t packet_get_1( int phone, services_t owner, size_t content ); |
194 | packet_t packet_get_1( int phone, size_t content ); |
| 233 | 195 | ||
| 234 | /** Releases the packet. |
196 | /** Releases the packet. |
| 235 | * The packet is marked as free for use. |
197 | * The packet is marked as free for use. |
| 236 | * The module should not use the packet after this point until it is received or obtained again. |
198 | * The module should not use the packet after this point until it is received or obtained again. |
| 237 | * @param phone The packet server module phone. Input parameter. |
199 | * @param phone The packet server module phone. Input parameter. |