Changeset 4f64a523 in mainline for uspace/srv/ethip


Ignore:
Timestamp:
2012-02-12T19:36:32Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
df15e5f
Parents:
1493811
Message:

Need to limit iplink to a single client connection.

Location:
uspace/srv/ethip
Files:
2 edited

Legend:

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

    r1493811 r4f64a523  
    5252#define NAME "eth"
    5353
    54 static int ethip_open(iplink_conn_t *conn);
    55 static int ethip_close(iplink_conn_t *conn);
    56 static int ethip_send(iplink_conn_t *conn, iplink_srv_sdu_t *sdu);
    57 static int ethip_get_mtu(iplink_conn_t *conn, size_t *mtu);
     54static int ethip_open(iplink_srv_t *srv);
     55static int ethip_close(iplink_srv_t *srv);
     56static int ethip_send(iplink_srv_t *srv, iplink_srv_sdu_t *sdu);
     57static int ethip_get_mtu(iplink_srv_t *srv, size_t *mtu);
    5858
    5959static void ethip_client_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg);
     
    9595        log_msg(LVL_DEBUG, "ethip_iplink_init()");
    9696
     97        iplink_srv_init(&nic->iplink);
    9798        nic->iplink.ops = &ethip_iplink_ops;
    9899        nic->iplink.arg = nic;
     
    148149}
    149150
    150 static int ethip_open(iplink_conn_t *conn)
     151static int ethip_open(iplink_srv_t *srv)
    151152{
    152153        log_msg(LVL_DEBUG, "ethip_open()");
     
    154155}
    155156
    156 static int ethip_close(iplink_conn_t *conn)
    157 {
    158         log_msg(LVL_DEBUG, "ethip_open()");
    159         return EOK;
    160 }
    161 
    162 static int ethip_send(iplink_conn_t *conn, iplink_srv_sdu_t *sdu)
    163 {
    164         ethip_nic_t *nic = (ethip_nic_t *)conn->srv->arg;
     157static int ethip_close(iplink_srv_t *srv)
     158{
     159        log_msg(LVL_DEBUG, "ethip_close()");
     160        return EOK;
     161}
     162
     163static int ethip_send(iplink_srv_t *srv, iplink_srv_sdu_t *sdu)
     164{
     165        ethip_nic_t *nic = (ethip_nic_t *)srv->arg;
    165166        eth_frame_t frame;
    166167        void *data;
     
    188189int ethip_received(iplink_srv_t *srv, void *data, size_t size)
    189190{
     191        log_msg(LVL_DEBUG, "ethip_received(): srv=%p", srv);
     192        ethip_nic_t *nic = (ethip_nic_t *)srv->arg;
    190193        eth_frame_t frame;
    191194        iplink_srv_sdu_t sdu;
    192195        int rc;
    193196
     197        log_msg(LVL_DEBUG, "ethip_received()");
     198
     199        log_msg(LVL_DEBUG, " - eth_pdu_decode");
    194200        rc = eth_pdu_decode(data, size, &frame);
    195         if (rc != EOK)
    196                 return rc;
    197 
     201        if (rc != EOK) {
     202                log_msg(LVL_DEBUG, " - eth_pdu_decode failed");
     203                return rc;
     204        }
     205
     206        log_msg(LVL_DEBUG, " - construct SDU");
     207        sdu.lsrc.ipv4 = (192 << 24) | (168 << 16) | (0 << 8) | 1;
     208        sdu.ldest.ipv4 = (192 << 24) | (168 << 16) | (0 << 8) | 4;
    198209        sdu.data = frame.data;
    199210        sdu.size = frame.size;
    200         (void) sdu;
    201         //rc = iplink_ev_recv(conn, &sdu);
     211        log_msg(LVL_DEBUG, " - call iplink_ev_recv");
     212        rc = iplink_ev_recv(&nic->iplink, &sdu);
    202213
    203214        free(frame.data);
     
    205216}
    206217
    207 static int ethip_get_mtu(iplink_conn_t *conn, size_t *mtu)
     218static int ethip_get_mtu(iplink_srv_t *srv, size_t *mtu)
    208219{
    209220        log_msg(LVL_DEBUG, "ethip_get_mtu()");
  • uspace/srv/ethip/ethip_nic.c

    r1493811 r4f64a523  
    158158        }
    159159
    160         rc = nic_set_state(nic->sess, NIC_STATE_ACTIVE);
    161         if (rc != EOK) {
    162                 log_msg(LVL_ERROR, "Failed activating NIC '%s'.",
    163                     nic->svc_name);
    164                 goto error;
    165         }
    166 
    167160        log_msg(LVL_DEBUG, "Opened NIC '%s'", nic->svc_name);
    168161        list_append(&nic->nic_list, &ethip_nic_list);
     
    172165        if (rc != EOK)
    173166                goto error;
     167
     168        rc = nic_set_state(nic->sess, NIC_STATE_ACTIVE);
     169        if (rc != EOK) {
     170                log_msg(LVL_ERROR, "Failed activating NIC '%s'.",
     171                    nic->svc_name);
     172                goto error;
     173        }
    174174
    175175        log_msg(LVL_DEBUG, "Initialized IP link service.");
     
    205205        size_t size;
    206206
    207         log_msg(LVL_DEBUG, "ethip_nic_received()");
     207        log_msg(LVL_DEBUG, "ethip_nic_received() nic=%p", nic);
    208208
    209209        rc = async_data_write_accept(&data, false, 0, 0, 0, &size);
     
    213213        }
    214214
     215        log_msg(LVL_DEBUG, "call ethip_received");
    215216        rc = ethip_received(&nic->iplink, data, size);
     217        log_msg(LVL_DEBUG, "free data");
    216218        free(data);
    217219
     
    228230static void ethip_nic_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    229231{
    230         ethip_nic_t *nic;
     232        ethip_nic_t *nic = (ethip_nic_t *)arg;
    231233
    232234        log_msg(LVL_DEBUG, "ethnip_nic_cb_conn()");
Note: See TracChangeset for help on using the changeset viewer.