Ignore:
File:
1 edited

Legend:

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

    r46d4d9f r16ac756  
    6262
    6363/** Type definition of the packet map page. */
    64 typedef packet_t *packet_map_t[PACKET_MAP_SIZE];
     64typedef packet_t packet_map_t[PACKET_MAP_SIZE];
     65
     66/** Type definition of the packet map page pointer. */
     67typedef packet_map_t * packet_map_ref;
    6568
    6669/** Packet map.
     
    8285/** Initializes the packet map.
    8386 *
    84  * @return              EOK on success.
    85  * @return              ENOMEM if there is not enough memory left.
     87 * @returns             EOK on success.
     88 * @returns             ENOMEM if there is not enough memory left.
    8689 */
    8790int pm_init(void)
     
    101104 *
    102105 * @param[in] packet_id The packet identifier to be found.
    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;
     106 * @returns             The found packet reference.
     107 * @returns             NULL if the mapping does not exist.
     108 */
     109packet_t pm_find(packet_id_t packet_id)
     110{
     111        packet_map_ref map;
     112        packet_t packet;
    110113
    111114        if (!packet_id)
     
    130133 *
    131134 * @param[in] packet    The packet to be remembered.
    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;
     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 */
     140int pm_add(packet_t packet)
     141{
     142        packet_map_ref map;
    140143        int rc;
    141144
     
    151154        } else {
    152155                do {
    153                         map = (packet_map_t *) malloc(sizeof(packet_map_t));
     156                        map = (packet_map_ref) malloc(sizeof(packet_map_t));
    154157                        if (!map) {
    155158                                fibril_rwlock_write_unlock(&pm_globals.lock);
     
    177180        int count;
    178181        int index;
    179         packet_map_t *map;
    180         packet_t *packet;
     182        packet_map_ref map;
     183        packet_t packet;
    181184
    182185        fibril_rwlock_write_lock(&pm_globals.lock);
     
    205208 * @param[in] order     The packet order value.
    206209 * @param[in] metric    The metric value of the packet.
    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;
     210 * @returns             EOK on success.
     211 * @returns             EINVAL if the first parameter is NULL.
     212 * @returns             EINVAL if the packet is not valid.
     213 */
     214int pq_add(packet_t * first, packet_t packet, size_t order, size_t metric)
     215{
     216        packet_t item;
    214217
    215218        if (!first || !packet_is_valid(packet))
     
    249252 * @param[in] first     The first packet of the queue.
    250253 * @param[in] order     The packet order value.
    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;
     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 */
     258packet_t pq_find(packet_t packet, size_t order)
     259{
     260        packet_t item;
    258261
    259262        if (!packet_is_valid(packet))
     
    275278 * @param[in] packet    The packet in the queue.
    276279 * @param[in] new_packet The new packet to be inserted.
    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;
     280 * @returns             EOK on success.
     281 * @returns             EINVAL if etiher of the packets is invalid.
     282 */
     283int pq_insert_after(packet_t packet, packet_t new_packet)
     284{
     285        packet_t item;
    283286
    284287        if (!packet_is_valid(packet) || !packet_is_valid(new_packet))
     
    298301 *
    299302 * @param[in] packet    The packet to be detached.
    300  * @return              The next packet in the queue. If the packet is the first
     303 * @returns             The next packet in the queue. If the packet is the first
    301304 *                      one of the queue, this becomes the new first one.
    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;
     305 * @returns             NULL if there is no packet left.
     306 * @returns             NULL if the packet is not valid.
     307 */
     308packet_t pq_detach(packet_t packet)
     309{
     310        packet_t next;
     311        packet_t previous;
    309312
    310313        if (!packet_is_valid(packet))
     
    328331 * @param[in] order     The packet order value.
    329332 * @param[in] metric    The metric value of the packet.
    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)
     333 * @returns             EOK on success.
     334 * @returns             EINVAL if the packet is invalid.
     335 */
     336int pq_set_order(packet_t packet, size_t order, size_t metric)
    334337{
    335338        if (!packet_is_valid(packet))
     
    346349 * @param[out] order    The packet order value.
    347350 * @param[out] metric   The metric value of the packet.
    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)
     351 * @returns             EOK on success.
     352 * @returns             EINVAL if the packet is invalid.
     353 */
     354int pq_get_order(packet_t packet, size_t *order, size_t *metric)
    352355{
    353356        if (!packet_is_valid(packet))
     
    372375 *                      packets after its detachment.
    373376 */
    374 void pq_destroy(packet_t *first, void (*packet_release)(packet_t *packet))
    375 {
    376         packet_t *actual;
    377         packet_t *next;
     377void pq_destroy(packet_t first, void (*packet_release)(packet_t packet))
     378{
     379        packet_t actual;
     380        packet_t next;
    378381
    379382        actual = first;
     
    391394 *
    392395 * @param[in] packet    The packet queue member.
    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)
     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 */
     400packet_t pq_next(packet_t packet)
    398401{
    399402        if (!packet_is_valid(packet))
     
    406409 *
    407410 * @param[in] packet    The packet queue member.
    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)
     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 */
     415packet_t pq_previous(packet_t packet)
    413416{
    414417        if (!packet_is_valid(packet))
Note: See TracChangeset for help on using the changeset viewer.