Changeset 977fcea in mainline for uspace/srv/net/netif/lo/lo.c


Ignore:
Timestamp:
2011-01-14T10:11:11Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f9dd44d
Parents:
0bd2879 (diff), 6610565b (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:

development branch merge

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/netif/lo/lo.c

    r0bd2879 r977fcea  
    4949#include <net/device.h>
    5050#include <nil_interface.h>
    51 #include <netif_interface.h>
    52 #include <netif_local.h>
     51#include <netif_skel.h>
    5352
    5453/** Default hardware address. */
    55 #define DEFAULT_ADDR            "\0\0\0\0\0\0"
     54#define DEFAULT_ADDR  0
    5655
    5756/** Default address length. */
    58 #define DEFAULT_ADDR_LEN        (sizeof(DEFAULT_ADDR) / sizeof(char))
     57#define DEFAULT_ADDR_LEN  6
    5958
    6059/** Loopback module name. */
     
    6261
    6362/** Network interface global data. */
    64 netif_globals_t netif_globals;
     63netif_globals_t netif_globals;
    6564
    6665int netif_specific_message(ipc_callid_t callid, ipc_call_t *call,
    67     ipc_call_t *answer, int *answer_count)
     66    ipc_call_t *answer, size_t *count)
    6867{
    6968        return ENOTSUP;
     
    7473        if (!address)
    7574                return EBADMEM;
    76 
    77         address->value = str_dup(DEFAULT_ADDR);
     75       
     76        uint8_t *addr = (uint8_t *) malloc(DEFAULT_ADDR_LEN);
     77        memset(addr, DEFAULT_ADDR, DEFAULT_ADDR_LEN);
     78       
     79        address->value = addr;
    7880        address->length = DEFAULT_ADDR_LEN;
    79 
     81       
    8082        return EOK;
    8183}
     
    169171}
    170172
    171 int netif_probe_message(device_id_t device_id, int irq, uintptr_t io)
     173int netif_probe_message(device_id_t device_id, int irq, void *io)
    172174{
    173175        netif_device_t *device;
     
    230232}
    231233
    232 /** Default thread for new connections.
    233  *
    234  * @param[in] iid       The initial message identifier.
    235  * @param[in] icall     The initial message call structure.
    236  */
    237 static void netif_client_connection(ipc_callid_t iid, ipc_call_t *icall)
    238 {
    239         /*
    240          * Accept the connection
    241          *  - Answer the first IPC_M_CONNECT_ME_TO call.
    242          */
    243         ipc_answer_0(iid, EOK);
    244        
    245         while (true) {
    246                 ipc_call_t answer;
    247                 int answer_count;
    248                
    249                 /* Clear the answer structure */
    250                 refresh_answer(&answer, &answer_count);
    251                
    252                 /* Fetch the next message */
    253                 ipc_call_t call;
    254                 ipc_callid_t callid = async_get_call(&call);
    255                
    256                 /* Process the message */
    257                 int res = netif_module_message(NAME, callid, &call, &answer,
    258                     &answer_count);
    259                
    260                 /*
    261                  * End if told to either by the message or the processing
    262                  * result.
    263                  */
    264                 if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) ||
    265                     (res == EHANGUP))
    266                         return;
    267                
    268                 /* Answer the message */
    269                 answer_call(callid, res, &answer, answer_count);
    270         }
    271 }
    272 
    273234int main(int argc, char *argv[])
    274235{
    275         int rc;
    276        
    277236        /* Start the module */
    278         rc = netif_module_start(netif_client_connection);
    279         return rc;
     237        return netif_module_start();
    280238}
    281239
Note: See TracChangeset for help on using the changeset viewer.