Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/net/netif/netif_skel.c

    ree2fa30a rffa2c8ef  
    6161/** Probe the existence of the device.
    6262 *
     63 * @param[in] netif_phone Network interface phone.
    6364 * @param[in] device_id   Device identifier.
    6465 * @param[in] irq         Device interrupt number.
     
    7071 *
    7172 */
    72 static int netif_probe_req_local(device_id_t device_id, int irq, void *io)
     73static int netif_probe_req_local(int netif_phone, device_id_t device_id,
     74    int irq, void *io)
    7375{
    7476        fibril_rwlock_write_lock(&netif_globals.lock);
     
    8183/** Send the packet queue.
    8284 *
     85 * @param[in] netif_phone Network interface phone.
    8386 * @param[in] device_id   Device identifier.
    8487 * @param[in] packet      Packet queue.
     
    9093 *
    9194 */
    92 static int netif_send_msg_local(device_id_t device_id, packet_t *packet,
    93     services_t sender)
     95static int netif_send_msg_local(int netif_phone, device_id_t device_id,
     96    packet_t *packet, services_t sender)
    9497{
    9598        fibril_rwlock_write_lock(&netif_globals.lock);
     
    102105/** Start the device.
    103106 *
     107 * @param[in] netif_phone Network interface phone.
    104108 * @param[in] device_id   Device identifier.
    105109 *
     
    111115 *
    112116 */
    113 static int netif_start_req_local(device_id_t device_id)
     117static int netif_start_req_local(int netif_phone, device_id_t device_id)
    114118{
    115119        fibril_rwlock_write_lock(&netif_globals.lock);
     
    124128        int result = netif_start_message(device);
    125129        if (result > NETIF_NULL) {
    126                 nil_device_state_msg(netif_globals.nil_sess, device_id, result);
     130                int phone = device->nil_phone;
     131                nil_device_state_msg(phone, device_id, result);
    127132                fibril_rwlock_write_unlock(&netif_globals.lock);
    128133                return EOK;
     
    136141/** Stop the device.
    137142 *
     143 * @param[in] netif_phone Network interface phone.
    138144 * @param[in] device_id   Device identifier.
    139145 *
     
    145151 *
    146152 */
    147 static int netif_stop_req_local(device_id_t device_id)
     153static int netif_stop_req_local(int netif_phone, device_id_t device_id)
    148154{
    149155        fibril_rwlock_write_lock(&netif_globals.lock);
     
    158164        int result = netif_stop_message(device);
    159165        if (result > NETIF_NULL) {
    160                 nil_device_state_msg(netif_globals.nil_sess, device_id, result);
     166                int phone = device->nil_phone;
     167                nil_device_state_msg(phone, device_id, result);
    161168                fibril_rwlock_write_unlock(&netif_globals.lock);
    162169                return EOK;
     
    212219void netif_pq_release(packet_id_t packet_id)
    213220{
    214         pq_release_remote(netif_globals.sess, packet_id);
     221        pq_release_remote(netif_globals.net_phone, packet_id);
    215222}
    216223
     
    225232packet_t *netif_packet_get_1(size_t content)
    226233{
    227         return packet_get_1_remote(netif_globals.sess, content);
     234        return packet_get_1_remote(netif_globals.net_phone, content);
    228235}
    229236
    230237/** Register the device notification receiver,
    231238 *
    232  * Register a network interface layer module as the device
     239 * Register a  network interface layer module as the device
    233240 * notification receiver.
    234241 *
    235  * @param[in] sess      Session to the network interface layer module.
    236  *
    237  * @return EOK on success.
     242 * @param[in] device_id Device identifier.
     243 * @param[in] phone     Network interface layer module phone.
     244 *
     245 * @return EOK on success.
     246 * @return ENOENT if there is no such device.
    238247 * @return ELIMIT if there is another module registered.
    239248 *
    240249 */
    241 static int register_message(async_sess_t *sess)
    242 {
    243         fibril_rwlock_write_lock(&netif_globals.lock);
    244         if (netif_globals.nil_sess != NULL) {
    245                 fibril_rwlock_write_unlock(&netif_globals.lock);
     250static int register_message(device_id_t device_id, int phone)
     251{
     252        netif_device_t *device;
     253        int rc = find_device(device_id, &device);
     254        if (rc != EOK)
     255                return rc;
     256       
     257        if (device->nil_phone >= 0)
    246258                return ELIMIT;
    247         }
    248        
    249         netif_globals.nil_sess = sess;
    250        
    251         fibril_rwlock_write_unlock(&netif_globals.lock);
     259       
     260        device->nil_phone = phone;
    252261        return EOK;
    253262}
     
    279288        *count = 0;
    280289       
    281         if (!IPC_GET_IMETHOD(*call))
     290        switch (IPC_GET_IMETHOD(*call)) {
     291        case IPC_M_PHONE_HUNGUP:
    282292                return EOK;
    283293       
    284         async_sess_t *callback =
    285             async_callback_receive_start(EXCHANGE_SERIALIZE, call);
    286         if (callback)
    287                 return register_message(callback);
    288        
    289         switch (IPC_GET_IMETHOD(*call)) {
    290294        case NET_NETIF_PROBE:
    291                 return netif_probe_req_local(IPC_GET_DEVICE(*call),
     295                return netif_probe_req_local(0, IPC_GET_DEVICE(*call),
    292296                    NETIF_GET_IRQ(*call), NETIF_GET_IO(*call));
    293297       
     298        case IPC_M_CONNECT_TO_ME:
     299                fibril_rwlock_write_lock(&netif_globals.lock);
     300               
     301                rc = register_message(IPC_GET_DEVICE(*call), IPC_GET_PHONE(*call));
     302               
     303                fibril_rwlock_write_unlock(&netif_globals.lock);
     304                return rc;
     305       
    294306        case NET_NETIF_SEND:
    295                 rc = packet_translate_remote(netif_globals.sess, &packet,
     307                rc = packet_translate_remote(netif_globals.net_phone, &packet,
    296308                    IPC_GET_PACKET(*call));
    297309                if (rc != EOK)
    298310                        return rc;
    299311               
    300                 return netif_send_msg_local(IPC_GET_DEVICE(*call), packet,
     312                return netif_send_msg_local(0, IPC_GET_DEVICE(*call), packet,
    301313                    IPC_GET_SENDER(*call));
    302314       
    303315        case NET_NETIF_START:
    304                 return netif_start_req_local(IPC_GET_DEVICE(*call));
     316                return netif_start_req_local(0, IPC_GET_DEVICE(*call));
    305317       
    306318        case NET_NETIF_STATS:
     
    328340       
    329341        case NET_NETIF_STOP:
    330                 return netif_stop_req_local(IPC_GET_DEVICE(*call));
     342                return netif_stop_req_local(0, IPC_GET_DEVICE(*call));
    331343       
    332344        case NET_NETIF_GET_ADDR:
     
    350362 *
    351363 */
    352 static void netif_client_connection(ipc_callid_t iid, ipc_call_t *icall,
    353     void *arg)
     364static void netif_client_connection(ipc_callid_t iid, ipc_call_t *icall)
    354365{
    355366        /*
     
    374385               
    375386                /* End if said to either by the message or the processing result */
    376                 if ((!IPC_GET_IMETHOD(call)) || (res == EHANGUP))
     387                if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) ||
     388                    (res == EHANGUP))
    377389                        return;
    378390               
     
    397409        async_set_client_connection(netif_client_connection);
    398410       
    399         netif_globals.sess = connect_to_service(SERVICE_NETWORKING);
    400         netif_globals.nil_sess = NULL;
     411        netif_globals.net_phone = connect_to_service(SERVICE_NETWORKING);
    401412        netif_device_map_initialize(&netif_globals.device_map);
    402413       
Note: See TracChangeset for help on using the changeset viewer.