Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/loopip/loopip.c

    r5a6cc679 ra35b458  
    4545#include <stdio.h>
    4646#include <stdlib.h>
     47#include <str.h>
    4748#include <task.h>
    4849
     
    7677typedef struct {
    7778        link_t link;
    78        
     79
    7980        /* XXX Version should be part of SDU */
    8081        ip_ver_t ver;
     
    8990                rqueue_entry_t *rqe =
    9091                    list_get_instance(link, rqueue_entry_t, link);
    91                
     92
    9293                (void) iplink_ev_recv(&loopip_iplink, &rqe->sdu, rqe->ver);
    93                
     94
    9495                free(rqe->sdu.data);
    9596                free(rqe);
    9697        }
    97        
     98
    9899        return 0;
    99100}
     
    102103{
    103104        async_set_fallback_port_handler(loopip_client_conn, NULL);
    104        
     105
    105106        errno_t rc = loc_server_register(NAME);
    106107        if (rc != EOK) {
     
    108109                return rc;
    109110        }
    110        
     111
    111112        iplink_srv_init(&loopip_iplink);
    112113        loopip_iplink.ops = &loopip_iplink_ops;
    113114        loopip_iplink.arg = NULL;
    114        
     115
    115116        prodcons_initialize(&loopip_rcv_queue);
    116        
     117
    117118        const char *svc_name = "net/loopback";
    118119        service_id_t sid;
     
    123124                return rc;
    124125        }
    125        
     126
    126127        category_id_t iplink_cat;
    127128        rc = loc_category_get_id("iplink", &iplink_cat, IPC_FLAG_BLOCKING);
     
    130131                return rc;
    131132        }
    132        
     133
    133134        rc = loc_service_add_to_cat(sid, iplink_cat);
    134135        if (rc != EOK) {
     
    137138                return rc;
    138139        }
    139        
     140
    140141        fid_t fid = fibril_create(loopip_recv_fibril, NULL);
    141142        if (fid == 0)
    142143                return ENOMEM;
    143        
     144
    144145        fibril_add_ready(fid);
    145        
     146
    146147        return EOK;
    147148}
     
    168169{
    169170        log_msg(LOG_DEFAULT, LVL_DEBUG, "loopip_send()");
    170        
     171
    171172        rqueue_entry_t *rqe = calloc(1, sizeof(rqueue_entry_t));
    172173        if (rqe == NULL)
    173174                return ENOMEM;
    174        
     175
    175176        /*
    176177         * Clone SDU
     
    182183                return ENOMEM;
    183184        }
    184        
     185
    185186        memcpy(rqe->sdu.data, sdu->data, sdu->size);
    186187        rqe->sdu.size = sdu->size;
    187        
     188
    188189        /*
    189190         * Insert to receive queue
    190191         */
    191192        prodcons_produce(&loopip_rcv_queue, &rqe->link);
    192        
     193
    193194        return EOK;
    194195}
     
    197198{
    198199        log_msg(LOG_DEFAULT, LVL_DEBUG, "loopip6_send()");
    199        
     200
    200201        rqueue_entry_t *rqe = calloc(1, sizeof(rqueue_entry_t));
    201202        if (rqe == NULL)
    202203                return ENOMEM;
    203        
     204
    204205        /*
    205206         * Clone SDU
     
    211212                return ENOMEM;
    212213        }
    213        
     214
    214215        memcpy(rqe->sdu.data, sdu->data, sdu->size);
    215216        rqe->sdu.size = sdu->size;
    216        
     217
    217218        /*
    218219         * Insert to receive queue
    219220         */
    220221        prodcons_produce(&loopip_rcv_queue, &rqe->link);
    221        
     222
    222223        return EOK;
    223224}
     
    249250{
    250251        printf("%s: HelenOS loopback IP link provider\n", NAME);
    251        
     252
    252253        errno_t rc = log_init(NAME);
    253254        if (rc != EOK) {
     
    255256                return rc;
    256257        }
    257        
     258
    258259        rc = loopip_init();
    259260        if (rc != EOK) {
     
    261262                return rc;
    262263        }
    263        
     264
    264265        printf("%s: Accepting connections.\n", NAME);
    265266        task_retval(0);
    266267        async_manager();
    267        
     268
    268269        /* Not reached */
    269270        return 0;
Note: See TracChangeset for help on using the changeset viewer.