Changeset 24ab58b3 in mainline for uspace/srv/net/il/ip/ip.c


Ignore:
Timestamp:
2010-04-06T11:41:48Z (15 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/il/ip/ip.c

    r4dd8529 r24ab58b3  
    7979/** IP module name.
    8080 */
    81 #define NAME    "IP protocol"
     81#define NAME  "ip"
    8282
    8383/** IP version 4.
     
    430430        ip_route_ref route;
    431431        int index;
    432         char * data;
    433432
    434433        ip_netif = (ip_netif_ref) malloc(sizeof(ip_netif_t));
     
    454453        }
    455454        // print the settings
    456         printf("New device registered:\n\tid\t= %d\n\tphone\t= %d\n\tIPV\t= %d\n", ip_netif->device_id, ip_netif->phone, ip_netif->ipv);
    457         printf("\tconfiguration\t= %s\n", ip_netif->dhcp ? "dhcp" : "static");
     455        printf("%s: Device registered (id: %d, phone: %d, ipv: %d, conf: %s)\n",
     456            NAME, ip_netif->device_id, ip_netif->phone, ip_netif->ipv,
     457            ip_netif->dhcp ? "dhcp" : "static");
     458       
    458459        // TODO ipv6 addresses
    459         data = (char *) malloc(INET_ADDRSTRLEN);
    460         if(data){
    461                 for(index = 0; index < ip_routes_count(&ip_netif->routes); ++ index){
    462                         route = ip_routes_get_index(&ip_netif->routes, index);
    463                         if(route){
    464                                 printf("\tRouting %d:\n", index);
    465                                 inet_ntop(AF_INET, (uint8_t *) &route->address.s_addr, data, INET_ADDRSTRLEN);
    466                                 printf("\t\taddress\t= %s\n", data);
    467                                 inet_ntop(AF_INET, (uint8_t *) &route->netmask.s_addr, data, INET_ADDRSTRLEN);
    468                                 printf("\t\tnetmask\t= %s\n", data);
    469                                 inet_ntop(AF_INET, (uint8_t *) &route->gateway.s_addr, data, INET_ADDRSTRLEN);
    470                                 printf("\t\tgateway\t= %s\n", data);
    471                         }
    472                 }
    473                 inet_ntop(AF_INET, (uint8_t *) &ip_netif->broadcast.s_addr, data, INET_ADDRSTRLEN);
    474                 printf("\t\tbroadcast\t= %s\n", data);
    475                 free(data);
    476         }
     460       
     461        char address[INET_ADDRSTRLEN];
     462        char netmask[INET_ADDRSTRLEN];
     463        char gateway[INET_ADDRSTRLEN];
     464       
     465        for (index = 0; index < ip_routes_count(&ip_netif->routes); ++ index){
     466                route = ip_routes_get_index(&ip_netif->routes, index);
     467                if (route) {
     468                        inet_ntop(AF_INET, (uint8_t *) &route->address.s_addr, address, INET_ADDRSTRLEN);
     469                        inet_ntop(AF_INET, (uint8_t *) &route->netmask.s_addr, netmask, INET_ADDRSTRLEN);
     470                        inet_ntop(AF_INET, (uint8_t *) &route->gateway.s_addr, gateway, INET_ADDRSTRLEN);
     471                        printf("%s: Route %d (address: %s, netmask: %s, gateway: %s)\n",
     472                            NAME, index, address, netmask, gateway);
     473                }
     474        }
     475       
     476        inet_ntop(AF_INET, (uint8_t *) &ip_netif->broadcast.s_addr, address, INET_ADDRSTRLEN);
     477        printf("%s: Broadcast (%s)\n", NAME, address);
     478       
    477479        fibril_rwlock_write_unlock(&ip_globals.netifs_lock);
    478480        return EOK;
     
    595597        }
    596598        netif->packet_dimension.content = mtu;
    597         printf("ip - device %d changed mtu to %d\n\n", device_id, mtu);
     599        printf("%s: Device %d changed MTU to %d\n", NAME, device_id, mtu);
    598600        fibril_rwlock_write_unlock(&ip_globals.netifs_lock);
    599601        return EOK;
     
    611613        }
    612614        netif->state = state;
    613         printf("ip - device %d changed state to %d\n\n", device_id, state);
     615        printf("%s: Device %d changed state to %d\n", NAME, device_id, state);
    614616        fibril_rwlock_write_unlock(&ip_globals.netifs_lock);
    615617        return EOK;
     
    646648                return index;
    647649        }
    648         printf("New protocol registered:\n\tprotocol\t= %d\n\tphone\t= %d\n", proto->protocol, proto->phone);
     650       
     651        printf("%s: Protocol registered (protocol: %d, phone: %d)\n",
     652            NAME, proto->protocol, proto->phone);
     653       
    649654        fibril_rwlock_write_unlock(&ip_globals.protos_lock);
    650655        return EOK;
     
    16771682        ERROR_DECLARE;
    16781683       
    1679         /* Print the module label */
    1680         printf("Task %d - %s\n", task_get_id(), NAME);
    1681        
    16821684        /* Start the module */
    1683         if (ERROR_OCCURRED(il_module_start(il_client_connection))) {
    1684                 printf(" - ERROR %i\n", ERROR_CODE);
     1685        if (ERROR_OCCURRED(il_module_start(il_client_connection)))
    16851686                return ERROR_CODE;
    1686         }
    16871687       
    16881688        return EOK;
Note: See TracChangeset for help on using the changeset viewer.