Ignore:
File:
1 edited

Legend:

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

    rffa2c8ef ree2fa30a  
    3636 */
    3737
    38 #include "net.h"
    39 
    4038#include <async.h>
    4139#include <ctype.h>
     
    4644#include <str.h>
    4745#include <str_error.h>
    48 
     46#include <ns.h>
    4947#include <ipc/services.h>
    5048#include <ipc/net.h>
     
    5250#include <ipc/il.h>
    5351#include <ipc/nil.h>
    54 
    5552#include <net/modules.h>
    5653#include <net/packet.h>
    5754#include <net/device.h>
    58 
    5955#include <adt/char_map.h>
    6056#include <adt/generic_char_map.h>
    6157#include <adt/measured_strings.h>
    6258#include <adt/module_map.h>
    63 
    6459#include <netif_remote.h>
    6560#include <nil_remote.h>
    6661#include <net_interface.h>
    6762#include <ip_interface.h>
     63#include "net.h"
    6864
    6965/** Networking module name. */
     
    289285        if (rc != EOK)
    290286                return rc;
     287       
    291288        rc = add_module(NULL, &net_globals.modules, (uint8_t *) NE2000_NAME,
    292289            (uint8_t *) NE2000_FILENAME, SERVICE_NE2000, 0, connect_to_service);
    293290        if (rc != EOK)
    294291                return rc;
     292       
    295293        rc = add_module(NULL, &net_globals.modules, (uint8_t *) ETHERNET_NAME,
    296294            (uint8_t *) ETHERNET_FILENAME, SERVICE_ETHERNET, 0, connect_to_service);
    297295        if (rc != EOK)
    298296                return rc;
     297       
    299298        rc = add_module(NULL, &net_globals.modules, (uint8_t *) NILDUMMY_NAME,
    300299            (uint8_t *) NILDUMMY_FILENAME, SERVICE_NILDUMMY, 0, connect_to_service);
     
    336335                goto out;
    337336       
    338         rc = async_connect_to_me(PHONE_NS, SERVICE_NETWORKING, 0, 0, NULL);
     337        rc = service_register(SERVICE_NETWORKING);
    339338        if (rc != EOK)
    340339                goto out;
     
    390389}
    391390
    392 int net_get_conf_req(int net_phone, measured_string_t **configuration,
     391static int net_get_conf_req_local(measured_string_t **configuration,
    393392    size_t count, uint8_t **data)
    394393{
     
    399398}
    400399
    401 int net_get_device_conf_req(int net_phone, device_id_t device_id,
     400static int net_get_device_conf_req_local(device_id_t device_id,
    402401    measured_string_t **configuration, size_t count, uint8_t **data)
    403402{
     
    475474        uintptr_t io = setting ? strtol((char *) setting->value, NULL, 16) : 0;
    476475       
    477         rc = netif_probe_req(netif->driver->phone, netif->id, irq, (void *) io);
     476        rc = netif_probe_req(netif->driver->sess, netif->id, irq, (void *) io);
    478477        if (rc != EOK)
    479478                return rc;
     
    488487               
    489488                int mtu = setting ? strtol((char *) setting->value, NULL, 10) : 0;
    490                
    491                 rc = nil_device_req(netif->nil->phone, netif->id, mtu,
     489                rc = nil_device_req(netif->nil->sess, netif->id, mtu,
    492490                    netif->driver->service);
    493491                if (rc != EOK)
     
    499497       
    500498        /* Inter-network layer startup */
    501         switch (netif->il->service) {
    502         case SERVICE_IP:
    503                 rc = ip_device_req(netif->il->phone, netif->id,
    504                     internet_service);
    505                 if (rc != EOK)
    506                         return rc;
    507                 break;
    508         default:
    509                 return ENOENT;
    510         }
    511        
    512         return netif_start_req(netif->driver->phone, netif->id);
     499        rc = ip_device_req(netif->il->sess, netif->id, internet_service);
     500        if (rc != EOK)
     501                return rc;
     502       
     503        return netif_start_req(netif->driver->sess, netif->id);
    513504}
    514505
     
    552543                rc = read_netif_configuration(conf_files[i], netif);
    553544                if (rc != EOK) {
    554                         measured_strings_destroy(&netif->configuration);
     545                        measured_strings_destroy(&netif->configuration, free);
    555546                        free(netif);
    556547                        return rc;
     
    562553                if (!setting) {
    563554                        fprintf(stderr, "%s: Network interface name is missing\n", NAME);
    564                         measured_strings_destroy(&netif->configuration);
     555                        measured_strings_destroy(&netif->configuration, free);
    565556                        free(netif);
    566557                        return EINVAL;
     
    571562                int index = netifs_add(&net_globals.netifs, netif->id, netif);
    572563                if (index < 0) {
    573                         measured_strings_destroy(&netif->configuration);
     564                        measured_strings_destroy(&netif->configuration, free);
    574565                        free(netif);
    575566                        return index;
     
    583574                    index);
    584575                if (rc != EOK) {
    585                         measured_strings_destroy(&netif->configuration);
    586                         netifs_exclude_index(&net_globals.netifs, index);
     576                        measured_strings_destroy(&netif->configuration, free);
     577                        netifs_exclude_index(&net_globals.netifs, index, free);
    587578                        return rc;
    588579                }
     
    590581                rc = start_device(netif);
    591582                if (rc != EOK) {
    592                         printf("%s: Error starting interface %s (%s)\n", NAME,
     583                        printf("%s: Ignoring failed interface %s (%s)\n", NAME,
    593584                            netif->name, str_error(rc));
    594                         measured_strings_destroy(&netif->configuration);
    595                         netifs_exclude_index(&net_globals.netifs, index);
    596                        
    597                         return rc;
     585                        measured_strings_destroy(&netif->configuration, free);
     586                        netifs_exclude_index(&net_globals.netifs, index, free);
     587                        continue;
    598588                }
    599589               
     
    636626       
    637627        *answer_count = 0;
     628       
     629        if (!IPC_GET_IMETHOD(*call))
     630                return EOK;
     631       
    638632        switch (IPC_GET_IMETHOD(*call)) {
    639         case IPC_M_PHONE_HUNGUP:
    640                 return EOK;
    641633        case NET_NET_GET_DEVICE_CONF:
    642634                rc = measured_strings_receive(&strings, &data,
     
    644636                if (rc != EOK)
    645637                        return rc;
    646                 net_get_device_conf_req(0, IPC_GET_DEVICE(*call), &strings,
     638                net_get_device_conf_req_local(IPC_GET_DEVICE(*call), &strings,
    647639                    IPC_GET_COUNT(*call), NULL);
    648640               
     
    658650                if (rc != EOK)
    659651                        return rc;
    660                 net_get_conf_req(0, &strings, IPC_GET_COUNT(*call), NULL);
     652                net_get_conf_req_local(&strings, IPC_GET_COUNT(*call), NULL);
    661653               
    662654                /* Strings should not contain received data anymore */
     
    675667/** Default thread for new connections.
    676668 *
    677  * @param[in] iid The initial message identifier.
     669 * @param[in] iid   The initial message identifier.
    678670 * @param[in] icall The initial message call structure.
    679  *
    680  */
    681 static void net_client_connection(ipc_callid_t iid, ipc_call_t *icall)
     671 * @param[in] arg   Local argument.
     672 *
     673 */
     674static void net_client_connection(ipc_callid_t iid, ipc_call_t *icall,
     675    void *arg)
    682676{
    683677        /*
     
    701695               
    702696                /* End if told to either by the message or the processing result */
    703                 if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) || (res == EHANGUP))
     697                if ((!IPC_GET_IMETHOD(call)) || (res == EHANGUP))
    704698                        return;
    705699               
Note: See TracChangeset for help on using the changeset viewer.