Changeset 59157eb in mainline for uspace/srv/inet/inet.c


Ignore:
Timestamp:
2012-02-02T15:18:46Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f834f90d
Parents:
ecff3d9
Message:

Implement INET_EV_RECV IPC.

File:
1 edited

Legend:

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

    recff3d9 r59157eb  
    4747#include <sys/types.h>
    4848
     49#include "inet.h"
     50
    4951#define NAME "inet"
    50 
    51 /** Inet Client */
    52 typedef struct {
    53         async_sess_t *sess;
    54         uint8_t protocol;
    55         link_t client_list;
    56 } inet_client_t;
    5752
    5853static void inet_client_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg);
     
    111106    ipc_call_t *call)
    112107{
    113         uint32_t src_ipv4;
    114         uint32_t dest_ipv4;
    115         uint8_t tos;
     108        inet_dgram_t dgram;
    116109        uint8_t ttl;
    117110        int df;
    118         void *data;
    119         size_t size;
    120111        int rc;
    121112
    122113        log_msg(LVL_DEBUG, "inet_send()");
    123114
    124         src_ipv4 = IPC_GET_ARG1(*call);
    125         dest_ipv4 = IPC_GET_ARG2(*call);
    126         tos = IPC_GET_ARG3(*call);
     115        dgram.src.ipv4 = IPC_GET_ARG1(*call);
     116        dgram.dest.ipv4 = IPC_GET_ARG2(*call);
     117        dgram.tos = IPC_GET_ARG3(*call);
    127118        ttl = IPC_GET_ARG4(*call);
    128119        df = IPC_GET_ARG5(*call);
    129120
    130         (void)src_ipv4;
    131         (void)dest_ipv4;
    132         (void)tos;
    133121        (void)ttl;
    134122        (void)df;
    135123
    136         rc = async_data_write_accept(&data, false, 0, 0, 0, &size);
     124        rc = async_data_write_accept(&dgram.data, false, 0, 0, 0, &dgram.size);
    137125        if (rc != EOK) {
    138126                async_answer_0(callid, rc);
     
    140128        }
    141129
    142         free(data);
     130        free(dgram.data);
    143131        async_answer_0(callid, ENOTSUP);
    144132}
     
    223211}
    224212
     213int inet_ev_recv(inet_client_t *client, inet_dgram_t *dgram)
     214{
     215        async_exch_t *exch = async_exchange_begin(client->sess);
     216
     217        ipc_call_t answer;
     218        aid_t req = async_send_3(exch, INET_EV_RECV, dgram->src.ipv4,
     219            dgram->dest.ipv4, dgram->tos, &answer);
     220        int rc = async_data_write_start(exch, dgram->data, dgram->size);
     221        async_exchange_end(exch);
     222
     223        if (rc != EOK) {
     224                async_wait_for(req, NULL);
     225                return rc;
     226        }
     227
     228        sysarg_t retval;
     229        async_wait_for(req, &retval);
     230        if (retval != EOK)
     231                return retval;
     232
     233        return EOK;
     234}
     235
    225236int main(int argc, char *argv[])
    226237{
Note: See TracChangeset for help on using the changeset viewer.