Changeset eb522e8 in mainline for uspace/lib/net/generic/packet_client.c
- Timestamp:
- 2011-06-01T08:43:42Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8d6c1f1
- Parents:
- 9e2e715 (diff), e51a514 (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 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/generic/packet_client.c
r9e2e715 reb522e8 53 53 * @param[in] data The data to be copied. 54 54 * @param[in] length The length of the copied data. 55 * @return sEOK on success.56 * @return sEINVAL if the packet is not valid.57 * @return sENOMEM if there is not enough memory left.58 */ 59 int packet_copy_data(packet_t packet, const void *data, size_t length)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) 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 sThe pointer to the allocated memory.81 * @return sNULL if there is not enough memory left.82 */ 83 void *packet_prefix(packet_t packet, size_t length)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) 84 84 { 85 85 if ((!packet_is_valid(packet)) || 86 (packet->data_start - sizeof( struct packet) -86 (packet->data_start - sizeof(packet_t) - 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 sThe pointer to the allocated memory.102 * @return sNULL if there is not enough memory left.103 */ 104 void *packet_suffix(packet_t packet, size_t length)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) 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 sEOK on success.123 * @return sEINVAL if the packet is not valid.124 * @return sENOMEM if there is not enough memory left.125 */ 126 int packet_trim(packet_t packet, size_t prefix, size_t suffix)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) 127 127 { 128 128 if (!packet_is_valid(packet)) … … 140 140 * 141 141 * @param[in] packet The packet. 142 * @return sThe packet identifier.143 * @return sZero if the packet is not valid.144 */ 145 packet_id_t packet_get_id(const packet_t 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) 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 sThe stored addresses length.156 * @return sZero if the addresses are not present.157 * @return sEINVAL if the packet is not valid.158 */ 159 int packet_get_addr(const packet_t packet, uint8_t **src, uint8_t **dest)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) 160 160 { 161 161 if (!packet_is_valid(packet)) … … 174 174 * 175 175 * @param[in] packet The packet. 176 * @return sThe packet content length in bytes.177 * @return sZero if the packet is not valid.178 */ 179 size_t packet_get_data_length(const packet_t 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) 180 180 { 181 181 if (!packet_is_valid(packet)) … … 188 188 * 189 189 * @param[in] packet The packet. 190 * @return sThe pointer to the beginning of the packet content.191 * @return sNULL if the packet is not valid.192 */ 193 void *packet_get_data(const packet_t 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) 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 sEOK on success.208 * @return sEINVAL if the packet is not valid.209 * @return sENOMEM if there is not enough memory left.207 * @return EOK on success. 208 * @return EINVAL if the packet is not valid. 209 * @return 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 sThe packet copy.257 * @return sNULL on error.258 */ 259 packet_t packet_get_copy(int phone, packet_tpacket)260 { 261 packet_t copy;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; 262 262 uint8_t * src = NULL; 263 263 uint8_t * dest = NULL; … … 267 267 return NULL; 268 268 269 / / get a new packet269 /* 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 addresses276 /* Get addresses */ 277 277 addrlen = packet_get_addr(packet, &src, &dest); 278 / / copy data278 /* Copy data */ 279 279 if ((packet_copy_data(copy, packet_get_data(packet), 280 280 PACKET_DATA_LENGTH(packet)) == EOK) && 281 / / copy addresses if present281 /* 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.