Changeset 6b82009 in mainline for uspace/srv


Ignore:
Timestamp:
2011-06-22T20:41:41Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ef09a7a
Parents:
55091847
Message:

networking stack: convert to the new async framework

Location:
uspace/srv
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hw/netif/ne2000/ne2000.c

    r55091847 r6b82009  
    3838#include <assert.h>
    3939#include <async.h>
    40 #include <async_obsolete.h>
    4140#include <ddi.h>
    4241#include <errno.h>
     
    4443#include <malloc.h>
    4544#include <sysinfo.h>
     45#include <ns.h>
    4646#include <ipc/services.h>
    47 #include <ns.h>
    48 #include <ns_obsolete.h>
    4947#include <ipc/irc.h>
    5048#include <net/modules.h>
     
    7876
    7977static bool irc_service = false;
    80 static int irc_phone = -1;
     78static async_sess_t *irc_sess = NULL;
    8179
    8280/** NE2000 kernel interrupt command sequence.
     
    154152        device_id_t device_id = IRQ_GET_DEVICE(*call);
    155153        netif_device_t *device;
    156         int nil_phone;
     154        async_sess_t *nil_sess;
    157155        ne2k_t *ne2k;
    158156       
    159157        fibril_rwlock_read_lock(&netif_globals.lock);
    160158       
    161         if (find_device(device_id, &device) == EOK) {
    162                 nil_phone = device->nil_phone;
     159        nil_sess = netif_globals.nil_sess;
     160       
     161        if (find_device(device_id, &device) == EOK)
    163162                ne2k = (ne2k_t *) device->specific;
    164         } else
     163        else
    165164                ne2k = NULL;
    166165       
     
    177176                               
    178177                                list_remove(&frame->link);
    179                                 nil_received_msg(nil_phone, device_id,
    180                                     frame->packet, SERVICE_NONE);
     178                                nil_received_msg(nil_sess, device_id, frame->packet,
     179                                    SERVICE_NONE);
    181180                                free(frame);
    182181                        }
     
    278277       
    279278        device->device_id = device_id;
    280         device->nil_phone = -1;
    281279        device->specific = (void *) ne2k;
    282280        device->state = NETIF_STOPPED;
     
    331329                change_state(device, NETIF_ACTIVE);
    332330               
    333                 if (irc_service)
    334                         async_obsolete_msg_1(irc_phone, IRC_ENABLE_INTERRUPT, ne2k->irq);
     331                if (irc_service) {
     332                        async_exch_t *exch = async_exchange_begin(irc_sess);
     333                        async_msg_1(exch, IRC_ENABLE_INTERRUPT, ne2k->irq);
     334                        async_exchange_end(exch);
     335                }
    335336        }
    336337       
     
    390391       
    391392        if (irc_service) {
    392                 while (irc_phone < 0)
    393                         irc_phone = service_obsolete_connect_blocking(SERVICE_IRC, 0, 0);
     393                while (!irc_sess)
     394                        irc_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
     395                            SERVICE_IRC, 0, 0);
    394396        }
    395397       
     
    402404{
    403405        /* Start the module */
    404         return netif_module_start();
     406        return netif_module_start(SERVICE_ETHERNET);
    405407}
    406408
  • uspace/srv/net/il/arp/arp.c

    r55091847 r6b82009  
    164164}
    165165
    166 static int arp_clean_cache_req(int arp_phone)
     166static int arp_clean_cache_req(void)
    167167{
    168168        int count;
     
    190190}
    191191
    192 static int arp_clear_address_req(int arp_phone, device_id_t device_id,
    193     services_t protocol, measured_string_t *address)
     192static int arp_clear_address_req(device_id_t device_id, services_t protocol,
     193    measured_string_t *address)
    194194{
    195195        fibril_mutex_lock(&arp_globals.lock);
     
    218218}
    219219
    220 static int arp_clear_device_req(int arp_phone, device_id_t device_id)
     220static int arp_clear_device_req(device_id_t device_id)
    221221{
    222222        fibril_mutex_lock(&arp_globals.lock);
     
    375375                                return rc;
    376376                       
    377                         nil_send_msg(device->phone, device_id, packet,
     377                        nil_send_msg(device->sess, device_id, packet,
    378378                            SERVICE_ARP);
    379379                        return 1;
     
    416416 * @param[in]     iid   Message identifier.
    417417 * @param[in,out] icall Message parameters.
    418  * @param[in]     arg   Local argument.
     418 * @param[in]     arg   Local argument.
     419 *
    419420 */
    420421static void arp_receiver(ipc_callid_t iid, ipc_call_t *icall, void *arg)
     
    431432               
    432433                case NET_IL_RECEIVED:
    433                         rc = packet_translate_remote(arp_globals.net_phone, &packet,
     434                        rc = packet_translate_remote(arp_globals.net_sess, &packet,
    434435                            IPC_GET_PACKET(*icall));
    435436                        if (rc == EOK) {
     
    439440                                        rc = arp_receive_message(IPC_GET_DEVICE(*icall), packet);
    440441                                        if (rc != 1) {
    441                                                 pq_release_remote(arp_globals.net_phone,
     442                                                pq_release_remote(arp_globals.net_sess,
    442443                                                    packet_get_id(packet));
    443444                                        }
     
    564565               
    565566                /* Bind */
    566                 device->phone = nil_bind_service(device->service,
     567                device->sess = nil_bind_service(device->service,
    567568                    (sysarg_t) device->device_id, SERVICE_ARP,
    568569                    arp_receiver);
    569                 if (device->phone < 0) {
     570                if (device->sess == NULL) {
    570571                        fibril_mutex_unlock(&arp_globals.lock);
    571572                        arp_protos_destroy(&device->protos, free);
     
    575576               
    576577                /* Get packet dimensions */
    577                 rc = nil_packet_size_req(device->phone, device_id,
     578                rc = nil_packet_size_req(device->sess, device_id,
    578579                    &device->packet_dimension);
    579580                if (rc != EOK) {
     
    585586               
    586587                /* Get hardware address */
    587                 rc = nil_get_addr_req(device->phone, device_id, &device->addr,
     588                rc = nil_get_addr_req(device->sess, device_id, &device->addr,
    588589                    &device->addr_data);
    589590                if (rc != EOK) {
     
    595596               
    596597                /* Get broadcast address */
    597                 rc = nil_get_broadcast_addr_req(device->phone, device_id,
     598                rc = nil_get_broadcast_addr_req(device->sess, device_id,
    598599                    &device->broadcast_addr, &device->broadcast_data);
    599600                if (rc != EOK) {
     
    627628}
    628629
    629 int il_initialize(int net_phone)
     630int il_initialize(async_sess_t *net_sess)
    630631{
    631632        fibril_mutex_initialize(&arp_globals.lock);
    632633       
    633634        fibril_mutex_lock(&arp_globals.lock);
    634         arp_globals.net_phone = net_phone;
     635        arp_globals.net_sess = net_sess;
    635636        int rc = arp_cache_initialize(&arp_globals.cache);
    636637        fibril_mutex_unlock(&arp_globals.lock);
     
    647648                return ELIMIT;
    648649       
    649         packet_t *packet = packet_get_4_remote(arp_globals.net_phone,
     650        packet_t *packet = packet_get_4_remote(arp_globals.net_sess,
    650651            device->packet_dimension.addr_len, device->packet_dimension.prefix,
    651652            length, device->packet_dimension.suffix);
     
    655656        arp_header_t *header = (arp_header_t *) packet_suffix(packet, length);
    656657        if (!header) {
    657                 pq_release_remote(arp_globals.net_phone, packet_get_id(packet));
     658                pq_release_remote(arp_globals.net_sess, packet_get_id(packet));
    658659                return ENOMEM;
    659660        }
     
    680681            (uint8_t *) device->broadcast_addr->value, device->addr->length);
    681682        if (rc != EOK) {
    682                 pq_release_remote(arp_globals.net_phone, packet_get_id(packet));
     683                pq_release_remote(arp_globals.net_sess, packet_get_id(packet));
    683684                return rc;
    684685        }
    685686       
    686         nil_send_msg(device->phone, device_id, packet, SERVICE_ARP);
     687        nil_send_msg(device->sess, device_id, packet, SERVICE_ARP);
    687688        return EOK;
    688689}
     
    890891       
    891892        case NET_ARP_CLEAR_DEVICE:
    892                 return arp_clear_device_req(0, IPC_GET_DEVICE(*call));
     893                return arp_clear_device_req(IPC_GET_DEVICE(*call));
    893894       
    894895        case NET_ARP_CLEAR_ADDRESS:
     
    897898                        return rc;
    898899               
    899                 arp_clear_address_req(0, IPC_GET_DEVICE(*call),
     900                arp_clear_address_req(IPC_GET_DEVICE(*call),
    900901                    IPC_GET_SERVICE(*call), address);
    901902                free(address);
     
    904905       
    905906        case NET_ARP_CLEAN_CACHE:
    906                 return arp_clean_cache_req(0);
     907                return arp_clean_cache_req();
    907908        }
    908909       
  • uspace/srv/net/il/arp/arp.h

    r55091847 r6b82009  
    3838#define NET_ARP_H_
    3939
     40#include <async.h>
    4041#include <fibril_synch.h>
    4142#include <ipc/services.h>
     
    104105        /** Packet dimension. */
    105106        packet_dimension_t packet_dimension;
    106         /** Device module phone. */
    107         int phone;
     107        /** Device module session. */
     108        async_sess_t *sess;
    108109       
    109110        /**
     
    122123        arp_cache_t cache;
    123124       
    124         /** Networking module phone. */
    125         int net_phone;
     125        /** Networking module session. */
     126        async_sess_t *net_sess;
     127       
    126128        /** Safety lock. */
    127129        fibril_mutex_t lock;
  • uspace/srv/net/il/ip/ip.c

    r55091847 r6b82009  
    7777#include <il_skel.h>
    7878
    79 // FIXME: remove this header
    80 #include <kernel/ipc/ipc_methods.h>
    81 
    8279/** IP module name. */
    8380#define NAME                    "ip"
     
    125122static void ip_receiver(ipc_callid_t, ipc_call_t *, void *);
    126123
    127 /** Releases the packet and returns the result.
    128  *
    129  * @param[in] packet    The packet queue to be released.
    130  * @param[in] result    The result to be returned.
    131  * @return              The result parameter.
     124/** Release the packet and returns the result.
     125 *
     126 * @param[in] packet Packet queue to be released.
     127 * @param[in] result Result to be returned.
     128 *
     129 * @return Result parameter.
     130 *
    132131 */
    133132static int ip_release_and_return(packet_t *packet, int result)
    134133{
    135         pq_release_remote(ip_globals.net_phone, packet_get_id(packet));
     134        pq_release_remote(ip_globals.net_sess, packet_get_id(packet));
    136135        return result;
    137136}
    138137
    139 /** Returns the ICMP phone.
    140  *
    141  * Searches the registered protocols.
    142  *
    143  * @return              The found ICMP phone.
    144  * @return              ENOENT if the ICMP is not registered.
    145  */
    146 static int ip_get_icmp_phone(void)
    147 {
    148         ip_proto_t *proto;
    149         int phone;
    150 
     138/** Return the ICMP session.
     139 *
     140 * Search the registered protocols.
     141 *
     142 * @return Found ICMP session.
     143 * @return NULL if the ICMP is not registered.
     144 *
     145 */
     146static async_sess_t *ip_get_icmp_session(void)
     147{
    151148        fibril_rwlock_read_lock(&ip_globals.protos_lock);
    152         proto = ip_protos_find(&ip_globals.protos, IPPROTO_ICMP);
    153         phone = proto ? proto->phone : ENOENT;
     149        ip_proto_t *proto = ip_protos_find(&ip_globals.protos, IPPROTO_ICMP);
     150        async_sess_t *sess = proto ? proto->sess : NULL;
    154151        fibril_rwlock_read_unlock(&ip_globals.protos_lock);
    155         return phone;
     152       
     153        return sess;
    156154}
    157155
     
    182180        next = pq_detach(packet);
    183181        if (next)
    184                 pq_release_remote(ip_globals.net_phone, packet_get_id(next));
     182                pq_release_remote(ip_globals.net_sess, packet_get_id(next));
    185183
    186184        if (!header) {
     
    221219}
    222220
    223 /** Prepares the ICMP notification packet.
    224  *
    225  * Releases additional packets and keeps only the first one.
     221/** Prepare the ICMP notification packet.
     222 *
     223 * Release additional packets and keep only the first one.
    226224 * All packets are released on error.
    227225 *
    228  * @param[in] error     The packet error service.
    229  * @param[in] packet    The packet or the packet queue to be reported as faulty.
    230  * @param[in] header    The first packet IP header. May be NULL.
    231  * @return              The found ICMP phone.
    232  * @return              EINVAL if the error parameter is set.
    233  * @return              EINVAL if the ICMP phone is not found.
    234  * @return              EINVAL if the ip_prepare_icmp() fails.
    235  */
    236 static int
    237 ip_prepare_icmp_and_get_phone(services_t error, packet_t *packet,
    238     ip_header_t *header)
    239 {
    240         int phone;
    241 
    242         phone = ip_get_icmp_phone();
    243         if (error || (phone < 0) || ip_prepare_icmp(packet, header))
    244                 return ip_release_and_return(packet, EINVAL);
    245         return phone;
    246 }
    247 
    248 int il_initialize(int net_phone)
     226 * @param[in] error  Packet error service.
     227 * @param[in] packet Packet or the packet queue to be reported as faulty.
     228 * @param[in] header First packet IP header. May be NULL.
     229 *
     230 * @return Found ICMP session.
     231 * @return NULL if the error parameter is set.
     232 * @return NULL if the ICMP session is not found.
     233 * @return NULL if the ip_prepare_icmp() fails.
     234 *
     235 */
     236static async_sess_t *ip_prepare_icmp_and_get_session(services_t error,
     237    packet_t *packet, ip_header_t *header)
     238{
     239        async_sess_t *sess = ip_get_icmp_session();
     240       
     241        if ((error) || (!sess) || (ip_prepare_icmp(packet, header))) {
     242                pq_release_remote(ip_globals.net_sess, packet_get_id(packet));
     243                return NULL;
     244        }
     245       
     246        return sess;
     247}
     248
     249int il_initialize(async_sess_t *net_sess)
    249250{
    250251        fibril_rwlock_initialize(&ip_globals.lock);
     
    253254        fibril_rwlock_initialize(&ip_globals.netifs_lock);
    254255       
    255         ip_globals.net_phone = net_phone;
     256        ip_globals.net_sess = net_sess;
    256257        ip_globals.packet_counter = 0;
    257258        ip_globals.gateway.address.s_addr = 0;
     
    355356
    356357        /* Get configuration */
    357         rc = net_get_device_conf_req(ip_globals.net_phone, ip_netif->device_id,
     358        rc = net_get_device_conf_req(ip_globals.net_sess, ip_netif->device_id,
    358359            &configuration, count, &data);
    359360        if (rc != EOK)
     
    423424
    424425        /* Bind netif service which also initializes the device */
    425         ip_netif->phone = nil_bind_service(ip_netif->service,
     426        ip_netif->sess = nil_bind_service(ip_netif->service,
    426427            (sysarg_t) ip_netif->device_id, SERVICE_IP,
    427428            ip_receiver);
    428         if (ip_netif->phone < 0) {
     429        if (ip_netif->sess == NULL) {
    429430                printf("Failed to contact the nil service %d\n",
    430431                    ip_netif->service);
    431                 return ip_netif->phone;
     432                return ENOENT;
    432433        }
    433434
     
    438439                        address.length = sizeof(in_addr_t);
    439440                       
    440                         rc = arp_device_req(ip_netif->arp->phone,
     441                        rc = arp_device_req(ip_netif->arp->sess,
    441442                            ip_netif->device_id, SERVICE_IP, ip_netif->service,
    442443                            &address);
     
    449450
    450451        /* Get packet dimensions */
    451         rc = nil_packet_size_req(ip_netif->phone, ip_netif->device_id,
     452        rc = nil_packet_size_req(ip_netif->sess, ip_netif->device_id,
    452453            &ip_netif->packet_dimension);
    453454        if (rc != EOK)
     
    481482}
    482483
    483 static int ip_device_req_local(int il_phone, device_id_t device_id,
    484     services_t netif)
     484static int ip_device_req_local(device_id_t device_id, services_t netif)
    485485{
    486486        ip_netif_t *ip_netif;
     
    516516
    517517        /* Print the settings */
    518         printf("%s: Device registered (id: %d, phone: %d, ipv: %d, conf: %s)\n",
    519             NAME, ip_netif->device_id, ip_netif->phone, ip_netif->ipv,
     518        printf("%s: Device registered (id: %d, ipv: %d, conf: %s)\n",
     519            NAME, ip_netif->device_id, ip_netif->ipv,
    520520            ip_netif->dhcp ? "dhcp" : "static");
    521521       
     
    932932
    933933        /* Create the last fragment */
    934         new_packet = packet_get_4_remote(ip_globals.net_phone, prefix, length,
     934        new_packet = packet_get_4_remote(ip_globals.net_sess, prefix, length,
    935935            suffix, ((addrlen > addr_len) ? addrlen : addr_len));
    936936        if (!new_packet)
     
    969969        /* Create middle fragments */
    970970        while (IP_TOTAL_LENGTH(header) > length) {
    971                 new_packet = packet_get_4_remote(ip_globals.net_phone, prefix,
     971                new_packet = packet_get_4_remote(ip_globals.net_sess, prefix,
    972972                    length, suffix,
    973973                    ((addrlen >= addr_len) ? addrlen : addr_len));
     
    994994}
    995995
    996 /** Checks the packet queue lengths and fragments the packets if needed.
     996/** Check the packet queue lengths and fragments the packets if needed.
    997997 *
    998998 * The ICMP_FRAG_NEEDED error notification may be sent if the packet needs to
    999999 * be fragmented and the fragmentation is not allowed.
    10001000 *
    1001  * @param[in,out] packet The packet or the packet queue to be checked.
    1002  * @param[in] prefix    The minimum prefix size.
    1003  * @param[in] content   The maximum content size.
    1004  * @param[in] suffix    The minimum suffix size.
    1005  * @param[in] addr_len  The minimum address length.
    1006  * @param[in] error     The error module service.
    1007  * @return              The packet or the packet queue of the allowed length.
    1008  * @return              NULL if there are no packets left.
    1009  */
    1010 static packet_t *
    1011 ip_split_packet(packet_t *packet, size_t prefix, size_t content, size_t suffix,
    1012     socklen_t addr_len, services_t error)
     1001 * @param[in,out] packet   Packet or the packet queue to be checked.
     1002 * @param[in]     prefix   Minimum prefix size.
     1003 * @param[in]     content  Maximum content size.
     1004 * @param[in]     suffix   Minimum suffix size.
     1005 * @param[in]     addr_len Minimum address length.
     1006 * @param[in]     error    Error module service.
     1007 *
     1008 * @return The packet or the packet queue of the allowed length.
     1009 * @return NULL if there are no packets left.
     1010 *
     1011 */
     1012static packet_t *ip_split_packet(packet_t *packet, size_t prefix, size_t content,
     1013    size_t suffix, socklen_t addr_len, services_t error)
    10131014{
    10141015        size_t length;
     
    10161017        packet_t *new_packet;
    10171018        int result;
    1018         int phone;
    1019 
     1019        async_sess_t *sess;
     1020       
    10201021        next = packet;
    10211022        /* Check all packets */
     
    10391040                        /* Fragmentation needed? */
    10401041                        if (result == EPERM) {
    1041                                 phone = ip_prepare_icmp_and_get_phone(
    1042                                     error, next, NULL);
    1043                                 if (phone >= 0) {
     1042                                sess = ip_prepare_icmp_and_get_session(error, next, NULL);
     1043                                if (sess) {
    10441044                                        /* Fragmentation necessary ICMP */
    1045                                         icmp_destination_unreachable_msg(phone,
     1045                                        icmp_destination_unreachable_msg(sess,
    10461046                                            ICMP_FRAG_NEEDED, content, next);
    10471047                                }
    10481048                        } else {
    1049                                 pq_release_remote(ip_globals.net_phone,
     1049                                pq_release_remote(ip_globals.net_sess,
    10501050                                    packet_get_id(next));
    10511051                        }
     
    10611061}
    10621062
    1063 /** Sends the packet or the packet queue via the specified route.
     1063/** Send the packet or the packet queue via the specified route.
    10641064 *
    10651065 * The ICMP_HOST_UNREACH error notification may be sent if route hardware
    10661066 * destination address is found.
    10671067 *
    1068  * @param[in,out] packet The packet to be sent.
    1069  * @param[in] netif     The target network interface.
    1070  * @param[in] route     The target route.
    1071  * @param[in] src       The source address.
    1072  * @param[in] dest      The destination address.
    1073  * @param[in] error     The error module service.
    1074  * @return              EOK on success.
    1075  * @return              Other error codes as defined for the arp_translate_req()
    1076  *                      function.
    1077  * @return              Other error codes as defined for the ip_prepare_packet()
    1078  *                      function.
     1068 * @param[in,out] packet Packet to be sent.
     1069 * @param[in]     netif  Target network interface.
     1070 * @param[in]     route  Target route.
     1071 * @param[in]     src    Source address.
     1072 * @param[in]     dest   Destination address.
     1073 * @param[in]     error  Error module service.
     1074 *
     1075 * @return EOK on success.
     1076 * @return Other error codes as defined for arp_translate_req().
     1077 * @return Other error codes as defined for ip_prepare_packet().
     1078 *
    10791079 */
    10801080static int ip_send_route(packet_t *packet, ip_netif_t *netif,
     
    10841084        measured_string_t *translation;
    10851085        uint8_t *data;
    1086         int phone;
     1086        async_sess_t *sess;
    10871087        int rc;
    10881088
     
    10931093                destination.length = sizeof(dest.s_addr);
    10941094
    1095                 rc = arp_translate_req(netif->arp->phone, netif->device_id,
     1095                rc = arp_translate_req(netif->arp->sess, netif->device_id,
    10961096                    SERVICE_IP, &destination, &translation, &data);
    10971097                if (rc != EOK) {
    1098                         pq_release_remote(ip_globals.net_phone,
     1098                        pq_release_remote(ip_globals.net_sess,
    10991099                            packet_get_id(packet));
    11001100                        return rc;
     
    11061106                                free(data);
    11071107                        }
    1108                         phone = ip_prepare_icmp_and_get_phone(error, packet,
     1108                        sess = ip_prepare_icmp_and_get_session(error, packet,
    11091109                            NULL);
    1110                         if (phone >= 0) {
     1110                        if (sess) {
    11111111                                /* Unreachable ICMP if no routing */
    1112                                 icmp_destination_unreachable_msg(phone,
     1112                                icmp_destination_unreachable_msg(sess,
    11131113                                    ICMP_HOST_UNREACH, 0, packet);
    11141114                        }
     
    11221122        rc = ip_prepare_packet(src, dest, packet, translation);
    11231123        if (rc != EOK) {
    1124                 pq_release_remote(ip_globals.net_phone, packet_get_id(packet));
     1124                pq_release_remote(ip_globals.net_sess, packet_get_id(packet));
    11251125        } else {
    11261126                packet = ip_split_packet(packet, netif->packet_dimension.prefix,
     
    11291129                    netif->packet_dimension.addr_len, error);
    11301130                if (packet) {
    1131                         nil_send_msg(netif->phone, netif->device_id, packet,
     1131                        nil_send_msg(netif->sess, netif->device_id, packet,
    11321132                            SERVICE_IP);
    11331133                }
     
    11421142}
    11431143
    1144 static int ip_send_msg_local(int il_phone, device_id_t device_id,
    1145     packet_t *packet, services_t sender, services_t error)
     1144static int ip_send_msg_local(device_id_t device_id, packet_t *packet,
     1145    services_t sender, services_t error)
    11461146{
    11471147        int addrlen;
     
    11521152        in_addr_t *dest;
    11531153        in_addr_t *src;
    1154         int phone;
     1154        async_sess_t *sess;
    11551155        int rc;
    11561156
     
    11971197        if (!netif || !route) {
    11981198                fibril_rwlock_read_unlock(&ip_globals.netifs_lock);
    1199                 phone = ip_prepare_icmp_and_get_phone(error, packet, NULL);
    1200                 if (phone >= 0) {
     1199                sess = ip_prepare_icmp_and_get_session(error, packet, NULL);
     1200                if (sess) {
    12011201                        /* Unreachable ICMP if no routing */
    1202                         icmp_destination_unreachable_msg(phone,
     1202                        icmp_destination_unreachable_msg(sess,
    12031203                            ICMP_NET_UNREACH, 0, packet);
    12041204                }
     
    12281228                if (!netif || !route) {
    12291229                        fibril_rwlock_read_unlock(&ip_globals.netifs_lock);
    1230                         phone = ip_prepare_icmp_and_get_phone(error, packet,
     1230                        sess = ip_prepare_icmp_and_get_session(error, packet,
    12311231                            NULL);
    1232                         if (phone >= 0) {
     1232                        if (sess) {
    12331233                                /* Unreachable ICMP if no routing */
    1234                                 icmp_destination_unreachable_msg(phone,
     1234                                icmp_destination_unreachable_msg(sess,
    12351235                                    ICMP_HOST_UNREACH, 0, packet);
    12361236                        }
     
    13161316{
    13171317        ip_proto_t *proto;
    1318         int phone;
     1318        async_sess_t *sess;
    13191319        services_t service;
    13201320        tl_received_msg_t received_msg;
     
    13691369        if (!proto) {
    13701370                fibril_rwlock_read_unlock(&ip_globals.protos_lock);
    1371                 phone = ip_prepare_icmp_and_get_phone(error, packet, header);
    1372                 if (phone >= 0) {
     1371                sess = ip_prepare_icmp_and_get_session(error, packet, header);
     1372                if (sess) {
    13731373                        /* Unreachable ICMP */
    1374                         icmp_destination_unreachable_msg(phone,
     1374                        icmp_destination_unreachable_msg(sess,
    13751375                            ICMP_PROT_UNREACH, 0, packet);
    13761376                }
     
    13841384                rc = received_msg(device_id, packet, service, error);
    13851385        } else {
    1386                 rc = tl_received_msg(proto->phone, device_id, packet,
     1386                rc = tl_received_msg(proto->sess, device_id, packet,
    13871387                    proto->service, error);
    13881388                fibril_rwlock_read_unlock(&ip_globals.protos_lock);
     
    14181418        in_addr_t dest;
    14191419        ip_route_t *route;
    1420         int phone;
     1420        async_sess_t *sess;
    14211421        struct sockaddr *addr;
    14221422        struct sockaddr_in addr_in;
     
    14311431        if ((header->header_checksum) &&
    14321432            (IP_HEADER_CHECKSUM(header) != IP_CHECKSUM_ZERO)) {
    1433                 phone = ip_prepare_icmp_and_get_phone(0, packet, header);
    1434                 if (phone >= 0) {
     1433                sess = ip_prepare_icmp_and_get_session(0, packet, header);
     1434                if (sess) {
    14351435                        /* Checksum error ICMP */
    1436                         icmp_parameter_problem_msg(phone, ICMP_PARAM_POINTER,
     1436                        icmp_parameter_problem_msg(sess, ICMP_PARAM_POINTER,
    14371437                            ((size_t) ((void *) &header->header_checksum)) -
    14381438                            ((size_t) ((void *) header)), packet);
     
    14421442
    14431443        if (header->ttl <= 1) {
    1444                 phone = ip_prepare_icmp_and_get_phone(0, packet, header);
    1445                 if (phone >= 0) {
     1444                sess = ip_prepare_icmp_and_get_session(0, packet, header);
     1445                if (sess) {
    14461446                        /* TTL exceeded ICMP */
    1447                         icmp_time_exceeded_msg(phone, ICMP_EXC_TTL, packet);
     1447                        icmp_time_exceeded_msg(sess, ICMP_EXC_TTL, packet);
    14481448                }
    14491449                return EINVAL;
     
    14731473        route = ip_find_route(dest);
    14741474        if (!route) {
    1475                 phone = ip_prepare_icmp_and_get_phone(0, packet, header);
    1476                 if (phone >= 0) {
     1475                sess = ip_prepare_icmp_and_get_session(0, packet, header);
     1476                if (sess) {
    14771477                        /* Unreachable ICMP */
    1478                         icmp_destination_unreachable_msg(phone,
     1478                        icmp_destination_unreachable_msg(sess,
    14791479                            ICMP_HOST_UNREACH, 0, packet);
    14801480                }
     
    14931493        }
    14941494
    1495         phone = ip_prepare_icmp_and_get_phone(0, packet, header);
    1496         if (phone >= 0) {
     1495        sess = ip_prepare_icmp_and_get_session(0, packet, header);
     1496        if (sess) {
    14971497                /* Unreachable ICMP if no routing */
    1498                 icmp_destination_unreachable_msg(phone, ICMP_HOST_UNREACH, 0,
     1498                icmp_destination_unreachable_msg(sess, ICMP_HOST_UNREACH, 0,
    14991499                    packet);
    15001500        }
     
    15031503}
    15041504
    1505 /** Returns the device packet dimensions for sending.
    1506  *
    1507  * @param[in] phone     The service module phone.
    1508  * @param[in] message   The service specific message.
    1509  * @param[in] device_id The device identifier.
    1510  * @param[out] addr_len The minimum reserved address length.
    1511  * @param[out] prefix   The minimum reserved prefix size.
    1512  * @param[out] content  The maximum content size.
    1513  * @param[out] suffix   The minimum reserved suffix size.
    1514  * @return              EOK on success.
     1505/** Return the device packet dimensions for sending.
     1506 *
     1507 * @param[in]  device_id Device identifier.
     1508 * @param[out] addr_len  Minimum reserved address length.
     1509 * @param[out] prefix    Minimum reserved prefix size.
     1510 * @param[out] content   Maximum content size.
     1511 * @param[out] suffix    Minimum reserved suffix size.
     1512 *
     1513 * @return EOK on success.
     1514 *
    15151515 */
    15161516static int ip_packet_size_message(device_id_t device_id, size_t *addr_len,
     
    15951595 * @param[in,out] icall Message parameters.
    15961596 * @param[in]     arg   Local argument.
     1597 *
    15971598 */
    15981599static void ip_receiver(ipc_callid_t iid, ipc_call_t *icall, void *arg)
     
    16101611               
    16111612                case NET_IL_RECEIVED:
    1612                         rc = packet_translate_remote(ip_globals.net_phone, &packet,
     1613                        rc = packet_translate_remote(ip_globals.net_sess, &packet,
    16131614                            IPC_GET_PACKET(*icall));
    16141615                        if (rc == EOK) {
     
    16371638}
    16381639
    1639 /** Registers the transport layer protocol.
     1640/** Register the transport layer protocol.
    16401641 *
    16411642 * The traffic of this protocol will be supplied using either the receive
    16421643 * function or IPC message.
    16431644 *
    1644  * @param[in] protocol  The transport layer module protocol.
    1645  * @param[in] service   The transport layer module service.
    1646  * @param[in] phone     The transport layer module phone.
    1647  * @param[in] received_msg The receiving function.
    1648  * @return              EOK on success.
    1649  * @return              EINVAL if the protocol parameter and/or the service
    1650  *                      parameter is zero.
    1651  * @return              EINVAL if the phone parameter is not a positive number
    1652  *                      and the tl_receive_msg is NULL.
    1653  * @return              ENOMEM if there is not enough memory left.
    1654  */
    1655 static int
    1656 ip_register(int protocol, services_t service, int phone,
     1645 * @param[in] protocol     Transport layer module protocol.
     1646 * @param[in] service      Transport layer module service.
     1647 * @param[in] sess         Transport layer module session.
     1648 * @param[in] received_msg Receiving function.
     1649 *
     1650 * @return EOK on success.
     1651 * @return EINVAL if the protocol parameter and/or the service
     1652 *         parameter is zero.
     1653 * @return EINVAL if the phone parameter is not a positive number
     1654 *         and the tl_receive_msg is NULL.
     1655 * @return ENOMEM if there is not enough memory left.
     1656 *
     1657 */
     1658static int ip_register(int protocol, services_t service, async_sess_t *sess,
    16571659    tl_received_msg_t received_msg)
    16581660{
     
    16601662        int index;
    16611663
    1662         if (!protocol || !service || ((phone < 0) && !received_msg))
     1664        if ((!protocol) || (!service) || ((!sess) && (!received_msg)))
    16631665                return EINVAL;
    1664 
     1666       
    16651667        proto = (ip_proto_t *) malloc(sizeof(ip_protos_t));
    16661668        if (!proto)
     
    16691671        proto->protocol = protocol;
    16701672        proto->service = service;
    1671         proto->phone = phone;
     1673        proto->sess = sess;
    16721674        proto->received_msg = received_msg;
    16731675
     
    16811683        fibril_rwlock_write_unlock(&ip_globals.protos_lock);
    16821684
    1683         printf("%s: Protocol registered (protocol: %d, phone: %d)\n",
    1684             NAME, proto->protocol, proto->phone);
     1685        printf("%s: Protocol registered (protocol: %d)\n",
     1686            NAME, proto->protocol);
    16851687
    16861688        return EOK;
    16871689}
    16881690
    1689 
    1690 static int
    1691 ip_add_route_req_local(int ip_phone, device_id_t device_id, in_addr_t address,
     1691static int ip_add_route_req_local(device_id_t device_id, in_addr_t address,
    16921692    in_addr_t netmask, in_addr_t gateway)
    16931693{
     
    17231723}
    17241724
    1725 static int
    1726 ip_set_gateway_req_local(int ip_phone, device_id_t device_id, in_addr_t gateway)
     1725static int ip_set_gateway_req_local(device_id_t device_id, in_addr_t gateway)
    17271726{
    17281727        ip_netif_t *netif;
     
    17481747/** Notify the IP module about the received error notification packet.
    17491748 *
    1750  * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
    1751  * @param[in] device_id The device identifier.
    1752  * @param[in] packet    The received packet or the received packet queue.
    1753  * @param[in] target    The target internetwork module service to be
    1754  *                      delivered to.
    1755  * @param[in] error     The packet error reporting service. Prefixes the
    1756  *                      received packet.
    1757  * @return              EOK on success.
    1758  *
    1759  */
    1760 static int
    1761 ip_received_error_msg_local(int ip_phone, device_id_t device_id,
     1749 * @param[in] device_id Device identifier.
     1750 * @param[in] packet    Received packet or the received packet queue.
     1751 * @param[in] target    Target internetwork module service to be
     1752 *                      delivered to.
     1753 * @param[in] error     Packet error reporting service. Prefixes the
     1754 *                      received packet.
     1755 *
     1756 * @return EOK on success.
     1757 *
     1758 */
     1759static int ip_received_error_msg_local(device_id_t device_id,
    17621760    packet_t *packet, services_t target, services_t error)
    17631761{
     
    18041802                        address.value = (uint8_t *) &header->destination_address;
    18051803                        address.length = sizeof(header->destination_address);
    1806                         arp_clear_address_req(netif->arp->phone,
     1804                        arp_clear_address_req(netif->arp->sess,
    18071805                            netif->device_id, SERVICE_IP, &address);
    18081806                }
     
    18181816}
    18191817
    1820 static int
    1821 ip_get_route_req_local(int ip_phone, ip_protocol_t protocol,
     1818static int ip_get_route_req_local(ip_protocol_t protocol,
    18221819    const struct sockaddr *destination, socklen_t addrlen,
    18231820    device_id_t *device_id, void **header, size_t *headerlen)
     
    19201917                return EOK;
    19211918       
     1919        async_sess_t *callback =
     1920            async_callback_receive_start(EXCHANGE_SERIALIZE, call);
     1921        if (callback)
     1922                return ip_register(IL_GET_PROTO(*call), IL_GET_SERVICE(*call),
     1923                    callback, NULL);
     1924       
    19221925        switch (IPC_GET_IMETHOD(*call)) {
    1923         case IPC_M_CONNECT_TO_ME:
    1924                 return ip_register(IL_GET_PROTO(*call), IL_GET_SERVICE(*call),
    1925                     IPC_GET_PHONE(*call), NULL);
    1926        
    19271926        case NET_IP_DEVICE:
    1928                 return ip_device_req_local(0, IPC_GET_DEVICE(*call),
     1927                return ip_device_req_local(IPC_GET_DEVICE(*call),
    19291928                    IPC_GET_SERVICE(*call));
    19301929       
    19311930        case NET_IP_RECEIVED_ERROR:
    1932                 rc = packet_translate_remote(ip_globals.net_phone, &packet,
     1931                rc = packet_translate_remote(ip_globals.net_sess, &packet,
    19331932                    IPC_GET_PACKET(*call));
    19341933                if (rc != EOK)
    19351934                        return rc;
    1936                 return ip_received_error_msg_local(0, IPC_GET_DEVICE(*call),
     1935                return ip_received_error_msg_local(IPC_GET_DEVICE(*call),
    19371936                    packet, IPC_GET_TARGET(*call), IPC_GET_ERROR(*call));
    19381937       
    19391938        case NET_IP_ADD_ROUTE:
    1940                 return ip_add_route_req_local(0, IPC_GET_DEVICE(*call),
     1939                return ip_add_route_req_local(IPC_GET_DEVICE(*call),
    19411940                    IP_GET_ADDRESS(*call), IP_GET_NETMASK(*call),
    19421941                    IP_GET_GATEWAY(*call));
    19431942
    19441943        case NET_IP_SET_GATEWAY:
    1945                 return ip_set_gateway_req_local(0, IPC_GET_DEVICE(*call),
     1944                return ip_set_gateway_req_local(IPC_GET_DEVICE(*call),
    19461945                    IP_GET_GATEWAY(*call));
    19471946
     
    19521951                        return rc;
    19531952               
    1954                 rc = ip_get_route_req_local(0, IP_GET_PROTOCOL(*call), addr,
     1953                rc = ip_get_route_req_local(IP_GET_PROTOCOL(*call), addr,
    19551954                    (socklen_t) addrlen, &device_id, &header, &headerlen);
    19561955                if (rc != EOK)
     
    19831982       
    19841983        case NET_IP_SEND:
    1985                 rc = packet_translate_remote(ip_globals.net_phone, &packet,
     1984                rc = packet_translate_remote(ip_globals.net_sess, &packet,
    19861985                    IPC_GET_PACKET(*call));
    19871986                if (rc != EOK)
    19881987                        return rc;
    19891988               
    1990                 return ip_send_msg_local(0, IPC_GET_DEVICE(*call), packet, 0,
     1989                return ip_send_msg_local(IPC_GET_DEVICE(*call), packet, 0,
    19911990                    IPC_GET_ERROR(*call));
    19921991        }
  • uspace/srv/net/il/ip/ip.h

    r55091847 r6b82009  
    3838#define NET_IP_H_
    3939
     40#include <async.h>
    4041#include <fibril_synch.h>
    4142#include <ipc/services.h>
     
    9899        /** Packet dimension. */
    99100        packet_dimension_t packet_dimension;
    100         /** Netif module phone. */
    101         int phone;
     101        /** Netif module session. */
     102        async_sess_t *sess;
    102103        /** Routing table. */
    103104        ip_routes_t routes;
     
    112113/** IP protocol specific data. */
    113114struct ip_proto {
    114         /** Protocol module phone. */
    115         int phone;
     115        /** Protocol module session. */
     116        async_sess_t *sess;
    116117        /** Protocol number. */
    117118        int protocol;
     
    142143        /** Known support modules. */
    143144        modules_t modules;
    144         /** Networking module phone. */
    145         int net_phone;
     145        /** Networking module session. */
     146        async_sess_t *net_sess;
    146147        /** Registered network interfaces. */
    147148        ip_netifs_t netifs;
  • uspace/srv/net/net/net.c

    r55091847 r6b82009  
    3636 */
    3737
    38 #include "net.h"
    39 
    4038#include <async.h>
    4139#include <ctype.h>
    4240#include <ddi.h>
    43 #include <ns.h>
    4441#include <errno.h>
    4542#include <malloc.h>
     
    4744#include <str.h>
    4845#include <str_error.h>
    49 
     46#include <ns.h>
    5047#include <ipc/services.h>
    5148#include <ipc/net.h>
     
    5350#include <ipc/il.h>
    5451#include <ipc/nil.h>
    55 
    5652#include <net/modules.h>
    5753#include <net/packet.h>
    5854#include <net/device.h>
    59 
    6055#include <adt/char_map.h>
    6156#include <adt/generic_char_map.h>
    6257#include <adt/measured_strings.h>
    6358#include <adt/module_map.h>
    64 
    6559#include <netif_remote.h>
    6660#include <nil_remote.h>
    6761#include <net_interface.h>
    6862#include <ip_interface.h>
     63#include "net.h"
    6964
    7065/** Networking module name. */
     
    394389}
    395390
    396 int net_get_conf_req(int net_phone, measured_string_t **configuration,
     391static int net_get_conf_req_local(measured_string_t **configuration,
    397392    size_t count, uint8_t **data)
    398393{
     
    403398}
    404399
    405 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,
    406401    measured_string_t **configuration, size_t count, uint8_t **data)
    407402{
     
    479474        uintptr_t io = setting ? strtol((char *) setting->value, NULL, 16) : 0;
    480475       
    481         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);
    482477        if (rc != EOK)
    483478                return rc;
    484479       
    485480        /* Network interface layer startup */
    486         services_t internet_service;
    487481        if (netif->nil) {
    488482                setting = measured_strings_find(&netif->configuration, (uint8_t *) CONF_MTU, 0);
     
    493487                int mtu = setting ? strtol((char *) setting->value, NULL, 10) : 0;
    494488               
    495                 rc = nil_device_req(netif->nil->phone, netif->id, mtu,
    496                     netif->driver->service);
     489                rc = nil_device_req(netif->nil->sess, netif->id, mtu);
    497490                if (rc != EOK)
    498491                        return rc;
    499                
    500                 internet_service = netif->nil->service;
    501         } else
    502                 internet_service = netif->driver->service;
     492        }
    503493       
    504494        /* Inter-network layer startup */
    505         switch (netif->il->service) {
    506         case SERVICE_IP:
    507                 rc = ip_device_req(netif->il->phone, netif->id,
    508                     internet_service);
    509                 if (rc != EOK)
    510                         return rc;
    511                 break;
    512         default:
    513                 return ENOENT;
    514         }
    515        
    516         return netif_start_req(netif->driver->phone, netif->id);
     495        rc = ip_device_req(netif->il->sess, netif->id);
     496        if (rc != EOK)
     497                return rc;
     498       
     499        return netif_start_req(netif->driver->sess, netif->id);
    517500}
    518501
     
    649632                if (rc != EOK)
    650633                        return rc;
    651                 net_get_device_conf_req(0, IPC_GET_DEVICE(*call), &strings,
     634                net_get_device_conf_req_local(IPC_GET_DEVICE(*call), &strings,
    652635                    IPC_GET_COUNT(*call), NULL);
    653636               
     
    663646                if (rc != EOK)
    664647                        return rc;
    665                 net_get_conf_req(0, &strings, IPC_GET_COUNT(*call), NULL);
     648                net_get_conf_req_local(&strings, IPC_GET_COUNT(*call), NULL);
    666649               
    667650                /* Strings should not contain received data anymore */
     
    683666 * @param[in] icall The initial message call structure.
    684667 * @param[in] arg   Local argument.
     668 *
    685669 */
    686670static void net_client_connection(ipc_callid_t iid, ipc_call_t *icall,
  • uspace/srv/net/netif/lo/lo.c

    r55091847 r6b82009  
    148148        null_device_stats((device_stats_t *) (*device)->specific);
    149149        (*device)->device_id = device_id;
    150         (*device)->nil_phone = -1;
    151150        (*device)->state = NETIF_STOPPED;
    152151        int index = netif_device_map_add(&netif_globals.device_map,
     
    202201        } while (next);
    203202       
    204         int phone = device->nil_phone;
     203        async_sess_t *nil_sess = netif_globals.nil_sess;
    205204        fibril_rwlock_write_unlock(&netif_globals.lock);
    206205       
    207         nil_received_msg(phone, device_id, packet, sender);
     206        nil_received_msg(nil_sess, device_id, packet, sender);
    208207       
    209208        fibril_rwlock_write_lock(&netif_globals.lock);
     
    226225{
    227226        /* Start the module */
    228         return netif_module_start();
     227        return netif_module_start(SERVICE_NILDUMMY);
    229228}
    230229
  • uspace/srv/net/nil/eth/eth.c

    r55091847 r6b82009  
    5959#include <packet_remote.h>
    6060#include <nil_skel.h>
    61 
    62 // FIXME: remove this header
    63 #include <kernel/ipc/ipc_methods.h>
    64 
    6561#include "eth.h"
    6662
     
    171167INT_MAP_IMPLEMENT(eth_protos, eth_proto_t);
    172168
    173 int nil_device_state_msg_local(int nil_phone, device_id_t device_id, int state)
     169int nil_device_state_msg_local(device_id_t device_id, sysarg_t state)
    174170{
    175171        int index;
     
    180176            index--) {
    181177                proto = eth_protos_get_index(&eth_globals.protos, index);
    182                 if (proto && proto->phone) {
    183                         il_device_state_msg(proto->phone, device_id, state,
     178                if ((proto) && (proto->sess)) {
     179                        il_device_state_msg(proto->sess, device_id, state,
    184180                            proto->service);
    185181                }
     
    190186}
    191187
    192 int nil_initialize(int net_phone)
     188int nil_initialize(async_sess_t *sess)
    193189{
    194190        int rc;
     
    199195        fibril_rwlock_write_lock(&eth_globals.devices_lock);
    200196        fibril_rwlock_write_lock(&eth_globals.protos_lock);
    201         eth_globals.net_phone = net_phone;
     197        eth_globals.net_sess = sess;
    202198
    203199        eth_globals.broadcast_addr =
     
    226222}
    227223
    228 /** Processes IPC messages from the registered device driver modules in an
     224/** Process IPC messages from the registered device driver modules in an
    229225 * infinite loop.
    230226 *
    231  * @param[in] iid       The message identifier.
    232  * @param[in,out] icall The message parameters.
    233  * @param[in] arg       Local argument.
     227 * @param[in]     iid   Message identifier.
     228 * @param[in,out] icall Message parameters.
     229 * @param[in]     arg   Local argument.
     230 *
    234231 */
    235232static void eth_receiver(ipc_callid_t iid, ipc_call_t *icall, void *arg)
     
    241238                switch (IPC_GET_IMETHOD(*icall)) {
    242239                case NET_NIL_DEVICE_STATE:
    243                         nil_device_state_msg_local(0, IPC_GET_DEVICE(*icall),
     240                        nil_device_state_msg_local(IPC_GET_DEVICE(*icall),
    244241                            IPC_GET_STATE(*icall));
    245242                        async_answer_0(iid, EOK);
    246243                        break;
    247244                case NET_NIL_RECEIVED:
    248                         rc = packet_translate_remote(eth_globals.net_phone,
     245                        rc = packet_translate_remote(eth_globals.net_sess,
    249246                            &packet, IPC_GET_PACKET(*icall));
    250247                        if (rc == EOK)
    251                                 rc = nil_received_msg_local(0,
    252                                     IPC_GET_DEVICE(*icall), packet, 0);
     248                                rc = nil_received_msg_local(IPC_GET_DEVICE(*icall),
     249                                    packet, 0);
    253250                       
    254251                        async_answer_0(iid, (sysarg_t) rc);
     
    326323                        proto = eth_protos_get_index(&eth_globals.protos,
    327324                            index);
    328                         if (proto->phone) {
    329                                 il_mtu_changed_msg(proto->phone,
     325                        if (proto->sess) {
     326                                il_mtu_changed_msg(proto->sess,
    330327                                    device->device_id, device->mtu,
    331328                                    proto->service);
     
    351348
    352349        configuration = &names[0];
    353         rc = net_get_device_conf_req(eth_globals.net_phone, device->device_id,
     350        rc = net_get_device_conf_req(eth_globals.net_sess, device->device_id,
    354351            &configuration, count, &data);
    355352        if (rc != EOK) {
     
    380377       
    381378        /* Bind the device driver */
    382         device->phone = netif_bind_service(device->service, device->device_id,
     379        device->sess = netif_bind_service(device->service, device->device_id,
    383380            SERVICE_ETHERNET, eth_receiver);
    384         if (device->phone < 0) {
     381        if (device->sess == NULL) {
    385382                fibril_rwlock_write_unlock(&eth_globals.devices_lock);
    386383                free(device);
    387                 return device->phone;
     384                return ENOENT;
    388385        }
    389386       
    390387        /* Get hardware address */
    391         rc = netif_get_addr_req(device->phone, device->device_id, &device->addr,
     388        rc = netif_get_addr_req(device->sess, device->device_id, &device->addr,
    392389            &device->addr_data);
    393390        if (rc != EOK) {
     
    509506}
    510507
    511 int nil_received_msg_local(int nil_phone, device_id_t device_id,
    512     packet_t *packet, services_t target)
     508int nil_received_msg_local(device_id_t device_id, packet_t *packet,
     509    services_t target)
    513510{
    514511        eth_proto_t *proto;
     
    532529                proto = eth_process_packet(flags, packet);
    533530                if (proto) {
    534                         il_received_msg(proto->phone, device_id, packet,
     531                        il_received_msg(proto->sess, device_id, packet,
    535532                            proto->service);
    536533                } else {
    537534                        /* Drop invalid/unknown */
    538                         pq_release_remote(eth_globals.net_phone,
     535                        pq_release_remote(eth_globals.net_sess,
    539536                            packet_get_id(packet));
    540537                }
     
    615612}
    616613
    617 /** Registers receiving module service.
    618  *
    619  * Passes received packets for this service.
    620  *
    621  * @param[in] service   The module service.
    622  * @param[in] phone     The service phone.
    623  * @return              EOK on success.
    624  * @return              ENOENT if the service is not known.
    625  * @return              ENOMEM if there is not enough memory left.
    626  */
    627 static int eth_register_message(services_t service, int phone)
     614/** Register receiving module service.
     615 *
     616 * Pass received packets for this service.
     617 *
     618 * @param[in] service Module service.
     619 * @param[in] sess    Service session.
     620 *
     621 * @return EOK on success.
     622 * @return ENOENT if the service is not known.
     623 * @return ENOMEM if there is not enough memory left.
     624 *
     625 */
     626static int eth_register_message(services_t service, async_sess_t *sess)
    628627{
    629628        eth_proto_t *proto;
     
    638637        proto = eth_protos_find(&eth_globals.protos, protocol);
    639638        if (proto) {
    640                 proto->phone = phone;
     639                proto->sess = sess;
    641640                fibril_rwlock_write_unlock(&eth_globals.protos_lock);
    642641                return EOK;
     
    650649                proto->service = service;
    651650                proto->protocol = protocol;
    652                 proto->phone = phone;
     651                proto->sess = sess;
    653652
    654653                index = eth_protos_add(&eth_globals.protos, protocol, proto);
     
    660659        }
    661660       
    662         printf("%s: Protocol registered (protocol: %d, service: %d, phone: "
    663             "%d)\n", NAME, proto->protocol, proto->service, proto->phone);
     661        printf("%s: Protocol registered (protocol: %d, service: %d)\n",
     662            NAME, proto->protocol, proto->service);
    664663       
    665664        fibril_rwlock_write_unlock(&eth_globals.protos_lock);
     
    799798        ethertype = htons(protocol_map(SERVICE_ETHERNET, sender));
    800799        if (!ethertype) {
    801                 pq_release_remote(eth_globals.net_phone, packet_get_id(packet));
     800                pq_release_remote(eth_globals.net_sess, packet_get_id(packet));
    802801                return EINVAL;
    803802        }
     
    820819                        if (next == packet)
    821820                                packet = tmp;
    822                         pq_release_remote(eth_globals.net_phone,
     821                        pq_release_remote(eth_globals.net_sess,
    823822                            packet_get_id(next));
    824823                        next = tmp;
     
    830829        /* Send packet queue */
    831830        if (packet) {
    832                 netif_send_msg(device->phone, device_id, packet,
     831                netif_send_msg(device->sess, device_id, packet,
    833832                    SERVICE_ETHERNET);
    834833        }
     
    854853                return EOK;
    855854       
     855        async_sess_t *callback =
     856            async_callback_receive_start(EXCHANGE_SERIALIZE, call);
     857        if (callback)
     858                return eth_register_message(NIL_GET_PROTO(*call), callback);
     859       
    856860        switch (IPC_GET_IMETHOD(*call)) {
    857861        case NET_NIL_DEVICE:
     
    859863                    IPC_GET_SERVICE(*call), IPC_GET_MTU(*call));
    860864        case NET_NIL_SEND:
    861                 rc = packet_translate_remote(eth_globals.net_phone, &packet,
     865                rc = packet_translate_remote(eth_globals.net_sess, &packet,
    862866                    IPC_GET_PACKET(*call));
    863867                if (rc != EOK)
     
    888892                        return EOK;
    889893                return measured_strings_reply(address, 1);
    890         case IPC_M_CONNECT_TO_ME:
    891                 return eth_register_message(NIL_GET_PROTO(*call),
    892                     IPC_GET_PHONE(*call));
    893894        }
    894895       
  • uspace/srv/net/nil/eth/eth.h

    r55091847 r6b82009  
    3838#define NET_ETH_H_
    3939
     40#include <async.h>
    4041#include <fibril_synch.h>
    4142#include <ipc/services.h>
    42 
    4343#include <net/device.h>
    4444#include <adt/measured_strings.h>
     
    223223        /** Device driver service. */
    224224        services_t service;
    225         /** Driver phone. */
    226         int phone;
     225        /** Driver session. */
     226        async_sess_t *sess;
    227227        /** Maximal transmission unit. */
    228228        size_t mtu;
     
    248248        /** Protocol identifier. */
    249249        int protocol;
    250         /** Protocol module phone. */
    251         int phone;
     250        /** Protocol module session. */
     251        async_sess_t *sess;
    252252};
    253253
    254254/** Ethernet global data. */
    255255struct eth_globals {
    256         /** Networking module phone. */
    257         int net_phone;
     256        /** Networking module session. */
     257        async_sess_t *net_sess;
    258258        /** Safety lock for devices. */
    259259        fibril_rwlock_t devices_lock;
     
    265265        /**
    266266         * Protocol map.
    267          * Service phone map for each protocol.
     267         * Service map for each protocol.
    268268         */
    269269        eth_protos_t protos;
  • uspace/srv/net/nil/nildummy/nildummy.c

    r55091847 r6b82009  
    4444#include <ipc/net.h>
    4545#include <ipc/services.h>
    46 
    4746#include <net/modules.h>
    4847#include <net/device.h>
     
    5352#include <netif_remote.h>
    5453#include <nil_skel.h>
    55 
    56 // FIXME: remove this header
    57 #include <kernel/ipc/ipc_methods.h>
    58 
    5954#include "nildummy.h"
    6055
     
    7065DEVICE_MAP_IMPLEMENT(nildummy_devices, nildummy_device_t);
    7166
    72 int nil_device_state_msg_local(int nil_phone, device_id_t device_id, int state)
     67int nil_device_state_msg_local(device_id_t device_id, sysarg_t state)
    7368{
    7469        fibril_rwlock_read_lock(&nildummy_globals.protos_lock);
    75         if (nildummy_globals.proto.phone)
    76                 il_device_state_msg(nildummy_globals.proto.phone, device_id,
     70        if (nildummy_globals.proto.sess)
     71                il_device_state_msg(nildummy_globals.proto.sess, device_id,
    7772                    state, nildummy_globals.proto.service);
    7873        fibril_rwlock_read_unlock(&nildummy_globals.protos_lock);
     
    8176}
    8277
    83 int nil_initialize(int net_phone)
     78int nil_initialize(async_sess_t *sess)
    8479{
    8580        fibril_rwlock_initialize(&nildummy_globals.devices_lock);
     
    8883        fibril_rwlock_write_lock(&nildummy_globals.protos_lock);
    8984       
    90         nildummy_globals.net_phone = net_phone;
    91         nildummy_globals.proto.phone = 0;
     85        nildummy_globals.net_sess = sess;
     86        nildummy_globals.proto.sess = NULL;
    9287        int rc = nildummy_devices_initialize(&nildummy_globals.devices);
    9388       
     
    10297 * @param[in]     iid   Message identifier.
    10398 * @param[in,out] icall Message parameters.
    104  * @param[in]     arg   Local argument.
     99 * @param[in]     arg    Local argument.
     100 *
    105101 */
    106102static void nildummy_receiver(ipc_callid_t iid, ipc_call_t *icall, void *arg)
     
    112108                switch (IPC_GET_IMETHOD(*icall)) {
    113109                case NET_NIL_DEVICE_STATE:
    114                         rc = nil_device_state_msg_local(0,
    115                             IPC_GET_DEVICE(*icall), IPC_GET_STATE(*icall));
     110                        rc = nil_device_state_msg_local(IPC_GET_DEVICE(*icall),
     111                            IPC_GET_STATE(*icall));
    116112                        async_answer_0(iid, (sysarg_t) rc);
    117113                        break;
    118114               
    119115                case NET_NIL_RECEIVED:
    120                         rc = packet_translate_remote(nildummy_globals.net_phone,
     116                        rc = packet_translate_remote(nildummy_globals.net_sess,
    121117                            &packet, IPC_GET_PACKET(*icall));
    122118                        if (rc == EOK)
    123                                 rc = nil_received_msg_local(0,
    124                                     IPC_GET_DEVICE(*icall), packet, 0);
     119                                rc = nil_received_msg_local(IPC_GET_DEVICE(*icall),
     120                                    packet, 0);
    125121                       
    126122                        async_answer_0(iid, (sysarg_t) rc);
     
    180176                /* Notify the upper layer module */
    181177                fibril_rwlock_read_lock(&nildummy_globals.protos_lock);
    182                 if (nildummy_globals.proto.phone) {
    183                         il_mtu_changed_msg(nildummy_globals.proto.phone,
     178                if (nildummy_globals.proto.sess) {
     179                        il_mtu_changed_msg(nildummy_globals.proto.sess,
    184180                            device->device_id, device->mtu,
    185181                            nildummy_globals.proto.service);
     
    203199
    204200        /* Bind the device driver */
    205         device->phone = netif_bind_service(device->service, device->device_id,
     201        device->sess = netif_bind_service(device->service, device->device_id,
    206202            SERVICE_ETHERNET, nildummy_receiver);
    207         if (device->phone < 0) {
     203        if (device->sess == NULL) {
    208204                fibril_rwlock_write_unlock(&nildummy_globals.devices_lock);
    209205                free(device);
    210                 return device->phone;
     206                return ENOENT;
    211207        }
    212208       
    213209        /* Get hardware address */
    214         int rc = netif_get_addr_req(device->phone, device->device_id,
     210        int rc = netif_get_addr_req(device->sess, device->device_id,
    215211            &device->addr, &device->addr_data);
    216212        if (rc != EOK) {
     
    307303}
    308304
    309 int nil_received_msg_local(int nil_phone, device_id_t device_id,
    310     packet_t *packet, services_t target)
     305int nil_received_msg_local(device_id_t device_id, packet_t *packet,
     306    services_t target)
    311307{
    312308        fibril_rwlock_read_lock(&nildummy_globals.protos_lock);
    313309       
    314         if (nildummy_globals.proto.phone) {
     310        if (nildummy_globals.proto.sess) {
    315311                do {
    316312                        packet_t *next = pq_detach(packet);
    317                         il_received_msg(nildummy_globals.proto.phone, device_id,
     313                        il_received_msg(nildummy_globals.proto.sess, device_id,
    318314                            packet, nildummy_globals.proto.service);
    319315                        packet = next;
     
    331327 *
    332328 * @param[in] service Module service.
    333  * @param[in] phone   Service phone.
     329 * @param[in] sess    Service session.
    334330 *
    335331 * @return EOK on success.
     
    338334 *
    339335 */
    340 static int nildummy_register_message(services_t service, int phone)
     336static int nildummy_register_message(services_t service, async_sess_t *sess)
    341337{
    342338        fibril_rwlock_write_lock(&nildummy_globals.protos_lock);
    343339        nildummy_globals.proto.service = service;
    344         nildummy_globals.proto.phone = phone;
    345        
    346         printf("%s: Protocol registered (service: %d, phone: %d)\n",
    347             NAME, nildummy_globals.proto.service, nildummy_globals.proto.phone);
     340        nildummy_globals.proto.sess = sess;
     341       
     342        printf("%s: Protocol registered (service: %d)\n",
     343            NAME, nildummy_globals.proto.service);
    348344       
    349345        fibril_rwlock_write_unlock(&nildummy_globals.protos_lock);
     
    376372        /* Send packet queue */
    377373        if (packet)
    378                 netif_send_msg(device->phone, device_id, packet,
     374                netif_send_msg(device->sess, device_id, packet,
    379375                    SERVICE_NILDUMMY);
    380376       
     
    400396                return EOK;
    401397       
     398        async_sess_t *callback =
     399            async_callback_receive_start(EXCHANGE_SERIALIZE, call);
     400        if (callback)
     401                return nildummy_register_message(NIL_GET_PROTO(*call), callback);
     402       
    402403        switch (IPC_GET_IMETHOD(*call)) {
    403404        case NET_NIL_DEVICE:
     
    406407       
    407408        case NET_NIL_SEND:
    408                 rc = packet_translate_remote(nildummy_globals.net_phone,
     409                rc = packet_translate_remote(nildummy_globals.net_sess,
    409410                    &packet, IPC_GET_PACKET(*call));
    410411                if (rc != EOK)
     
    436437                        return rc;
    437438                return measured_strings_reply(address, 1);
    438        
    439         case IPC_M_CONNECT_TO_ME:
    440                 return nildummy_register_message(NIL_GET_PROTO(*call),
    441                     IPC_GET_PHONE(*call));
    442439        }
    443440       
  • uspace/srv/net/nil/nildummy/nildummy.h

    r55091847 r6b82009  
    3838#define NET_NILDUMMY_H_
    3939
     40#include <async.h>
    4041#include <fibril_synch.h>
    4142#include <ipc/services.h>
    42 
    4343#include <net/device.h>
    4444#include <adt/measured_strings.h>
     
    8181        services_t service;
    8282       
    83         /** Driver phone. */
    84         int phone;
     83        /** Driver session. */
     84        async_sess_t *sess;
    8585       
    8686        /** Maximal transmission unit. */
     
    9999        services_t service;
    100100       
    101         /** Protocol module phone. */
    102         int phone;
     101        /** Protocol module session. */
     102        async_sess_t *sess;
    103103};
    104104
    105105/** Dummy nil global data. */
    106106struct nildummy_globals {
    107         /** Networking module phone. */
    108         int net_phone;
     107        /** Networking module session. */
     108        async_sess_t *net_sess;
    109109       
    110110        /** Lock for devices. */
  • uspace/srv/net/tl/icmp/icmp.c

    r55091847 r6b82009  
    118118
    119119/** Global data */
    120 static int phone_net = -1;
    121 static int phone_ip = -1;
     120static async_sess_t *net_sess = NULL;
     121static async_sess_t *ip_sess = NULL;
    122122static bool error_reporting = true;
    123123static bool echo_replying = true;
     
    173173static void icmp_release(packet_t *packet)
    174174{
    175         pq_release_remote(phone_net, packet_get_id(packet));
     175        pq_release_remote(net_sess, packet_get_id(packet));
    176176}
    177177
     
    225225        }
    226226       
    227         return ip_send_msg(phone_ip, -1, packet, SERVICE_ICMP, error);
     227        return ip_send_msg(ip_sess, -1, packet, SERVICE_ICMP, error);
    228228}
    229229
     
    297297        size_t length = (size_t) addrlen;
    298298       
    299         packet_t *packet = packet_get_4_remote(phone_net, size,
     299        packet_t *packet = packet_get_4_remote(net_sess, size,
    300300            icmp_dimension.addr_len, ICMP_HEADER_SIZE + icmp_dimension.prefix,
    301301            icmp_dimension.suffix);
     
    595595        case ICMP_SKIP:
    596596        case ICMP_PHOTURIS:
    597                 ip_received_error_msg(phone_ip, -1, packet,
     597                ip_received_error_msg(ip_sess, -1, packet,
    598598                    SERVICE_IP, SERVICE_ICMP);
    599599                return EOK;
     
    609609 * @param[in,out] icall Message parameters.
    610610 * @param[in]     arg   Local argument.
     611 *
    611612 */
    612613static void icmp_receiver(ipc_callid_t iid, ipc_call_t *icall, void *arg)
     
    621622                switch (IPC_GET_IMETHOD(*icall)) {
    622623                case NET_TL_RECEIVED:
    623                         rc = packet_translate_remote(phone_net, &packet,
     624                        rc = packet_translate_remote(net_sess, &packet,
    624625                            IPC_GET_PACKET(*icall));
    625626                        if (rc == EOK) {
     
    641642/** Initialize the ICMP module.
    642643 *
    643  * @param[in] net_phone Network module phone.
     644 * @param[in] sess Network module session.
    644645 *
    645646 * @return EOK on success.
     
    647648 *
    648649 */
    649 int tl_initialize(int net_phone)
     650int tl_initialize(async_sess_t *sess)
    650651{
    651652        measured_string_t names[] = {
     
    669670        atomic_set(&icmp_client, 0);
    670671       
    671         phone_net = net_phone;
    672         phone_ip = ip_bind_service(SERVICE_IP, IPPROTO_ICMP, SERVICE_ICMP,
     672        net_sess = sess;
     673        ip_sess = ip_bind_service(SERVICE_IP, IPPROTO_ICMP, SERVICE_ICMP,
    673674            icmp_receiver);
    674         if (phone_ip < 0)
    675                 return phone_ip;
    676        
    677         int rc = ip_packet_size_req(phone_ip, -1, &icmp_dimension);
     675        if (ip_sess == NULL)
     676                return ENOENT;
     677       
     678        int rc = ip_packet_size_req(ip_sess, -1, &icmp_dimension);
    678679        if (rc != EOK)
    679680                return rc;
     
    684685        /* Get configuration */
    685686        configuration = &names[0];
    686         rc = net_get_conf_req(phone_net, &configuration, count, &data);
     687        rc = net_get_conf_req(net_sess, &configuration, count, &data);
    687688        if (rc != EOK)
    688689                return rc;
     
    762763       
    763764        case NET_ICMP_DEST_UNREACH:
    764                 rc = packet_translate_remote(phone_net, &packet,
     765                rc = packet_translate_remote(net_sess, &packet,
    765766                    IPC_GET_PACKET(*call));
    766767                if (rc != EOK)
     
    771772       
    772773        case NET_ICMP_SOURCE_QUENCH:
    773                 rc = packet_translate_remote(phone_net, &packet,
     774                rc = packet_translate_remote(net_sess, &packet,
    774775                    IPC_GET_PACKET(*call));
    775776                if (rc != EOK)
     
    779780       
    780781        case NET_ICMP_TIME_EXCEEDED:
    781                 rc = packet_translate_remote(phone_net, &packet,
     782                rc = packet_translate_remote(net_sess, &packet,
    782783                    IPC_GET_PACKET(*call));
    783784                if (rc != EOK)
     
    787788       
    788789        case NET_ICMP_PARAMETERPROB:
    789                 rc = packet_translate_remote(phone_net, &packet,
     790                rc = packet_translate_remote(net_sess, &packet,
    790791                    IPC_GET_PACKET(*call));
    791792                if (rc != EOK)
  • uspace/srv/net/tl/tcp/tcp.c

    r55091847 r6b82009  
    3838#include <assert.h>
    3939#include <async.h>
    40 #include <async_obsolete.h>
    4140#include <fibril_synch.h>
    4241#include <malloc.h>
     
    7473#include "tcp_header.h"
    7574
    76 // FIXME: remove this header
    77 #include <kernel/ipc/ipc_methods.h>
    78 
    7975/** TCP module name. */
    8076#define NAME  "tcp"
     
    210206
    211207static int tcp_received_msg(device_id_t, packet_t *, services_t, services_t);
    212 static int tcp_process_client_messages(ipc_callid_t, ipc_call_t);
     208static int tcp_process_client_messages(async_sess_t *, ipc_callid_t,
     209    ipc_call_t);
    213210
    214211static int tcp_listen_message(socket_cores_t *, int, int);
     
    328325
    329326        if (!socket) {
    330                 if (tl_prepare_icmp_packet(tcp_globals.net_phone,
    331                     tcp_globals.icmp_phone, packet, error) == EOK) {
    332                         icmp_destination_unreachable_msg(tcp_globals.icmp_phone,
     327                if (tl_prepare_icmp_packet(tcp_globals.net_sess,
     328                    tcp_globals.icmp_sess, packet, error) == EOK) {
     329                        icmp_destination_unreachable_msg(tcp_globals.icmp_sess,
    333330                            ICMP_PORT_UNREACH, 0, packet);
    334331                }
     
    401398                fibril_rwlock_write_unlock(socket_data->local_lock);
    402399
    403                 rc = tl_prepare_icmp_packet(tcp_globals.net_phone,
    404                     tcp_globals.icmp_phone, packet, error);
     400                rc = tl_prepare_icmp_packet(tcp_globals.net_sess,
     401                    tcp_globals.icmp_sess, packet, error);
    405402                if (rc == EOK) {
    406403                        /* Checksum error ICMP */
    407                         icmp_parameter_problem_msg(tcp_globals.icmp_phone,
     404                        icmp_parameter_problem_msg(tcp_globals.icmp_sess,
    408405                            ICMP_PARAM_POINTER,
    409406                            ((size_t) ((void *) &header->checksum)) -
     
    443440                break;
    444441        default:
    445                 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
     442                pq_release_remote(tcp_globals.net_sess, packet_get_id(packet));
    446443        }
    447444
     
    506503                        /* Release the acknowledged packets */
    507504                        next_packet = pq_next(packet);
    508                         pq_release_remote(tcp_globals.net_phone,
     505                        pq_release_remote(tcp_globals.net_sess,
    509506                            packet_get_id(packet));
    510507                        packet = next_packet;
     
    565562                        next_packet = pq_next(next_packet);
    566563                        pq_insert_after(tmp_packet, next_packet);
    567                         pq_release_remote(tcp_globals.net_phone,
     564                        pq_release_remote(tcp_globals.net_sess,
    568565                            packet_get_id(tmp_packet));
    569566                }
     
    602599                                if (packet == socket_data->incoming)
    603600                                        socket_data->incoming = next_packet;
    604                                 pq_release_remote(tcp_globals.net_phone,
     601                                pq_release_remote(tcp_globals.net_sess,
    605602                                    packet_get_id(packet));
    606603                                packet = next_packet;
     
    625622                                if (length <= 0) {
    626623                                        /* Remove the empty packet */
    627                                         pq_release_remote(tcp_globals.net_phone,
     624                                        pq_release_remote(tcp_globals.net_sess,
    628625                                            packet_get_id(packet));
    629626                                        packet = next_packet;
     
    672669                                }
    673670                                /* Remove the duplicit or corrupted packet */
    674                                 pq_release_remote(tcp_globals.net_phone,
     671                                pq_release_remote(tcp_globals.net_sess,
    675672                                    packet_get_id(packet));
    676673                                packet = next_packet;
     
    699696                if (rc != EOK) {
    700697                        /* Remove the corrupted packets */
    701                         pq_release_remote(tcp_globals.net_phone,
     698                        pq_release_remote(tcp_globals.net_sess,
    702699                            packet_get_id(packet));
    703                         pq_release_remote(tcp_globals.net_phone,
     700                        pq_release_remote(tcp_globals.net_sess,
    704701                            packet_get_id(next_packet));
    705702                } else {
     
    712709                                    new_sequence_number, length);
    713710                                if (rc != EOK) {
    714                                         pq_release_remote(tcp_globals.net_phone,
     711                                        pq_release_remote(tcp_globals.net_sess,
    715712                                            packet_get_id(next_packet));
    716713                                }
    717714                                rc = pq_insert_after(packet, next_packet);
    718715                                if (rc != EOK) {
    719                                         pq_release_remote(tcp_globals.net_phone,
     716                                        pq_release_remote(tcp_globals.net_sess,
    720717                                            packet_get_id(next_packet));
    721718                                }
     
    726723                printf("unexpected\n");
    727724                /* Release duplicite or restricted */
    728                 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
     725                pq_release_remote(tcp_globals.net_sess, packet_get_id(packet));
    729726                forced_ack = true;
    730727        }
     
    794791        if (rc != EOK)
    795792                return tcp_release_and_return(packet, rc);
    796         rc = tl_get_ip_packet_dimension(tcp_globals.ip_phone,
     793        rc = tl_get_ip_packet_dimension(tcp_globals.ip_sess,
    797794            &tcp_globals.dimensions, socket_data->device_id, &packet_dimension);
    798795        if (rc != EOK)
     
    803800
    804801        /* Notify the destination socket */
    805         async_obsolete_msg_5(socket->phone, NET_SOCKET_RECEIVED,
    806             (sysarg_t) socket->socket_id,
     802        async_exch_t *exch = async_exchange_begin(socket->sess);
     803        async_msg_5(exch, NET_SOCKET_RECEIVED, (sysarg_t) socket->socket_id,
    807804            ((packet_dimension->content < socket_data->data_fragment_size) ?
    808805            packet_dimension->content : socket_data->data_fragment_size), 0, 0,
    809806            (sysarg_t) fragments);
     807        async_exchange_end(exch);
    810808
    811809        return EOK;
     
    824822
    825823        /* Notify the destination socket */
    826         async_obsolete_msg_5(socket->phone, NET_SOCKET_RECEIVED,
    827             (sysarg_t) socket->socket_id,
    828             0, 0, 0,
    829             (sysarg_t) 0 /* 0 fragments == no more data */);
     824        async_exch_t *exch = async_exchange_begin(socket->sess);
     825        async_msg_5(exch, NET_SOCKET_RECEIVED, (sysarg_t) socket->socket_id,
     826            0, 0, 0, (sysarg_t) 0 /* 0 fragments == no more data */);
     827        async_exchange_end(exch);
    830828}
    831829
     
    853851        next_packet = pq_detach(packet);
    854852        if (next_packet) {
    855                 pq_release_remote(tcp_globals.net_phone,
     853                pq_release_remote(tcp_globals.net_sess,
    856854                    packet_get_id(next_packet));
    857855        }
     
    940938        /* Create a socket */
    941939        socket_id = -1;
    942         rc = socket_create(socket_data->local_sockets, listening_socket->phone,
     940        rc = socket_create(socket_data->local_sockets, listening_socket->sess,
    943941            socket_data, &socket_id);
    944942        if (rc != EOK) {
     
    993991        fibril_rwlock_write_unlock(&tcp_globals.lock);
    994992        if (rc != EOK) {
    995                 socket_destroy(tcp_globals.net_phone, socket->socket_id,
     993                socket_destroy(tcp_globals.net_sess, socket->socket_id,
    996994                    socket_data->local_sockets, &tcp_globals.sockets,
    997995                    tcp_free_socket_data);
     
    10051003        next_packet = pq_detach(packet);
    10061004        if (next_packet) {
    1007                 pq_release_remote(tcp_globals.net_phone,
     1005                pq_release_remote(tcp_globals.net_sess,
    10081006                    packet_get_id(next_packet));
    10091007        }
     
    10141012                    packet_get_data_length(packet) - sizeof(*header));
    10151013                if (rc != EOK) {
    1016                         socket_destroy(tcp_globals.net_phone, socket->socket_id,
     1014                        socket_destroy(tcp_globals.net_sess, socket->socket_id,
    10171015                            socket_data->local_sockets, &tcp_globals.sockets,
    10181016                            tcp_free_socket_data);
     
    10251023        rc = tcp_queue_packet(socket, socket_data, packet, 1);
    10261024        if (rc != EOK) {
    1027                 socket_destroy(tcp_globals.net_phone, socket->socket_id,
     1025                socket_destroy(tcp_globals.net_sess, socket->socket_id,
    10281026                    socket_data->local_sockets, &tcp_globals.sockets,
    10291027                    tcp_free_socket_data);
     
    10331031        packet = tcp_get_packets_to_send(socket, socket_data);
    10341032        if (!packet) {
    1035                 socket_destroy(tcp_globals.net_phone, socket->socket_id,
     1033                socket_destroy(tcp_globals.net_sess, socket->socket_id,
    10361034                    socket_data->local_sockets, &tcp_globals.sockets,
    10371035                    tcp_free_socket_data);
     
    10681066
    10691067        socket_data->next_incoming = ntohl(header->sequence_number); /* + 1; */
    1070         pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
     1068        pq_release_remote(tcp_globals.net_sess, packet_get_id(packet));
    10711069        socket_data->state = TCP_SOCKET_ESTABLISHED;
    10721070        listening_socket = socket_cores_find(socket_data->local_sockets,
     
    10821080                if (rc == EOK) {
    10831081                        /* Notify the destination socket */
    1084                         async_obsolete_msg_5(socket->phone, NET_SOCKET_ACCEPTED,
     1082                        async_exch_t *exch = async_exchange_begin(socket->sess);
     1083                        async_msg_5(exch, NET_SOCKET_ACCEPTED,
    10851084                            (sysarg_t) listening_socket->socket_id,
    10861085                            socket_data->data_fragment_size, TCP_HEADER_SIZE,
    10871086                            0, (sysarg_t) socket->socket_id);
     1087                        async_exchange_end(exch);
    10881088
    10891089                        fibril_rwlock_write_unlock(socket_data->local_lock);
     
    11811181                                /* Add to acknowledged or release */
    11821182                                if (pq_add(&acknowledged, packet, 0, 0) != EOK)
    1183                                         pq_release_remote(tcp_globals.net_phone,
     1183                                        pq_release_remote(tcp_globals.net_sess,
    11841184                                            packet_get_id(packet));
    11851185                                packet = next;
     
    11901190                /* Release acknowledged */
    11911191                if (acknowledged) {
    1192                         pq_release_remote(tcp_globals.net_phone,
     1192                        pq_release_remote(tcp_globals.net_sess,
    11931193                            packet_get_id(acknowledged));
    11941194                }
     
    12341234        assert(answer);
    12351235        assert(answer_count);
    1236 
     1236       
    12371237        *answer_count = 0;
    1238         switch (IPC_GET_IMETHOD(*call)) {
    1239         case IPC_M_CONNECT_TO_ME:
    1240                 return tcp_process_client_messages(callid, *call);
    1241         }
    1242 
     1238       
     1239        async_sess_t *callback =
     1240            async_callback_receive_start(EXCHANGE_SERIALIZE, call);
     1241        if (callback)
     1242                return tcp_process_client_messages(callback, callid, *call);
     1243       
    12431244        return ENOTSUP;
    12441245}
     
    12701271}
    12711272
    1272 int tcp_process_client_messages(ipc_callid_t callid, ipc_call_t call)
     1273int tcp_process_client_messages(async_sess_t *sess, ipc_callid_t callid,
     1274    ipc_call_t call)
    12731275{
    12741276        int res;
    12751277        socket_cores_t local_sockets;
    1276         int app_phone = IPC_GET_PHONE(call);
    12771278        struct sockaddr *addr;
    12781279        int socket_id;
     
    13251326                        fibril_rwlock_write_lock(&lock);
    13261327                        socket_id = SOCKET_GET_SOCKET_ID(call);
    1327                         res = socket_create(&local_sockets, app_phone,
     1328                        res = socket_create(&local_sockets, sess,
    13281329                            socket_data, &socket_id);
    13291330                        SOCKET_SET_SOCKET_ID(answer, socket_id);
     
    13331334                                break;
    13341335                        }
    1335                         if (tl_get_ip_packet_dimension(tcp_globals.ip_phone,
     1336                        if (tl_get_ip_packet_dimension(tcp_globals.ip_sess,
    13361337                            &tcp_globals.dimensions, DEVICE_INVALID_ID,
    13371338                            &packet_dimension) == EOK) {
     
    15081509        }
    15091510
    1510         /* Release the application phone */
    1511         async_obsolete_hangup(app_phone);
     1511        /* Release the application session */
     1512        async_hangup(sess);
    15121513
    15131514        printf("release\n");
    15141515        /* Release all local sockets */
    1515         socket_cores_release(tcp_globals.net_phone, &local_sockets,
     1516        socket_cores_release(tcp_globals.net_sess, &local_sockets,
    15161517            &tcp_globals.sockets, tcp_free_socket_data);
    15171518
     
    16211622                        local_lock = socket_data->local_lock;
    16221623                        fibril_rwlock_write_lock(local_lock);
    1623                         socket_destroy(tcp_globals.net_phone,
     1624                        socket_destroy(tcp_globals.net_sess,
    16241625                            timeout->socket_id, timeout->local_sockets,
    16251626                            &tcp_globals.sockets, tcp_free_socket_data);
     
    17541755        }
    17551756
    1756         rc = ip_get_route_req(tcp_globals.ip_phone, IPPROTO_TCP,
     1757        rc = ip_get_route_req(tcp_globals.ip_sess, IPPROTO_TCP,
    17571758            addr, addrlen, &socket_data->device_id,
    17581759            &socket_data->pseudo_header, &socket_data->headerlen);
     
    19021903                        rc = pq_insert_after(previous, copy);
    19031904                        if (rc != EOK) {
    1904                                 pq_release_remote(tcp_globals.net_phone,
     1905                                pq_release_remote(tcp_globals.net_sess,
    19051906                                    packet_get_id(copy));
    19061907                                return sending;
     
    19391940            socket_data->headerlen, packet_get_data_length(packet));
    19401941        if (rc != EOK) {
    1941                 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
     1942                pq_release_remote(tcp_globals.net_sess, packet_get_id(packet));
    19421943                return NULL;
    19431944        }
     
    19461947        header = (tcp_header_t *) packet_get_data(packet);
    19471948        if (!header) {
    1948                 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
     1949                pq_release_remote(tcp_globals.net_sess, packet_get_id(packet));
    19491950                return NULL;
    19501951        }
     
    19711972        rc = ip_client_prepare_packet(packet, IPPROTO_TCP, 0, 0, 0, 0);
    19721973        if (rc != EOK) {
    1973                 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
     1974                pq_release_remote(tcp_globals.net_sess, packet_get_id(packet));
    19741975                return NULL;
    19751976        }
     
    19781979            sequence_number, socket_data->state, socket_data->timeout, true);
    19791980        if (rc != EOK) {
    1980                 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
     1981                pq_release_remote(tcp_globals.net_sess, packet_get_id(packet));
    19811982                return NULL;
    19821983        }
     
    19951996
    19961997        /* Make a copy of the packet */
    1997         copy = packet_get_copy(tcp_globals.net_phone, packet);
     1998        copy = packet_get_copy(tcp_globals.net_sess, packet);
    19981999        if (!copy)
    19992000                return NULL;
     
    20092010        while (packet) {
    20102011                next = pq_detach(packet);
    2011                 ip_send_msg(tcp_globals.ip_phone, device_id, packet,
     2012                ip_send_msg(tcp_globals.ip_sess, device_id, packet,
    20122013                    SERVICE_TCP, 0);
    20132014                packet = next;
     
    21222123                return NO_DATA;
    21232124
    2124         rc = packet_translate_remote(tcp_globals.net_phone, &packet, packet_id);
     2125        rc = packet_translate_remote(tcp_globals.net_sess, &packet, packet_id);
    21252126        if (rc != EOK)
    21262127                return rc;
     
    21332134        /* Release the packet */
    21342135        dyn_fifo_pop(&socket->received);
    2135         pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
     2136        pq_release_remote(tcp_globals.net_sess, packet_get_id(packet));
    21362137
    21372138        /* Return the total length */
     
    21712172                return ENOTCONN;
    21722173
    2173         rc = tl_get_ip_packet_dimension(tcp_globals.ip_phone,
     2174        rc = tl_get_ip_packet_dimension(tcp_globals.ip_sess,
    21742175            &tcp_globals.dimensions, socket_data->device_id, &packet_dimension);
    21752176        if (rc != EOK)
     
    21822183        for (index = 0; index < fragments; index++) {
    21832184                /* Read the data fragment */
    2184                 result = tl_socket_read_packet_data(tcp_globals.net_phone,
     2185                result = tl_socket_read_packet_data(tcp_globals.net_sess,
    21852186                    &packet, TCP_HEADER_SIZE, packet_dimension,
    21862187                    socket_data->addr, socket_data->addrlen);
     
    22452246        default:
    22462247                /* Just destroy */
    2247                 rc = socket_destroy(tcp_globals.net_phone, socket_id,
     2248                rc = socket_destroy(tcp_globals.net_sess, socket_id,
    22482249                    local_sockets, &tcp_globals.sockets,
    22492250                    tcp_free_socket_data);
     
    22932294
    22942295        /* Get the device packet dimension */
    2295         rc = tl_get_ip_packet_dimension(tcp_globals.ip_phone,
     2296        rc = tl_get_ip_packet_dimension(tcp_globals.ip_sess,
    22962297            &tcp_globals.dimensions, socket_data->device_id, &packet_dimension);
    22972298        if (rc != EOK)
     
    22992300
    23002301        /* Get a new packet */
    2301         *packet = packet_get_4_remote(tcp_globals.net_phone, TCP_HEADER_SIZE,
     2302        *packet = packet_get_4_remote(tcp_globals.net_sess, TCP_HEADER_SIZE,
    23022303            packet_dimension->addr_len, packet_dimension->prefix,
    23032304            packet_dimension->suffix);
     
    23622363                        if (rc != EOK)
    23632364                                return rc;
    2364                         rc = tl_get_ip_packet_dimension(tcp_globals.ip_phone,
     2365                        rc = tl_get_ip_packet_dimension(tcp_globals.ip_sess,
    23652366                            &tcp_globals.dimensions, socket_data->device_id,
    23662367                            &packet_dimension);
     
    24342435int tcp_release_and_return(packet_t *packet, int result)
    24352436{
    2436         pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
     2437        pq_release_remote(tcp_globals.net_sess, packet_get_id(packet));
    24372438        return result;
    24382439}
     
    24432444 * @param[in,out] icall Message parameters.
    24442445 * @param[in]     arg   Local argument.
     2446 *
    24452447 */
    24462448static void tcp_receiver(ipc_callid_t iid, ipc_call_t *icall, void *arg)
     
    24522454                switch (IPC_GET_IMETHOD(*icall)) {
    24532455                case NET_TL_RECEIVED:
    2454                         rc = packet_translate_remote(tcp_globals.net_phone, &packet,
     2456                        rc = packet_translate_remote(tcp_globals.net_sess, &packet,
    24552457                            IPC_GET_PACKET(*icall));
    24562458                        if (rc == EOK)
     
    24702472/** Initialize the TCP module.
    24712473 *
    2472  * @param[in] net_phone Network module phone.
     2474 * @param[in] sess Network module session.
    24732475 *
    24742476 * @return EOK on success.
     
    24762478 *
    24772479 */
    2478 int tl_initialize(int net_phone)
     2480int tl_initialize(async_sess_t *sess)
    24792481{
    24802482        fibril_rwlock_initialize(&tcp_globals.lock);
    24812483        fibril_rwlock_write_lock(&tcp_globals.lock);
    24822484       
    2483         tcp_globals.net_phone = net_phone;
     2485        tcp_globals.net_sess = sess;
    24842486       
    2485         tcp_globals.icmp_phone = icmp_connect_module();
    2486         tcp_globals.ip_phone = ip_bind_service(SERVICE_IP, IPPROTO_TCP,
     2487        tcp_globals.icmp_sess = icmp_connect_module();
     2488        tcp_globals.ip_sess = ip_bind_service(SERVICE_IP, IPPROTO_TCP,
    24872489            SERVICE_TCP, tcp_receiver);
    2488         if (tcp_globals.ip_phone < 0) {
     2490        if (tcp_globals.ip_sess == NULL) {
    24892491                fibril_rwlock_write_unlock(&tcp_globals.lock);
    2490                 return tcp_globals.ip_phone;
     2492                return ENOENT;
    24912493        }
    24922494       
  • uspace/srv/net/tl/tcp/tcp.h

    r55091847 r6b82009  
    3838#define NET_TCP_H_
    3939
     40#include <async.h>
    4041#include <fibril_synch.h>
    41 
    4242#include <net/packet.h>
    4343#include <net/device.h>
     
    284284/** TCP global data. */
    285285struct tcp_globals {
    286         /** Networking module phone. */
    287         int net_phone;
    288         /** IP module phone. */
    289         int ip_phone;
    290         /** ICMP module phone. */
    291         int icmp_phone;
     286        /** Networking module session. */
     287        async_sess_t *net_sess;
     288        /** IP module session. */
     289        async_sess_t *ip_sess;
     290        /** ICMP module session. */
     291        async_sess_t *icmp_sess;
    292292        /** Last used free port. */
    293293        int last_used_port;
  • uspace/srv/net/tl/udp/udp.c

    r55091847 r6b82009  
    3737
    3838#include <async.h>
    39 #include <async_obsolete.h>
    4039#include <fibril_synch.h>
    4140#include <malloc.h>
     
    7170#include "udp_header.h"
    7271
    73 // FIXME: remove this header
    74 #include <kernel/ipc/ipc_methods.h>
    75 
    7672/** UDP module name. */
    7773#define NAME  "udp"
     
    10399static int udp_release_and_return(packet_t *packet, int result)
    104100{
    105         pq_release_remote(udp_globals.net_phone, packet_get_id(packet));
     101        pq_release_remote(udp_globals.net_sess, packet_get_id(packet));
    106102        return result;
    107103}
     
    196192            ntohs(header->destination_port), (uint8_t *) SOCKET_MAP_KEY_LISTENING, 0);
    197193        if (!socket) {
    198                 if (tl_prepare_icmp_packet(udp_globals.net_phone,
    199                     udp_globals.icmp_phone, packet, error) == EOK) {
    200                         icmp_destination_unreachable_msg(udp_globals.icmp_phone,
     194                if (tl_prepare_icmp_packet(udp_globals.net_sess,
     195                    udp_globals.icmp_sess, packet, error) == EOK) {
     196                        icmp_destination_unreachable_msg(udp_globals.icmp_sess,
    201197                            ICMP_PORT_UNREACH, 0, packet);
    202198                }
     
    255251                        while (tmp_packet) {
    256252                                next_packet = pq_detach(tmp_packet);
    257                                 pq_release_remote(udp_globals.net_phone,
     253                                pq_release_remote(udp_globals.net_sess,
    258254                                    packet_get_id(tmp_packet));
    259255                                tmp_packet = next_packet;
     
    278274                if (flip_checksum(compact_checksum(checksum)) !=
    279275                    IP_CHECKSUM_ZERO) {
    280                         if (tl_prepare_icmp_packet(udp_globals.net_phone,
    281                             udp_globals.icmp_phone, packet, error) == EOK) {
     276                        if (tl_prepare_icmp_packet(udp_globals.net_sess,
     277                            udp_globals.icmp_sess, packet, error) == EOK) {
    282278                                /* Checksum error ICMP */
    283279                                icmp_parameter_problem_msg(
    284                                     udp_globals.icmp_phone, ICMP_PARAM_POINTER,
     280                                    udp_globals.icmp_sess, ICMP_PARAM_POINTER,
    285281                                    ((size_t) ((void *) &header->checksum)) -
    286282                                    ((size_t) ((void *) header)), packet);
     
    296292                return udp_release_and_return(packet, rc);
    297293               
    298         rc = tl_get_ip_packet_dimension(udp_globals.ip_phone,
     294        rc = tl_get_ip_packet_dimension(udp_globals.ip_sess,
    299295            &udp_globals.dimensions, device_id, &packet_dimension);
    300296        if (rc != EOK)
     
    303299        /* Notify the destination socket */
    304300        fibril_rwlock_write_unlock(&udp_globals.lock);
    305         async_obsolete_msg_5(socket->phone, NET_SOCKET_RECEIVED,
    306             (sysarg_t) socket->socket_id, packet_dimension->content, 0, 0,
    307             (sysarg_t) fragments);
     301       
     302        async_exch_t *exch = async_exchange_begin(socket->sess);
     303        async_msg_5(exch, NET_SOCKET_RECEIVED, (sysarg_t) socket->socket_id,
     304            packet_dimension->content, 0, 0, (sysarg_t) fragments);
     305        async_exchange_end(exch);
    308306
    309307        return EOK;
     
    342340 * @param[in,out] icall Message parameters.
    343341 * @param[in]     arg   Local argument.
     342 *
    344343 */
    345344static void udp_receiver(ipc_callid_t iid, ipc_call_t *icall, void *arg)
     
    351350                switch (IPC_GET_IMETHOD(*icall)) {
    352351                case NET_TL_RECEIVED:
    353                         rc = packet_translate_remote(udp_globals.net_phone, &packet,
     352                        rc = packet_translate_remote(udp_globals.net_sess, &packet,
    354353                            IPC_GET_PACKET(*icall));
    355354                        if (rc == EOK)
     
    369368/** Initialize the UDP module.
    370369 *
    371  * @param[in] net_phone Network module phone.
     370 * @param[in] sess Network module session.
    372371 *
    373372 * @return EOK on success.
     
    375374 *
    376375 */
    377 int tl_initialize(int net_phone)
     376int tl_initialize(async_sess_t *sess)
    378377{
    379378        measured_string_t names[] = {
     
    394393        fibril_rwlock_write_lock(&udp_globals.lock);
    395394       
    396         udp_globals.net_phone = net_phone;
    397        
    398         udp_globals.icmp_phone = icmp_connect_module();
    399        
    400         udp_globals.ip_phone = ip_bind_service(SERVICE_IP, IPPROTO_UDP,
    401             SERVICE_UDP, udp_receiver);
    402         if (udp_globals.ip_phone < 0) {
    403                 fibril_rwlock_write_unlock(&udp_globals.lock);
    404                 return udp_globals.ip_phone;
     395        udp_globals.net_sess = sess;
     396        udp_globals.icmp_sess = icmp_connect_module();
     397       
     398        udp_globals.ip_sess = ip_bind_service(SERVICE_IP, IPPROTO_UDP,
     399             SERVICE_UDP, udp_receiver);
     400        if (udp_globals.ip_sess == NULL) {
     401            fibril_rwlock_write_unlock(&udp_globals.lock);
     402            return ENOENT;
    405403        }
    406404       
    407405        /* Read default packet dimensions */
    408         int rc = ip_packet_size_req(udp_globals.ip_phone, -1,
     406        int rc = ip_packet_size_req(udp_globals.ip_sess, -1,
    409407            &udp_globals.packet_dimension);
    410408        if (rc != EOK) {
     
    435433        /* Get configuration */
    436434        configuration = &names[0];
    437         rc = net_get_conf_req(udp_globals.net_phone, &configuration, count,
     435        rc = net_get_conf_req(udp_globals.net_sess, &configuration, count,
    438436            &data);
    439437        if (rc != EOK) {
     
    529527
    530528        if (udp_globals.checksum_computing) {
    531                 rc = ip_get_route_req(udp_globals.ip_phone, IPPROTO_UDP, addr,
     529                rc = ip_get_route_req(udp_globals.ip_sess, IPPROTO_UDP, addr,
    532530                    addrlen, &device_id, &ip_header, &headerlen);
    533531                if (rc != EOK)
    534532                        return rc;
    535533                /* Get the device packet dimension */
    536 //              rc = tl_get_ip_packet_dimension(udp_globals.ip_phone,
     534//              rc = tl_get_ip_packet_dimension(udp_globals.ip_sess,
    537535//                  &udp_globals.dimensions, device_id, &packet_dimension);
    538536//              if (rc != EOK)
     
    541539//      } else {
    542540                /* Do not ask all the time */
    543                 rc = ip_packet_size_req(udp_globals.ip_phone, -1,
     541                rc = ip_packet_size_req(udp_globals.ip_sess, -1,
    544542                    &udp_globals.packet_dimension);
    545543                if (rc != EOK)
     
    559557
    560558        /* Read the first packet fragment */
    561         result = tl_socket_read_packet_data(udp_globals.net_phone, &packet,
     559        result = tl_socket_read_packet_data(udp_globals.net_sess, &packet,
    562560            UDP_HEADER_SIZE, packet_dimension, addr, addrlen);
    563561        if (result < 0)
     
    580578        /* Read the rest of the packet fragments */
    581579        for (index = 1; index < fragments; index++) {
    582                 result = tl_socket_read_packet_data(udp_globals.net_phone,
     580                result = tl_socket_read_packet_data(udp_globals.net_sess,
    583581                    &next_packet, 0, packet_dimension, addr, addrlen);
    584582                if (result < 0)
     
    632630
    633631        /* Send the packet */
    634         ip_send_msg(udp_globals.ip_phone, device_id, packet, SERVICE_UDP, 0);
     632        ip_send_msg(udp_globals.ip_sess, device_id, packet, SERVICE_UDP, 0);
    635633
    636634        return EOK;
     
    679677                return NO_DATA;
    680678       
    681         rc = packet_translate_remote(udp_globals.net_phone, &packet, packet_id);
     679        rc = packet_translate_remote(udp_globals.net_sess, &packet, packet_id);
    682680        if (rc != EOK) {
    683681                (void) dyn_fifo_pop(&socket->received);
     
    739737}
    740738
    741 /** Processes the socket client messages.
    742  *
    743  * Runs until the client module disconnects.
    744  *
    745  * @param[in] callid    The message identifier.
    746  * @param[in] call      The message parameters.
    747  * @return              EOK on success.
    748  *
    749  * @see socket.h
    750  */
    751 static int udp_process_client_messages(ipc_callid_t callid, ipc_call_t call)
     739/** Process the socket client messages.
     740 *
     741 * Run until the client module disconnects.
     742 *
     743 * @see socket.h
     744 *
     745 * @param[in] sess   Callback session.
     746 * @param[in] callid Message identifier.
     747 * @param[in] call   Message parameters.
     748 *
     749 * @return EOK on success.
     750 *
     751 */
     752static int udp_process_client_messages(async_sess_t *sess, ipc_callid_t callid,
     753    ipc_call_t call)
    752754{
    753755        int res;
    754756        socket_cores_t local_sockets;
    755         int app_phone = IPC_GET_PHONE(call);
    756757        struct sockaddr *addr;
    757758        int socket_id;
     
    786787                /* Get the next call */
    787788                callid = async_get_call(&call);
    788                
     789
     790                /* Process the call */
    789791                if (!IPC_GET_IMETHOD(call)) {
    790792                        res = EHANGUP;
    791793                        break;
    792794                }
    793 
    794                 /* Process the call */
     795               
    795796                switch (IPC_GET_IMETHOD(call)) {
    796797                case NET_SOCKET:
    797798                        socket_id = SOCKET_GET_SOCKET_ID(call);
    798                         res = socket_create(&local_sockets, app_phone, NULL,
     799                        res = socket_create(&local_sockets, sess, NULL,
    799800                            &socket_id);
    800801                        SOCKET_SET_SOCKET_ID(answer, socket_id);
     
    804805                       
    805806                        size = MAX_UDP_FRAGMENT_SIZE;
    806                         if (tl_get_ip_packet_dimension(udp_globals.ip_phone,
     807                        if (tl_get_ip_packet_dimension(udp_globals.ip_sess,
    807808                            &udp_globals.dimensions, DEVICE_INVALID_ID,
    808809                            &packet_dimension) == EOK) {
     
    868869                case NET_SOCKET_CLOSE:
    869870                        fibril_rwlock_write_lock(&udp_globals.lock);
    870                         res = socket_destroy(udp_globals.net_phone,
     871                        res = socket_destroy(udp_globals.net_sess,
    871872                            SOCKET_GET_SOCKET_ID(call), &local_sockets,
    872873                            &udp_globals.sockets, NULL);
     
    882883        }
    883884
    884         /* Release the application phone */
    885         async_obsolete_hangup(app_phone);
     885        /* Release the application session */
     886        async_hangup(sess);
    886887
    887888        /* Release all local sockets */
    888         socket_cores_release(udp_globals.net_phone, &local_sockets,
     889        socket_cores_release(udp_globals.net_sess, &local_sockets,
    889890            &udp_globals.sockets, NULL);
    890891
     
    916917{
    917918        *answer_count = 0;
    918 
    919         switch (IPC_GET_IMETHOD(*call)) {
    920         case IPC_M_CONNECT_TO_ME:
    921                 return udp_process_client_messages(callid, *call);
    922         }
    923 
     919       
     920        async_sess_t *callback =
     921            async_callback_receive_start(EXCHANGE_SERIALIZE, call);
     922        if (callback)
     923                return udp_process_client_messages(callback, callid, *call);
     924       
    924925        return ENOTSUP;
    925926}
  • uspace/srv/net/tl/udp/udp.h

    r55091847 r6b82009  
    3838#define NET_UDP_H_
    3939
     40#include <async.h>
    4041#include <fibril_synch.h>
    4142#include <socket_core.h>
     
    4950/** UDP global data. */
    5051struct udp_globals {
    51         /** Networking module phone. */
    52         int net_phone;
    53         /** IP module phone. */
    54         int ip_phone;
    55         /** ICMP module phone. */
    56         int icmp_phone;
     52        /** Networking module session. */
     53        async_sess_t *net_sess;
     54        /** IP module session. */
     55        async_sess_t *ip_sess;
     56        /** ICMP module session. */
     57        async_sess_t *icmp_sess;
    5758        /** Packet dimension. */
    5859        packet_dimension_t packet_dimension;
Note: See TracChangeset for help on using the changeset viewer.