Changeset eb522e8 in mainline for uspace/lib/c/generic/net/packet.c


Ignore:
Timestamp:
2011-06-01T08:43:42Z (14 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
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.
Message:

Huuuuuge merge from development - all the work actually :)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/net/packet.c

    r9e2e715 reb522e8  
    6262
    6363/** 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;
     64typedef packet_t *packet_map_t[PACKET_MAP_SIZE];
    6865
    6966/** Packet map.
     
    8582/** Initializes the packet map.
    8683 *
    87  * @returns             EOK on success.
    88  * @returns             ENOMEM if there is not enough memory left.
     84 * @return              EOK on success.
     85 * @return              ENOMEM if there is not enough memory left.
    8986 */
    9087int pm_init(void)
     
    104101 *
    105102 * @param[in] packet_id The packet identifier to be found.
    106  * @returns             The found packet reference.
    107  * @returns             NULL if the mapping does not exist.
    108  */
    109 packet_t pm_find(packet_id_t packet_id)
    110 {
    111         packet_map_ref map;
    112         packet_t packet;
     103 * @return              The found packet reference.
     104 * @return              NULL if the mapping does not exist.
     105 */
     106packet_t *pm_find(packet_id_t packet_id)
     107{
     108        packet_map_t *map;
     109        packet_t *packet;
    113110
    114111        if (!packet_id)
     
    133130 *
    134131 * @param[in] packet    The packet to be remembered.
    135  * @returns             EOK on success.
    136  * @returns             EINVAL if the packet is not valid.
    137  * @returns             EINVAL if the packet map is not initialized.
    138  * @returns             ENOMEM if there is not enough memory left.
    139  */
    140 int pm_add(packet_t packet)
    141 {
    142         packet_map_ref map;
     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 */
     137int pm_add(packet_t *packet)
     138{
     139        packet_map_t *map;
    143140        int rc;
    144141
     
    154151        } else {
    155152                do {
    156                         map = (packet_map_ref) malloc(sizeof(packet_map_t));
     153                        map = (packet_map_t *) malloc(sizeof(packet_map_t));
    157154                        if (!map) {
    158155                                fibril_rwlock_write_unlock(&pm_globals.lock);
     
    180177        int count;
    181178        int index;
    182         packet_map_ref map;
    183         packet_t packet;
     179        packet_map_t *map;
     180        packet_t *packet;
    184181
    185182        fibril_rwlock_write_lock(&pm_globals.lock);
     
    193190                }
    194191        }
    195         gpm_destroy(&pm_globals.packet_map);
    196         // leave locked
     192        gpm_destroy(&pm_globals.packet_map, free);
     193        /* leave locked */
    197194}
    198195
     
    208205 * @param[in] order     The packet order value.
    209206 * @param[in] metric    The metric value of the packet.
    210  * @returns             EOK on success.
    211  * @returns             EINVAL if the first parameter is NULL.
    212  * @returns             EINVAL if the packet is not valid.
    213  */
    214 int pq_add(packet_t * first, packet_t packet, 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 */
     211int pq_add(packet_t **first, packet_t *packet, size_t order, size_t metric)
     212{
     213        packet_t *item;
    217214
    218215        if (!first || !packet_is_valid(packet))
     
    252249 * @param[in] first     The first packet of the queue.
    253250 * @param[in] order     The packet order value.
    254  * @returns             The packet with the given order.
    255  * @returns             NULL if the first packet is not valid.
    256  * @returns             NULL if the packet is not found.
    257  */
    258 packet_t pq_find(packet_t packet, 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 */
     255packet_t *pq_find(packet_t *packet, size_t order)
     256{
     257        packet_t *item;
    261258
    262259        if (!packet_is_valid(packet))
     
    278275 * @param[in] packet    The packet in the queue.
    279276 * @param[in] new_packet The new packet to be inserted.
    280  * @returns             EOK on success.
    281  * @returns             EINVAL if etiher of the packets is invalid.
    282  */
    283 int pq_insert_after(packet_t packet, packet_t new_packet)
    284 {
    285         packet_t item;
     277 * @return              EOK on success.
     278 * @return              EINVAL if etiher of the packets is invalid.
     279 */
     280int pq_insert_after(packet_t *packet, packet_t *new_packet)
     281{
     282        packet_t *item;
    286283
    287284        if (!packet_is_valid(packet) || !packet_is_valid(new_packet))
     
    301298 *
    302299 * @param[in] packet    The packet to be detached.
    303  * @returns             The next packet in the queue. If the packet is the first
     300 * @return              The next packet in the queue. If the packet is the first
    304301 *                      one of the queue, this becomes the new first one.
    305  * @returns             NULL if there is no packet left.
    306  * @returns             NULL if the packet is not valid.
    307  */
    308 packet_t pq_detach(packet_t packet)
    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 */
     305packet_t *pq_detach(packet_t *packet)
     306{
     307        packet_t *next;
     308        packet_t *previous;
    312309
    313310        if (!packet_is_valid(packet))
     
    331328 * @param[in] order     The packet order value.
    332329 * @param[in] metric    The metric value of the packet.
    333  * @returns             EOK on success.
    334  * @returns             EINVAL 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 */
     333int pq_set_order(packet_t *packet, size_t order, size_t metric)
    337334{
    338335        if (!packet_is_valid(packet))
     
    349346 * @param[out] order    The packet order value.
    350347 * @param[out] metric   The metric value of the packet.
    351  * @returns             EOK on success.
    352  * @returns             EINVAL 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 */
     351int pq_get_order(packet_t *packet, size_t *order, size_t *metric)
    355352{
    356353        if (!packet_is_valid(packet))
     
    375372 *                      packets after its detachment.
    376373 */
    377 void pq_destroy(packet_t first, void (*packet_release)(packet_t packet))
    378 {
    379         packet_t actual;
    380         packet_t next;
     374void pq_destroy(packet_t *first, void (*packet_release)(packet_t *packet))
     375{
     376        packet_t *actual;
     377        packet_t *next;
    381378
    382379        actual = first;
     
    394391 *
    395392 * @param[in] packet    The packet queue member.
    396  * @returns             The next packet in the queue.
    397  * @returns             NULL if there is no next packet.
    398  * @returns             NULL if the packet is not valid.
    399  */
    400 packet_t pq_next(packet_t packet)
     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 */
     397packet_t *pq_next(packet_t *packet)
    401398{
    402399        if (!packet_is_valid(packet))
     
    409406 *
    410407 * @param[in] packet    The packet queue member.
    411  * @returns             The previous packet in the queue.
    412  * @returns             NULL if there is no previous packet.
    413  * @returns             NULL if the packet is not valid.
    414  */
    415 packet_t pq_previous(packet_t packet)
     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 */
     412packet_t *pq_previous(packet_t *packet)
    416413{
    417414        if (!packet_is_valid(packet))
Note: See TracChangeset for help on using the changeset viewer.