Changeset eb522e8 in mainline for uspace/lib/c/generic/net/packet.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/c/generic/net/packet.c
r9e2e715 reb522e8 62 62 63 63 /** Type definition of the packet map page. */ 64 typedef packet_t packet_map_t[PACKET_MAP_SIZE]; 65 66 /** Type definition of the packet map page pointer. */ 67 typedef packet_map_t * packet_map_ref; 64 typedef packet_t *packet_map_t[PACKET_MAP_SIZE]; 68 65 69 66 /** Packet map. … … 85 82 /** Initializes the packet map. 86 83 * 87 * @return sEOK on success.88 * @return sENOMEM if there is not enough memory left.84 * @return EOK on success. 85 * @return ENOMEM if there is not enough memory left. 89 86 */ 90 87 int pm_init(void) … … 104 101 * 105 102 * @param[in] packet_id The packet identifier to be found. 106 * @return sThe found packet reference.107 * @return sNULL if the mapping does not exist.108 */ 109 packet_t pm_find(packet_id_t packet_id)110 { 111 packet_map_ refmap;112 packet_t packet;103 * @return The found packet reference. 104 * @return NULL if the mapping does not exist. 105 */ 106 packet_t *pm_find(packet_id_t packet_id) 107 { 108 packet_map_t *map; 109 packet_t *packet; 113 110 114 111 if (!packet_id) … … 133 130 * 134 131 * @param[in] packet The packet to be remembered. 135 * @return sEOK on success.136 * @return sEINVAL if the packet is not valid.137 * @return sEINVAL if the packet map is not initialized.138 * @return sENOMEM if there is not enough memory left.139 */ 140 int pm_add(packet_t packet)141 { 142 packet_map_ refmap;132 * @return EOK on success. 133 * @return EINVAL if the packet is not valid. 134 * @return EINVAL if the packet map is not initialized. 135 * @return ENOMEM if there is not enough memory left. 136 */ 137 int pm_add(packet_t *packet) 138 { 139 packet_map_t *map; 143 140 int rc; 144 141 … … 154 151 } else { 155 152 do { 156 map = (packet_map_ ref) malloc(sizeof(packet_map_t));153 map = (packet_map_t *) malloc(sizeof(packet_map_t)); 157 154 if (!map) { 158 155 fibril_rwlock_write_unlock(&pm_globals.lock); … … 180 177 int count; 181 178 int index; 182 packet_map_ refmap;183 packet_t packet;179 packet_map_t *map; 180 packet_t *packet; 184 181 185 182 fibril_rwlock_write_lock(&pm_globals.lock); … … 193 190 } 194 191 } 195 gpm_destroy(&pm_globals.packet_map );196 / / leave locked192 gpm_destroy(&pm_globals.packet_map, free); 193 /* leave locked */ 197 194 } 198 195 … … 208 205 * @param[in] order The packet order value. 209 206 * @param[in] metric The metric value of the packet. 210 * @return sEOK on success.211 * @return sEINVAL if the first parameter is NULL.212 * @return sEINVAL if the packet is not valid.213 */ 214 int pq_add(packet_t * first, packet_tpacket, size_t order, size_t metric)215 { 216 packet_t item;207 * @return EOK on success. 208 * @return EINVAL if the first parameter is NULL. 209 * @return EINVAL if the packet is not valid. 210 */ 211 int pq_add(packet_t **first, packet_t *packet, size_t order, size_t metric) 212 { 213 packet_t *item; 217 214 218 215 if (!first || !packet_is_valid(packet)) … … 252 249 * @param[in] first The first packet of the queue. 253 250 * @param[in] order The packet order value. 254 * @return sThe packet with the given order.255 * @return sNULL if the first packet is not valid.256 * @return sNULL if the packet is not found.257 */ 258 packet_t pq_find(packet_tpacket, size_t order)259 { 260 packet_t item;251 * @return The packet with the given order. 252 * @return NULL if the first packet is not valid. 253 * @return NULL if the packet is not found. 254 */ 255 packet_t *pq_find(packet_t *packet, size_t order) 256 { 257 packet_t *item; 261 258 262 259 if (!packet_is_valid(packet)) … … 278 275 * @param[in] packet The packet in the queue. 279 276 * @param[in] new_packet The new packet to be inserted. 280 * @return sEOK on success.281 * @return sEINVAL if etiher of the packets is invalid.282 */ 283 int pq_insert_after(packet_t packet, packet_tnew_packet)284 { 285 packet_t item;277 * @return EOK on success. 278 * @return EINVAL if etiher of the packets is invalid. 279 */ 280 int pq_insert_after(packet_t *packet, packet_t *new_packet) 281 { 282 packet_t *item; 286 283 287 284 if (!packet_is_valid(packet) || !packet_is_valid(new_packet)) … … 301 298 * 302 299 * @param[in] packet The packet to be detached. 303 * @return sThe next packet in the queue. If the packet is the first300 * @return The next packet in the queue. If the packet is the first 304 301 * one of the queue, this becomes the new first one. 305 * @return sNULL if there is no packet left.306 * @return sNULL if the packet is not valid.307 */ 308 packet_t pq_detach(packet_tpacket)309 { 310 packet_t next;311 packet_t previous;302 * @return NULL if there is no packet left. 303 * @return NULL if the packet is not valid. 304 */ 305 packet_t *pq_detach(packet_t *packet) 306 { 307 packet_t *next; 308 packet_t *previous; 312 309 313 310 if (!packet_is_valid(packet)) … … 331 328 * @param[in] order The packet order value. 332 329 * @param[in] metric The metric value of the packet. 333 * @return sEOK on success.334 * @return sEINVAL if the packet is invalid.335 */ 336 int pq_set_order(packet_t packet, size_t order, size_t metric)330 * @return EOK on success. 331 * @return EINVAL if the packet is invalid. 332 */ 333 int pq_set_order(packet_t *packet, size_t order, size_t metric) 337 334 { 338 335 if (!packet_is_valid(packet)) … … 349 346 * @param[out] order The packet order value. 350 347 * @param[out] metric The metric value of the packet. 351 * @return sEOK on success.352 * @return sEINVAL if the packet is invalid.353 */ 354 int pq_get_order(packet_t packet, size_t *order, size_t *metric)348 * @return EOK on success. 349 * @return EINVAL if the packet is invalid. 350 */ 351 int pq_get_order(packet_t *packet, size_t *order, size_t *metric) 355 352 { 356 353 if (!packet_is_valid(packet)) … … 375 372 * packets after its detachment. 376 373 */ 377 void pq_destroy(packet_t first, void (*packet_release)(packet_tpacket))378 { 379 packet_t actual;380 packet_t next;374 void pq_destroy(packet_t *first, void (*packet_release)(packet_t *packet)) 375 { 376 packet_t *actual; 377 packet_t *next; 381 378 382 379 actual = first; … … 394 391 * 395 392 * @param[in] packet The packet queue member. 396 * @return sThe next packet in the queue.397 * @return sNULL if there is no next packet.398 * @return sNULL if the packet is not valid.399 */ 400 packet_t pq_next(packet_tpacket)393 * @return The next packet in the queue. 394 * @return NULL if there is no next packet. 395 * @return NULL if the packet is not valid. 396 */ 397 packet_t *pq_next(packet_t *packet) 401 398 { 402 399 if (!packet_is_valid(packet)) … … 409 406 * 410 407 * @param[in] packet The packet queue member. 411 * @return sThe previous packet in the queue.412 * @return sNULL if there is no previous packet.413 * @return sNULL if the packet is not valid.414 */ 415 packet_t pq_previous(packet_tpacket)408 * @return The previous packet in the queue. 409 * @return NULL if there is no previous packet. 410 * @return NULL if the packet is not valid. 411 */ 412 packet_t *pq_previous(packet_t *packet) 416 413 { 417 414 if (!packet_is_valid(packet))
Note:
See TracChangeset
for help on using the changeset viewer.