Changeset 14f1db0 in mainline for uspace/srv/net/il


Ignore:
Timestamp:
2010-04-09T12:54:57Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1caa3c2
Parents:
24ab58b3
Message:

networking overhaul:

  • separation of conserns
  • removal of (almost all) overlaping symbols, libnetif is not needed anymore
  • again, it is possible to build the networking in multiple architecture configurations (however, currently only the bundling netif and nil layers is supported, more to come)
  • code style updates and fixes (still a huge amount of work to do)
Location:
uspace/srv/net/il
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/il/arp/arp.c

    r24ab58b3 r14f1db0  
    5757#include <packet/packet.h>
    5858#include <packet/packet_client.h>
     59#include <packet_remote.h>
    5960#include <il_messages.h>
     61#include <il_interface.h>
     62#include <il_local.h>
    6063#include <arp_messages.h>
    6164
     
    370373}
    371374
    372 int arp_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
     375int arp_message_standalone(ipc_callid_t callid, ipc_call_t *call,
     376    ipc_call_t *answer, int *answer_count)
     377{
    373378        ERROR_DECLARE;
    374 
     379       
    375380        measured_string_ref address;
    376381        measured_string_ref translation;
     
    378383        packet_t packet;
    379384        packet_t next;
    380 
    381 //      printf("message %d - %d\n", IPC_GET_METHOD(*call), NET_ARP_FIRST);
     385       
    382386        *answer_count = 0;
    383         switch(IPC_GET_METHOD(*call)){
     387        switch (IPC_GET_METHOD(*call)) {
    384388                case IPC_M_PHONE_HUNGUP:
    385389                        return EOK;
     
    418422                        return EOK;
    419423                case NET_IL_RECEIVED:
    420                         if(! ERROR_OCCURRED(packet_translate(arp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){
     424                        if(! ERROR_OCCURRED(packet_translate_remote(arp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){
    421425                                fibril_rwlock_read_lock(&arp_globals.lock);
    422426                                do{
     
    424428                                        ERROR_CODE = arp_receive_message(IPC_GET_DEVICE(call), packet);
    425429                                        if(ERROR_CODE != 1){
    426                                                 pq_release(arp_globals.net_phone, packet_get_id(packet));
     430                                                pq_release_remote(arp_globals.net_phone, packet_get_id(packet));
    427431                                        }
    428432                                        packet = next;
     
    434438                        return arp_mtu_changed_message(IPC_GET_DEVICE(call), IPC_GET_MTU(call));
    435439        }
     440       
    436441        return ENOTSUP;
    437442}
     
    570575                return NULL;
    571576        }
    572         packet = packet_get_4(arp_globals.net_phone, device->packet_dimension.addr_len, device->packet_dimension.prefix, length, device->packet_dimension.suffix);
     577        packet = packet_get_4_remote(arp_globals.net_phone, device->packet_dimension.addr_len, device->packet_dimension.prefix, length, device->packet_dimension.suffix);
    573578        if(! packet){
    574579                return NULL;
     
    576581        header = (arp_header_ref) packet_suffix(packet, length);
    577582        if(! header){
    578                 pq_release(arp_globals.net_phone, packet_get_id(packet));
     583                pq_release_remote(arp_globals.net_phone, packet_get_id(packet));
    579584                return NULL;
    580585        }
     
    593598        memcpy(((uint8_t *) header) + length, target->value, target->length);
    594599        if(packet_set_addr(packet, (uint8_t *) device->addr->value, (uint8_t *) device->broadcast_addr->value, CONVERT_SIZE(char, uint8_t, device->addr->length)) != EOK){
    595                 pq_release(arp_globals.net_phone, packet_get_id(packet));
     600                pq_release_remote(arp_globals.net_phone, packet_get_id(packet));
    596601                return NULL;
    597602        }
     
    619624        }
    620625}
    621 
    622 #ifdef CONFIG_NETWORKING_modular
    623 
    624 #include <il_standalone.h>
    625626
    626627/** Default thread for new connections.
     
    650651               
    651652                /* Process the message */
    652                 int res = il_module_message(callid, &call, &answer, &answer_count);
     653                int res = il_module_message_standalone(callid, &call, &answer,
     654                    &answer_count);
    653655               
    654656                /* End if said to either by the message or the processing result */
     
    675677       
    676678        /* Start the module */
    677         if (ERROR_OCCURRED(il_module_start(il_client_connection)))
     679        if (ERROR_OCCURRED(il_module_start_standalone(il_client_connection)))
    678680                return ERROR_CODE;
    679681       
     
    681683}
    682684
    683 #endif /* CONFIG_NETWORKING_modular */
    684 
    685685/** @}
    686686 */
  • uspace/srv/net/il/arp/arp_module.c

    r24ab58b3 r14f1db0  
    4848#include <net_interface.h>
    4949#include <packet/packet.h>
    50 #include <il_standalone.h>
     50#include <il_local.h>
    5151
    5252#include "arp.h"
     
    6565 *  @returns Other error codes as defined for the arp_message() function.
    6666 */
    67 int il_module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
    68         return arp_message(callid, call, answer, answer_count);
     67int il_module_message_standalone(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
     68        return arp_message_standalone(callid, call, answer, answer_count);
    6969}
    7070
     
    7676 *  @returns Other error codes as defined for the REGISTER_ME() macro function.
    7777 */
    78 int il_module_start(async_client_conn_t client_connection){
     78int il_module_start_standalone(async_client_conn_t client_connection){
    7979        ERROR_DECLARE;
    80 
    81         ipcarg_t phonehash;
    82 
     80       
    8381        async_set_client_connection(client_connection);
    8482        arp_globals.net_phone = net_connect_module(SERVICE_NETWORKING);
    8583        ERROR_PROPAGATE(pm_init());
    86         if(ERROR_OCCURRED(arp_initialize(client_connection))
    87                 || ERROR_OCCURRED(REGISTER_ME(SERVICE_ARP, &phonehash))){
     84       
     85        ipcarg_t phonehash;
     86        if (ERROR_OCCURRED(arp_initialize(client_connection))
     87            || ERROR_OCCURRED(REGISTER_ME(SERVICE_ARP, &phonehash))) {
    8888                pm_destroy();
    8989                return ERROR_CODE;
    9090        }
    91 
     91       
    9292        async_manager();
    93 
     93       
    9494        pm_destroy();
    9595        return EOK;
  • uspace/srv/net/il/arp/arp_module.h

    r24ab58b3 r14f1db0  
    5858 *  @see IS_NET_ARP_MESSAGE()
    5959 */
    60 int arp_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
     60int arp_message_standalone(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
    6161
    6262#endif
  • uspace/srv/net/il/ip/ip.c

    r24ab58b3 r14f1db0  
    6969#include <adt/module_map.h>
    7070#include <packet/packet_client.h>
     71#include <packet_remote.h>
    7172#include <nil_messages.h>
    7273#include <il_messages.h>
     74#include <il_local.h>
     75#include <ip_local.h>
    7376
    7477#include "ip.h"
     
    424427}
    425428
    426 int ip_device_req(int il_phone, device_id_t device_id, services_t netif){
     429int ip_device_req_local(int il_phone, device_id_t device_id, services_t netif){
    427430        ERROR_DECLARE;
    428431
     
    656659}
    657660
    658 int ip_send_msg(int il_phone, device_id_t device_id, packet_t packet, services_t sender, services_t error){
     661int ip_send_msg_local(int il_phone, device_id_t device_id, packet_t packet, services_t sender, services_t error){
    659662        ERROR_DECLARE;
    660663
     
    782785//                      sleep(1);
    783786//                      ERROR_PROPAGATE(arp_translate_req(netif->arp->phone, netif->device_id, SERVICE_IP, &destination, &translation, &data));
    784                         pq_release(ip_globals.net_phone, packet_get_id(packet));
     787                        pq_release_remote(ip_globals.net_phone, packet_get_id(packet));
    785788                        return ERROR_CODE;
    786789                }
     
    799802        }else translation = NULL;
    800803        if(ERROR_OCCURRED(ip_prepare_packet(src, dest, packet, translation))){
    801                 pq_release(ip_globals.net_phone, packet_get_id(packet));
     804                pq_release_remote(ip_globals.net_phone, packet_get_id(packet));
    802805        }else{
    803806                packet = ip_split_packet(packet, netif->packet_dimension.prefix, netif->packet_dimension.content, netif->packet_dimension.suffix, netif->packet_dimension.addr_len, error);
     
    891894}
    892895
    893 int ip_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
     896int ip_message_standalone(ipc_callid_t callid, ipc_call_t *call,
     897    ipc_call_t *answer, int * answer_count)
     898{
    894899        ERROR_DECLARE;
    895 
     900       
    896901        packet_t packet;
    897         struct sockaddr * addr;
     902        struct sockaddr *addr;
    898903        size_t addrlen;
    899904        size_t prefix;
    900905        size_t suffix;
    901906        size_t content;
    902         ip_pseudo_header_ref header;
     907        void *header;
    903908        size_t headerlen;
    904909        device_id_t device_id;
    905 
     910       
    906911        *answer_count = 0;
    907         switch(IPC_GET_METHOD(*call)){
     912        switch (IPC_GET_METHOD(*call)) {
    908913                case IPC_M_PHONE_HUNGUP:
    909914                        return EOK;
    910915                case NET_IL_DEVICE:
    911                         return ip_device_req(0, IPC_GET_DEVICE(call), IPC_GET_SERVICE(call));
     916                        return ip_device_req_local(0, IPC_GET_DEVICE(call),
     917                            IPC_GET_SERVICE(call));
    912918                case IPC_M_CONNECT_TO_ME:
    913                         return ip_register(IL_GET_PROTO(call), IL_GET_SERVICE(call), IPC_GET_PHONE(call), NULL);
     919                        return ip_register(IL_GET_PROTO(call), IL_GET_SERVICE(call),
     920                            IPC_GET_PHONE(call), NULL);
    914921                case NET_IL_SEND:
    915                         ERROR_PROPAGATE(packet_translate(ip_globals.net_phone, &packet, IPC_GET_PACKET(call)));
    916                         return ip_send_msg(0, IPC_GET_DEVICE(call), packet, 0, IPC_GET_ERROR(call));
     922                        ERROR_PROPAGATE(packet_translate_remote(ip_globals.net_phone, &packet,
     923                            IPC_GET_PACKET(call)));
     924                        return ip_send_msg_local(0, IPC_GET_DEVICE(call), packet, 0,
     925                            IPC_GET_ERROR(call));
    917926                case NET_IL_DEVICE_STATE:
    918                         return ip_device_state_message(IPC_GET_DEVICE(call), IPC_GET_STATE(call));
     927                        return ip_device_state_message(IPC_GET_DEVICE(call),
     928                            IPC_GET_STATE(call));
    919929                case NET_IL_RECEIVED:
    920                         ERROR_PROPAGATE(packet_translate(ip_globals.net_phone, &packet, IPC_GET_PACKET(call)));
     930                        ERROR_PROPAGATE(packet_translate_remote(ip_globals.net_phone, &packet,
     931                            IPC_GET_PACKET(call)));
    921932                        return ip_receive_message(IPC_GET_DEVICE(call), packet);
    922933                case NET_IP_RECEIVED_ERROR:
    923                         ERROR_PROPAGATE(packet_translate(ip_globals.net_phone, &packet, IPC_GET_PACKET(call)));
    924                         return ip_received_error_msg(0, IPC_GET_DEVICE(call), packet, IPC_GET_TARGET(call), IPC_GET_ERROR(call));
     934                        ERROR_PROPAGATE(packet_translate_remote(ip_globals.net_phone, &packet,
     935                            IPC_GET_PACKET(call)));
     936                        return ip_received_error_msg_local(0, IPC_GET_DEVICE(call), packet,
     937                            IPC_GET_TARGET(call), IPC_GET_ERROR(call));
    925938                case NET_IP_ADD_ROUTE:
    926                         return ip_add_route_req(0, IPC_GET_DEVICE(call), IP_GET_ADDRESS(call), IP_GET_NETMASK(call), IP_GET_GATEWAY(call));
     939                        return ip_add_route_req_local(0, IPC_GET_DEVICE(call),
     940                            IP_GET_ADDRESS(call), IP_GET_NETMASK(call), IP_GET_GATEWAY(call));
    927941                case NET_IP_SET_GATEWAY:
    928                         return ip_set_gateway_req(0, IPC_GET_DEVICE(call), IP_GET_GATEWAY(call));
     942                        return ip_set_gateway_req_local(0, IPC_GET_DEVICE(call),
     943                            IP_GET_GATEWAY(call));
    929944                case NET_IP_GET_ROUTE:
    930945                        ERROR_PROPAGATE(data_receive((void **) &addr, &addrlen));
    931                         ERROR_PROPAGATE(ip_get_route_req(0, IP_GET_PROTOCOL(call), addr, (socklen_t) addrlen,
    932                             &device_id, &header, &headerlen));
     946                        ERROR_PROPAGATE(ip_get_route_req_local(0, IP_GET_PROTOCOL(call),
     947                            addr, (socklen_t) addrlen, &device_id, &header, &headerlen));
    933948                        IPC_SET_DEVICE(answer, device_id);
    934949                        IP_SET_HEADERLEN(answer, headerlen);
     950                       
    935951                        *answer_count = 2;
    936                         if(! ERROR_OCCURRED(data_reply(&headerlen, sizeof(headerlen)))){
     952                       
     953                        if (!ERROR_OCCURRED(data_reply(&headerlen, sizeof(headerlen))))
    937954                                ERROR_CODE = data_reply(header, headerlen);
    938                         }
     955                       
    939956                        free(header);
    940957                        return ERROR_CODE;
    941958                case NET_IL_PACKET_SPACE:
    942                         ERROR_PROPAGATE(ip_packet_size_message(IPC_GET_DEVICE(call), &addrlen, &prefix, &content, &suffix));
     959                        ERROR_PROPAGATE(ip_packet_size_message(IPC_GET_DEVICE(call),
     960                            &addrlen, &prefix, &content, &suffix));
    943961                        IPC_SET_ADDR(answer, addrlen);
    944962                        IPC_SET_PREFIX(answer, prefix);
     
    948966                        return EOK;
    949967                case NET_IL_MTU_CHANGED:
    950                         return ip_mtu_changed_message(IPC_GET_DEVICE(call), IPC_GET_MTU(call));
    951         }
     968                        return ip_mtu_changed_message(IPC_GET_DEVICE(call),
     969                            IPC_GET_MTU(call));
     970        }
     971       
    952972        return ENOTSUP;
    953973}
    954974
    955 int ip_packet_size_req(int ip_phone, device_id_t device_id, packet_dimension_ref packet_dimension){
    956         if(! packet_dimension){
     975int ip_packet_size_req_local(int ip_phone, device_id_t device_id,
     976    packet_dimension_ref packet_dimension)
     977{
     978        if (!packet_dimension)
    957979                return EBADMEM;
    958         }
    959         return ip_packet_size_message(device_id, &packet_dimension->addr_len, &packet_dimension->prefix, &packet_dimension->content, &packet_dimension->suffix);
     980       
     981        return ip_packet_size_message(device_id, &packet_dimension->addr_len,
     982            &packet_dimension->prefix, &packet_dimension->content,
     983            &packet_dimension->suffix);
    960984}
    961985
     
    10031027}
    10041028
    1005 int ip_add_route_req(int ip_phone, device_id_t device_id, in_addr_t address, in_addr_t netmask, in_addr_t gateway){
     1029int ip_add_route_req_local(int ip_phone, device_id_t device_id, in_addr_t address, in_addr_t netmask, in_addr_t gateway){
    10061030        ip_route_ref route;
    10071031        ip_netif_ref netif;
     
    10671091}
    10681092
    1069 int ip_set_gateway_req(int ip_phone, device_id_t device_id, in_addr_t gateway){
     1093int ip_set_gateway_req_local(int ip_phone, device_id_t device_id, in_addr_t gateway)
     1094{
    10701095        ip_netif_ref netif;
    10711096
     
    11121137                                        }
    11131138                                }else{
    1114                                         pq_release(ip_globals.net_phone, packet_get_id(next));
     1139                                        pq_release_remote(ip_globals.net_phone, packet_get_id(next));
    11151140                                }
    11161141                                next = new_packet;
     
    11531178        }
    11541179        // create the last fragment
    1155         new_packet = packet_get_4(ip_globals.net_phone, prefix, length, suffix, ((addrlen > addr_len) ? addrlen : addr_len));
     1180        new_packet = packet_get_4_remote(ip_globals.net_phone, prefix, length, suffix, ((addrlen > addr_len) ? addrlen : addr_len));
    11561181        if(! new_packet){
    11571182                return ENOMEM;
     
    11771202        // create middle framgents
    11781203        while(IP_TOTAL_LENGTH(header) > length){
    1179                 new_packet = packet_get_4(ip_globals.net_phone, prefix, length, suffix, ((addrlen >= addr_len) ? addrlen : addr_len));
     1204                new_packet = packet_get_4_remote(ip_globals.net_phone, prefix, length, suffix, ((addrlen >= addr_len) ? addrlen : addr_len));
    11801205                if(! new_packet){
    11811206                        return ENOMEM;
     
    13571382}
    13581383
    1359 int ip_received_error_msg(int ip_phone, device_id_t device_id, packet_t packet, services_t target, services_t error){
     1384/** Notify the IP module about the received error notification packet.
     1385 *
     1386 * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
     1387 * @param[in] device_id The device identifier.
     1388 * @param[in] packet    The received packet or the received packet queue.
     1389 * @param[in] target    The target internetwork module service to be
     1390 *                      delivered to.
     1391 * @param[in] error     The packet error reporting service. Prefixes the
     1392 *                      received packet.
     1393 *
     1394 * @return EOK on success.
     1395 *
     1396 */
     1397int ip_received_error_msg_local(int ip_phone, device_id_t device_id, packet_t packet, services_t target, services_t error){
    13601398        uint8_t * data;
    13611399        int offset;
     
    14921530        next = pq_detach(packet);
    14931531        if(next){
    1494                 pq_release(ip_globals.net_phone, packet_get_id(next));
     1532                pq_release_remote(ip_globals.net_phone, packet_get_id(next));
    14951533        }
    14961534        if(! header){
     
    15561594
    15571595int ip_release_and_return(packet_t packet, int result){
    1558         pq_release(ip_globals.net_phone, packet_get_id(packet));
     1596        pq_release_remote(ip_globals.net_phone, packet_get_id(packet));
    15591597        return result;
    15601598}
    15611599
    1562 int ip_get_route_req(int ip_phone, ip_protocol_t protocol, const struct sockaddr * destination, socklen_t addrlen, device_id_t * device_id, ip_pseudo_header_ref * header, size_t * headerlen){
     1600int ip_get_route_req_local(int ip_phone, ip_protocol_t protocol, const struct sockaddr * destination, socklen_t addrlen, device_id_t * device_id, void **header, size_t * headerlen){
    15631601        struct sockaddr_in * address_in;
    15641602//      struct sockaddr_in6 *   address_in6;
     
    16241662        header_in->protocol = protocol;
    16251663        header_in->data_length = 0;
    1626         *header = (ip_pseudo_header_ref) header_in;
     1664        *header = header_in;
    16271665        return EOK;
    16281666}
    1629 
    1630 #ifdef CONFIG_NETWORKING_modular
    1631 
    1632 #include <il_standalone.h>
    16331667
    16341668/** Default thread for new connections.
     
    16581692               
    16591693                /* Process the message */
    1660                 int res = il_module_message(callid, &call, &answer, &answer_count);
     1694                int res = il_module_message_standalone(callid, &call, &answer,
     1695                    &answer_count);
    16611696               
    16621697                /* End if said to either by the message or the processing result */
     
    16831718       
    16841719        /* Start the module */
    1685         if (ERROR_OCCURRED(il_module_start(il_client_connection)))
     1720        if (ERROR_OCCURRED(il_module_start_standalone(il_client_connection)))
    16861721                return ERROR_CODE;
    16871722       
     
    16891724}
    16901725
    1691 #endif /* CONFIG_NETWORKING_modular */
    1692 
    16931726/** @}
    16941727 */
  • uspace/srv/net/il/ip/ip_module.c

    r24ab58b3 r14f1db0  
    4747#include <net_interface.h>
    4848#include <packet/packet.h>
    49 #include <il_standalone.h>
     49#include <il_local.h>
    5050
    5151#include "ip.h"
     
    5454/** IP module global data.
    5555 */
    56 extern ip_globals_t     ip_globals;
     56extern ip_globals_t ip_globals;
    5757
    5858/** Processes the IP message.
     
    6464 *  @returns Other error codes as defined for the ip_message() function.
    6565 */
    66 int il_module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
    67         return ip_message(callid, call, answer, answer_count);
     66int il_module_message_standalone(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
     67        return ip_message_standalone(callid, call, answer, answer_count);
    6868}
    6969
     
    7575 *  @returns Other error codes as defined for the REGISTER_ME() macro function.
    7676 */
    77 int il_module_start(async_client_conn_t client_connection){
     77int il_module_start_standalone(async_client_conn_t client_connection){
    7878        ERROR_DECLARE;
    79 
    80         ipcarg_t phonehash;
    81 
     79       
    8280        async_set_client_connection(client_connection);
    8381        ip_globals.net_phone = net_connect_module(SERVICE_NETWORKING);
    8482        ERROR_PROPAGATE(pm_init());
    85         if(ERROR_OCCURRED(ip_initialize(client_connection))
    86                 || ERROR_OCCURRED(REGISTER_ME(SERVICE_IP, &phonehash))){
     83       
     84        ipcarg_t phonehash;
     85        if (ERROR_OCCURRED(ip_initialize(client_connection))
     86            || ERROR_OCCURRED(REGISTER_ME(SERVICE_IP, &phonehash))) {
    8787                pm_destroy();
    8888                return ERROR_CODE;
    8989        }
    90 
     90       
    9191        async_manager();
    92 
     92       
    9393        pm_destroy();
    9494        return EOK;
  • uspace/srv/net/il/ip/ip_module.h

    r24ab58b3 r14f1db0  
    5959 *  @see IS_NET_IP_MESSAGE()
    6060 */
    61 int ip_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
     61int ip_message_standalone(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
    6262
    6363#endif
Note: See TracChangeset for help on using the changeset viewer.