Changeset 70922c2 in mainline for uspace/srv


Ignore:
Timestamp:
2012-02-01T00:09:22Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ffcc5776
Parents:
cb3dbb63 (diff), 3d4750f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Mainline changes.

Location:
uspace/srv
Files:
4 edited

Legend:

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

    rcb3dbb63 r70922c2  
    813813 * On success, answer will contain EOK int retval.
    814814 * On failure, error code will be sent in retval.
     815 *
    815816 */
    816817static void loc_callback_create(ipc_callid_t iid, ipc_call_t *icall)
    817818{
    818         cb_sess_t *cb_sess;
    819        
    820         cb_sess = calloc(1, sizeof(cb_sess_t));
     819        cb_sess_t *cb_sess = calloc(1, sizeof(cb_sess_t));
    821820        if (cb_sess == NULL) {
    822821                async_answer_0(iid, ENOMEM);
  • uspace/srv/net/net/net.h

    rcb3dbb63 r70922c2  
    9696       
    9797        /** Serving network interface driver module index. */
    98         service_id_t sid;  /**< Service ID */
    99         async_sess_t *sess;      /**< Driver session. */
     98        service_id_t sid;    /**< Service ID */
     99        async_sess_t *sess;  /**< Driver session. */
    100100       
    101101        module_t *nil;  /**< Serving link layer module index. */
  • uspace/srv/net/nil/eth/eth.c

    rcb3dbb63 r70922c2  
    173173    void *arg);
    174174
    175 static int eth_device_state(nic_device_id_t device_id, sysarg_t state)
     175static int eth_device_state(eth_device_t *device, sysarg_t state)
    176176{
    177177        int index;
     
    183183                proto = eth_protos_get_index(&eth_globals.protos, index);
    184184                if ((proto) && (proto->sess)) {
    185                         il_device_state_msg(proto->sess, device_id, state,
    186                             proto->service);
     185                        il_device_state_msg(proto->sess, device->device_id,
     186                            state, proto->service);
    187187                }
    188188        }
     
    347347        }
    348348       
    349         rc = nic_callback_create(device->sess, device_id,
    350             eth_nic_cb_connection, NULL);
     349        rc = nic_callback_create(device->sess, eth_nic_cb_connection, device);
    351350        if (rc != EOK) {
    352351                fibril_rwlock_write_unlock(&eth_globals.devices_lock);
     
    825824}
    826825
    827 static int eth_received(nic_device_id_t device_id)
     826static int eth_received(eth_device_t *device)
    828827{
    829828        void *data;
     
    845844        free(data);
    846845       
    847         return nil_received_msg_local(device_id, packet);
    848 }
    849 
    850 static int eth_addr_changed(nic_device_id_t device_id)
     846        return nil_received_msg_local(device->device_id, packet);
     847}
     848
     849static int eth_addr_changed(eth_device_t *device)
    851850{
    852851        nic_address_t address;
     
    866865
    867866        fibril_rwlock_write_lock(&eth_globals.devices_lock);
    868         /* An existing device? */
    869         eth_device_t *device = eth_devices_find(&eth_globals.devices, device_id);
    870         if (device) {
    871                 printf("Device %d changing address from " PRIMAC " to " PRIMAC "\n",
    872                         device_id, ARGSMAC(device->addr.address), ARGSMAC(address.address));
    873                 memcpy(&device->addr, &address, sizeof (nic_address_t));
    874                 fibril_rwlock_write_unlock(&eth_globals.devices_lock);
    875 
    876                 /* Notify all upper layer modules */
    877                 fibril_rwlock_read_lock(&eth_globals.protos_lock);
    878                 int index;
    879                 for (index = 0; index < eth_protos_count(&eth_globals.protos); index++) {
    880                         eth_proto_t *proto = eth_protos_get_index(&eth_globals.protos, index);
    881                         if (proto->sess != NULL) {
    882                                 il_addr_changed_msg(proto->sess, device->device_id,
    883                                                 ETH_ADDR, address.address);
    884                         }
    885                 }
    886 
    887                 fibril_rwlock_read_unlock(&eth_globals.protos_lock);
    888                 return EOK;
    889         } else {
    890                 return ENOENT;
    891         }
     867
     868        printf("Device %d changing address from " PRIMAC " to " PRIMAC "\n",
     869                device->device_id, ARGSMAC(device->addr.address),
     870                ARGSMAC(address.address));
     871        memcpy(&device->addr, &address, sizeof (nic_address_t));
     872        fibril_rwlock_write_unlock(&eth_globals.devices_lock);
     873
     874        /* Notify all upper layer modules */
     875        fibril_rwlock_read_lock(&eth_globals.protos_lock);
     876        int index;
     877        for (index = 0; index < eth_protos_count(&eth_globals.protos); index++) {
     878                eth_proto_t *proto = eth_protos_get_index(&eth_globals.protos, index);
     879                if (proto->sess != NULL) {
     880                        il_addr_changed_msg(proto->sess, device->device_id,
     881                                        ETH_ADDR, address.address);
     882                }
     883        }
     884
     885        fibril_rwlock_read_unlock(&eth_globals.protos_lock);
     886        return EOK;
    892887}
    893888
     
    962957static void eth_nic_cb_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    963958{
     959        eth_device_t *device = (eth_device_t *)arg;
    964960        int rc;
    965961       
     
    975971                switch (IPC_GET_IMETHOD(call)) {
    976972                case NIC_EV_DEVICE_STATE:
    977                         rc = eth_device_state(IPC_GET_ARG1(call),
    978                             IPC_GET_ARG2(call));
     973                        rc = eth_device_state(device, IPC_GET_ARG1(call));
    979974                        async_answer_0(callid, (sysarg_t) rc);
    980975                        break;
    981976                case NIC_EV_RECEIVED:
    982                         rc = eth_received(IPC_GET_ARG1(call));
     977                        rc = eth_received(device);
    983978                        async_answer_0(callid, (sysarg_t) rc);
    984979                        break;
    985980                case NIC_EV_ADDR_CHANGED:
    986                         rc = eth_addr_changed(IPC_GET_ARG1(call));
     981                        rc = eth_addr_changed(device);
    987982                        async_answer_0(callid, (sysarg_t) rc);
    988983                        break;
  • uspace/srv/net/nil/nildummy/nildummy.c

    rcb3dbb63 r70922c2  
    7373    void *arg);
    7474
    75 static int nildummy_device_state(nic_device_id_t device_id, sysarg_t state)
     75static int nildummy_device_state(nildummy_device_t *device, sysarg_t state)
    7676{
    7777        fibril_rwlock_read_lock(&nildummy_globals.protos_lock);
    7878        if (nildummy_globals.proto.sess)
    79                 il_device_state_msg(nildummy_globals.proto.sess, device_id,
    80                     state, nildummy_globals.proto.service);
     79                il_device_state_msg(nildummy_globals.proto.sess,
     80                    device->device_id, state, nildummy_globals.proto.service);
    8181        fibril_rwlock_read_unlock(&nildummy_globals.protos_lock);
    8282       
     
    8484}
    8585
    86 static int nildummy_addr_changed(nic_device_id_t device_id)
     86static int nildummy_addr_changed(nildummy_device_t *device)
    8787{
    8888        return ENOTSUP;
     
    182182        }
    183183       
    184         int rc = nic_callback_create(device->sess, device_id,
    185             nildummy_nic_cb_conn, NULL);
     184        int rc = nic_callback_create(device->sess, nildummy_nic_cb_conn,
     185            device);
    186186        if (rc != EOK) {
    187187                async_hangup(device->sess);
     
    360360    services_t sender)
    361361{
    362         packet_t *p;
    363        
    364362        fibril_rwlock_read_lock(&nildummy_globals.devices_lock);
    365363       
     
    371369        }
    372370       
    373         p = packet;
     371        packet_t *p = packet;
    374372        do {
    375373                nic_send_frame(device->sess, packet_get_data(p),
     
    385383}
    386384
    387 static int nildummy_received(nic_device_id_t device_id)
     385static int nildummy_received(nildummy_device_t *device)
    388386{
    389387        void *data;
     
    403401        free(pdata);
    404402
    405         return nil_received_msg_local(device_id, packet);
     403        return nil_received_msg_local(device->device_id, packet);
    406404}
    407405
     
    467465static void nildummy_nic_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    468466{
     467        nildummy_device_t *device = (nildummy_device_t *)arg;
    469468        int rc;
    470469       
     
    480479                switch (IPC_GET_IMETHOD(call)) {
    481480                case NIC_EV_DEVICE_STATE:
    482                         rc = nildummy_device_state(IPC_GET_ARG1(call),
    483                             IPC_GET_ARG2(call));
     481                        rc = nildummy_device_state(device, IPC_GET_ARG1(call));
    484482                        async_answer_0(callid, (sysarg_t) rc);
    485483                        break;
    486484                case NIC_EV_RECEIVED:
    487                         rc = nildummy_received(IPC_GET_ARG1(call));
     485                        rc = nildummy_received(device);
    488486                        async_answer_0(callid, (sysarg_t) rc);
    489487                        break;
    490488                case NIC_EV_ADDR_CHANGED:
    491                         rc = nildummy_addr_changed(IPC_GET_ARG1(call));
     489                        rc = nildummy_addr_changed(device);
    492490                        async_answer_0(callid, (sysarg_t) rc);
    493491                        break;
Note: See TracChangeset for help on using the changeset viewer.