Changes in uspace/lib/net/generic/packet_client.c [28a3e74:b69ceea] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/generic/packet_client.c
r28a3e74 rb69ceea 53 53 * @param[in] data The data to be copied. 54 54 * @param[in] length The length of the copied data. 55 * @return EOK on success.56 * @return EINVAL if the packet is not valid.57 * @return ENOMEM if there is not enough memory left.58 */ 59 int packet_copy_data(packet_t *packet, const void *data, size_t length)55 * @returns EOK on success. 56 * @returns EINVAL if the packet is not valid. 57 * @returns ENOMEM if there is not enough memory left. 58 */ 59 int packet_copy_data(packet_t packet, const void *data, size_t length) 60 60 { 61 61 if (!packet_is_valid(packet)) … … 78 78 * @param[in] length The space length to be allocated at the beginning of the 79 79 * packet content. 80 * @return The pointer to the allocated memory.81 * @return NULL if there is not enough memory left.82 */ 83 void *packet_prefix(packet_t *packet, size_t length)80 * @returns The pointer to the allocated memory. 81 * @returns NULL if there is not enough memory left. 82 */ 83 void *packet_prefix(packet_t packet, size_t length) 84 84 { 85 85 if ((!packet_is_valid(packet)) || 86 (packet->data_start - sizeof( packet_t) -86 (packet->data_start - sizeof(struct packet) - 87 87 2 * (packet->dest_addr - packet->src_addr) < length)) { 88 88 return NULL; … … 99 99 * @param[in] length The space length to be allocated at the end of the 100 100 * packet content. 101 * @return The pointer to the allocated memory.102 * @return NULL if there is not enough memory left.103 */ 104 void *packet_suffix(packet_t *packet, size_t length)101 * @returns The pointer to the allocated memory. 102 * @returns NULL if there is not enough memory left. 103 */ 104 void *packet_suffix(packet_t packet, size_t length) 105 105 { 106 106 if ((!packet_is_valid(packet)) || … … 120 120 * @param[in] suffix The suffix length to be removed from the end of the 121 121 * packet content. 122 * @return EOK on success.123 * @return EINVAL if the packet is not valid.124 * @return ENOMEM if there is not enough memory left.125 */ 126 int packet_trim(packet_t *packet, size_t prefix, size_t suffix)122 * @returns EOK on success. 123 * @returns EINVAL if the packet is not valid. 124 * @returns ENOMEM if there is not enough memory left. 125 */ 126 int packet_trim(packet_t packet, size_t prefix, size_t suffix) 127 127 { 128 128 if (!packet_is_valid(packet)) … … 140 140 * 141 141 * @param[in] packet The packet. 142 * @return The packet identifier.143 * @return Zero if the packet is not valid.144 */ 145 packet_id_t packet_get_id(const packet_t *packet)142 * @returns The packet identifier. 143 * @returns Zero if the packet is not valid. 144 */ 145 packet_id_t packet_get_id(const packet_t packet) 146 146 { 147 147 return packet_is_valid(packet) ? packet->packet_id : 0; … … 153 153 * @param[out] src The source address. May be NULL if not desired. 154 154 * @param[out] dest The destination address. May be NULL if not desired. 155 * @return The stored addresses length.156 * @return Zero if the addresses are not present.157 * @return EINVAL if the packet is not valid.158 */ 159 int packet_get_addr(const packet_t *packet, uint8_t **src, uint8_t **dest)155 * @returns The stored addresses length. 156 * @returns Zero if the addresses are not present. 157 * @returns EINVAL if the packet is not valid. 158 */ 159 int packet_get_addr(const packet_t packet, uint8_t **src, uint8_t **dest) 160 160 { 161 161 if (!packet_is_valid(packet)) … … 174 174 * 175 175 * @param[in] packet The packet. 176 * @return The packet content length in bytes.177 * @return Zero if the packet is not valid.178 */ 179 size_t packet_get_data_length(const packet_t *packet)176 * @returns The packet content length in bytes. 177 * @returns Zero if the packet is not valid. 178 */ 179 size_t packet_get_data_length(const packet_t packet) 180 180 { 181 181 if (!packet_is_valid(packet)) … … 188 188 * 189 189 * @param[in] packet The packet. 190 * @return The pointer to the beginning of the packet content.191 * @return NULL if the packet is not valid.192 */ 193 void *packet_get_data(const packet_t *packet)190 * @returns The pointer to the beginning of the packet content. 191 * @returns NULL if the packet is not valid. 192 */ 193 void *packet_get_data(const packet_t packet) 194 194 { 195 195 if (!packet_is_valid(packet)) … … 205 205 * @param[in] dest The new destination address. May be NULL. 206 206 * @param[in] addr_len The addresses length. 207 * @return EOK on success.208 * @return EINVAL if the packet is not valid.209 * @return ENOMEM if there is not enough memory left.207 * @returns EOK on success. 208 * @returns EINVAL if the packet is not valid. 209 * @returns ENOMEM if there is not enough memory left. 210 210 */ 211 211 int 212 packet_set_addr(packet_t *packet, const uint8_t *src, const uint8_t *dest,212 packet_set_addr(packet_t packet, const uint8_t *src, const uint8_t *dest, 213 213 size_t addr_len) 214 214 { … … 254 254 * @param[in] phone The packet server module phone. 255 255 * @param[in] packet The original packet. 256 * @return The packet copy.257 * @return NULL on error.258 */ 259 packet_t *packet_get_copy(int phone, packet_t *packet)260 { 261 packet_t *copy;256 * @returns The packet copy. 257 * @returns NULL on error. 258 */ 259 packet_t packet_get_copy(int phone, packet_t packet) 260 { 261 packet_t copy; 262 262 uint8_t * src = NULL; 263 263 uint8_t * dest = NULL; … … 267 267 return NULL; 268 268 269 / * Get a new packet */269 // get a new packet 270 270 copy = packet_get_4_remote(phone, PACKET_DATA_LENGTH(packet), 271 271 PACKET_MAX_ADDRESS_LENGTH(packet), packet->max_prefix, … … 274 274 return NULL; 275 275 276 / * Get addresses */276 // get addresses 277 277 addrlen = packet_get_addr(packet, &src, &dest); 278 / * Copy data */278 // copy data 279 279 if ((packet_copy_data(copy, packet_get_data(packet), 280 280 PACKET_DATA_LENGTH(packet)) == EOK) && 281 / * Copy addresses if present */281 // copy addresses if present 282 282 ((addrlen <= 0) || 283 283 (packet_set_addr(copy, src, dest, addrlen) == EOK))) {
Note:
See TracChangeset
for help on using the changeset viewer.