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


Ignore:
Timestamp:
2010-04-23T21:42:26Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6c39a907
Parents:
38aaacc2 (diff), 80badbe (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:

Merge mainline changes.

File:
1 edited

Legend:

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

    r38aaacc2 rf4f866c  
    5151#include <nil_interface.h>
    5252#include <nil_messages.h>
    53 #include <netif.h>
    54 #include <netif_module.h>
     53#include <netif_interface.h>
     54#include <netif_local.h>
    5555
    5656/** Default hardware address.
     
    6464/** Loopback module name.
    6565 */
    66 #define NAME    "lo - loopback interface"
     66#define NAME  "lo"
    6767
    6868/** Network interface global data.
     
    7676 *  @returns EOK otherwise.
    7777 */
    78 int change_state_message(device_ref device, device_state_t state);
     78int change_state_message(netif_device_t * device, device_state_t state);
    7979
    8080/** Creates and returns the loopback network interface structure.
     
    8585 *  @returns ENOMEM if there is not enough memory left.
    8686 */
    87 int create(device_id_t device_id, device_ref * device);
     87int create(device_id_t device_id, netif_device_t * * device);
    8888
    8989int netif_specific_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
     
    103103        ERROR_DECLARE;
    104104
    105         device_ref device;
     105        netif_device_t * device;
    106106
    107107        if(! stats){
     
    113113}
    114114
    115 int change_state_message(device_ref device, device_state_t state){
    116         if(device->state != state){
     115int change_state_message(netif_device_t * device, device_state_t state)
     116{
     117        if (device->state != state) {
    117118                device->state = state;
    118                 printf("State changed to %s\n", (state == NETIF_ACTIVE) ? "ACTIVE" : "STOPPED");
     119               
     120                printf("%s: State changed to %s\n", NAME,
     121                    (state == NETIF_ACTIVE) ? "active" : "stopped");
     122               
    119123                return state;
    120124        }
    121         return EOK;
    122 }
    123 
    124 int create(device_id_t device_id, device_ref * device){
     125       
     126        return EOK;
     127}
     128
     129int create(device_id_t device_id, netif_device_t * * device){
    125130        int index;
    126131
    127         if(device_map_count(&netif_globals.device_map) > 0){
     132        if(netif_device_map_count(&netif_globals.device_map) > 0){
    128133                return EXDEV;
    129134        }else{
    130                 *device = (device_ref) malloc(sizeof(device_t));
     135                *device = (netif_device_t *) malloc(sizeof(netif_device_t));
    131136                if(!(*device)){
    132137                        return ENOMEM;
     
    141146                (** device).nil_phone = -1;
    142147                (** device).state = NETIF_STOPPED;
    143                 index = device_map_add(&netif_globals.device_map, (** device).device_id, * device);
     148                index = netif_device_map_add(&netif_globals.device_map, (** device).device_id, * device);
    144149                if(index < 0){
    145150                        free(*device);
     
    161166        ERROR_DECLARE;
    162167
    163         device_ref device;
     168        netif_device_t * device;
    164169
    165170        // create a new device
    166171        ERROR_PROPAGATE(create(device_id, &device));
    167172        // print the settings
    168         printf("New device created:\n\tid\t= %d\n", device->device_id);
     173        printf("%s: Device created (id: %d)\n", NAME, device->device_id);
    169174        return EOK;
    170175}
     
    173178        ERROR_DECLARE;
    174179
    175         device_ref device;
     180        netif_device_t * device;
    176181        size_t length;
    177182        packet_t next;
     
    199204}
    200205
    201 int netif_start_message(device_ref device){
     206int netif_start_message(netif_device_t * device){
    202207        return change_state_message(device, NETIF_ACTIVE);
    203208}
    204209
    205 int netif_stop_message(device_ref device){
     210int netif_stop_message(netif_device_t * device){
    206211        return change_state_message(device, NETIF_STOPPED);
    207212}
    208213
    209 #ifdef CONFIG_NETWORKING_modular
    210 
    211 #include <netif_standalone.h>
    212 
    213214/** Default thread for new connections.
    214215 *
    215  *  @param[in] iid The initial message identifier.
    216  *  @param[in] icall The initial message call structure.
    217  *
    218  */
    219 static void netif_client_connection(ipc_callid_t iid, ipc_call_t * icall)
     216 * @param[in] iid The initial message identifier.
     217 * @param[in] icall The initial message call structure.
     218 *
     219 */
     220static void netif_client_connection(ipc_callid_t iid, ipc_call_t *icall)
    220221{
    221222        /*
     
    237238               
    238239                /* Process the message */
    239                 int res = netif_module_message(callid, &call, &answer, &answer_count);
     240                int res = netif_module_message(NAME, callid, &call, &answer,
     241                    &answer_count);
    240242               
    241243                /* End if said to either by the message or the processing result */
     
    248250}
    249251
    250 /** Starts the module.
    251  *
    252  *  @param argc The count of the command line arguments. Ignored parameter.
    253  *  @param argv The command line parameters. Ignored parameter.
    254  *
    255  *  @returns EOK on success.
    256  *  @returns Other error codes as defined for each specific module start function.
    257  *
    258  */
    259252int main(int argc, char *argv[])
    260253{
    261254        ERROR_DECLARE;
    262255       
    263         /* Print the module label */
    264         printf("Task %d - %s\n", task_get_id(), NAME);
    265        
    266256        /* Start the module */
    267         if (ERROR_OCCURRED(netif_module_start(netif_client_connection))) {
    268                 printf(" - ERROR %i\n", ERROR_CODE);
     257        if (ERROR_OCCURRED(netif_module_start(netif_client_connection)))
    269258                return ERROR_CODE;
    270         }
    271        
    272         return EOK;
    273 }
    274 
    275 #endif /* CONFIG_NETWORKING_modular */
     259       
     260        return EOK;
     261}
    276262
    277263/** @}
Note: See TracChangeset for help on using the changeset viewer.