Changeset 24ab58b3 in mainline for uspace/srv/net/nil/eth/eth.c


Ignore:
Timestamp:
2010-04-06T11:41:48Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
14f1db0
Parents:
4dd8529
Message:

more compact network startup messages (usually one line instead of multiple lines)
pass module name as an argument to nil_message() and friends
deeper cstyle changes (replace forward prototypes with proper extern declarations and static functions, change doxygen comments, stick more closely to the 80-column rule, no argument names in header files, spacing, comments, etc.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/nil/eth/eth.c

    r4dd8529 r24ab58b3  
    6060#include <adt/measured_strings.h>
    6161#include <packet/packet_client.h>
     62#include <nil_module.h>
    6263
    6364#include "eth.h"
     
    6667/** The module name.
    6768 */
    68 #define NAME    "Ethernet protocol"
     69#define NAME  "eth"
    6970
    7071/** Reserved packet prefix length.
     
    401402                        return index;
    402403                }
    403                 printf("New device registered:\n\tid\t= %d\n\tservice\t= %d\n\tMTU\t= %d\n\taddress\t= %X:%X:%X:%X:%X:%X\n\tflags\t= 0x%x\n", device->device_id, device->service, device->mtu, device->addr_data[0], device->addr_data[1], device->addr_data[2], device->addr_data[3], device->addr_data[4], device->addr_data[5], device->flags);
     404                printf("%s: Device registered (id: %d, service: %d: mtu: %d, "
     405                    "mac: %x:%x:%x:%x:%x:%x, flags: 0x%x)\n",
     406                    NAME, device->device_id, device->service, device->mtu,
     407                    device->addr_data[0], device->addr_data[1],
     408                    device->addr_data[2], device->addr_data[3],
     409                    device->addr_data[4], device->addr_data[5], device->flags);
    404410        }
    405411        fibril_rwlock_write_unlock(&eth_globals.devices_lock);
     
    571577                }
    572578        }
    573         printf("New protocol registered:\n\tprotocol\t= 0x%x\n\tservice\t= %d\n\tphone\t= %d\n", proto->protocol, proto->service, proto->phone);
     579       
     580        printf("%s: Protocol registered (protocol: %d, service: %d, phone: %d)\n",
     581            NAME, proto->protocol, proto->service, proto->phone);
     582       
    574583        fibril_rwlock_write_unlock(&eth_globals.protos_lock);
    575584        return EOK;
     
    704713}
    705714
    706 int nil_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
     715int nil_message(const char *name, ipc_callid_t callid, ipc_call_t *call,
     716    ipc_call_t *answer, int *answer_count)
     717{
    707718        ERROR_DECLARE;
    708 
     719       
    709720        measured_string_ref address;
    710721        packet_t packet;
     
    713724        size_t suffix;
    714725        size_t content;
    715 
    716 //      printf("message %d - %d\n", IPC_GET_METHOD(*call), NET_NIL_FIRST);
     726       
    717727        *answer_count = 0;
    718         switch(IPC_GET_METHOD(*call)){
     728        switch (IPC_GET_METHOD(*call)) {
    719729                case IPC_M_PHONE_HUNGUP:
    720730                        return EOK;
    721731                case NET_NIL_DEVICE:
    722                         return eth_device_message(IPC_GET_DEVICE(call), IPC_GET_SERVICE(call), IPC_GET_MTU(call));
     732                        return eth_device_message(IPC_GET_DEVICE(call),
     733                            IPC_GET_SERVICE(call), IPC_GET_MTU(call));
    723734                case NET_NIL_SEND:
    724                         ERROR_PROPAGATE(packet_translate(eth_globals.net_phone, &packet, IPC_GET_PACKET(call)));
    725                         return eth_send_message(IPC_GET_DEVICE(call), packet, IPC_GET_SERVICE(call));
     735                        ERROR_PROPAGATE(packet_translate(eth_globals.net_phone, &packet,
     736                            IPC_GET_PACKET(call)));
     737                        return eth_send_message(IPC_GET_DEVICE(call), packet,
     738                            IPC_GET_SERVICE(call));
    726739                case NET_NIL_PACKET_SPACE:
    727                         ERROR_PROPAGATE(eth_packet_space_message(IPC_GET_DEVICE(call), &addrlen, &prefix, &content, &suffix));
     740                        ERROR_PROPAGATE(eth_packet_space_message(IPC_GET_DEVICE(call),
     741                            &addrlen, &prefix, &content, &suffix));
    728742                        IPC_SET_ADDR(answer, addrlen);
    729743                        IPC_SET_PREFIX(answer, prefix);
     
    733747                        return EOK;
    734748                case NET_NIL_ADDR:
    735                         ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call), ETH_LOCAL_ADDR, &address));
     749                        ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call),
     750                            ETH_LOCAL_ADDR, &address));
    736751                        return measured_strings_reply(address, 1);
    737752                case NET_NIL_BROADCAST_ADDR:
    738                         ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call), ETH_BROADCAST_ADDR, &address));
     753                        ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call),
     754                            ETH_BROADCAST_ADDR, &address));
    739755                        return measured_strings_reply(address, 1);
    740756                case IPC_M_CONNECT_TO_ME:
    741                         return eth_register_message(NIL_GET_PROTO(call), IPC_GET_PHONE(call));
    742         }
     757                        return eth_register_message(NIL_GET_PROTO(call),
     758                            IPC_GET_PHONE(call));
     759        }
     760       
    743761        return ENOTSUP;
    744762}
     
    799817               
    800818                /* Process the message */
    801                 int res = nil_module_message(callid, &call, &answer, &answer_count);
     819                int res = nil_module_message(NAME, callid, &call, &answer,
     820                    &answer_count);
    802821               
    803822                /* End if said to either by the message or the processing result */
     
    823842        ERROR_DECLARE;
    824843       
    825         /* Print the module label */
    826         printf("Task %d - %s\n", task_get_id(), NAME);
    827        
    828844        /* Start the module */
    829         if (ERROR_OCCURRED(nil_module_start(nil_client_connection))) {
    830                 printf(" - ERROR %i\n", ERROR_CODE);
     845        if (ERROR_OCCURRED(nil_module_start(nil_client_connection)))
    831846                return ERROR_CODE;
    832         }
    833847       
    834848        return EOK;
Note: See TracChangeset for help on using the changeset viewer.