Changeset 59157eb in mainline
- Timestamp:
- 2012-02-02T15:18:46Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f834f90d
- Parents:
- ecff3d9
- Location:
- uspace
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/inet.c
recff3d9 r59157eb 148 148 } 149 149 150 static void inet_ev_recv(ipc_callid_t callid, ipc_call_t *call) 151 { 152 int rc; 153 inet_dgram_t dgram; 154 155 dgram.src.ipv4 = IPC_GET_ARG1(*call); 156 dgram.dest.ipv4 = IPC_GET_ARG2(*call); 157 dgram.tos = IPC_GET_ARG3(*call); 158 159 rc = async_data_write_accept(&dgram.data, false, 0, 0, 0, &dgram.size); 160 if (rc != EOK) { 161 async_answer_0(callid, rc); 162 return; 163 } 164 165 rc = inet_ev_ops->recv(&dgram); 166 async_answer_0(callid, rc); 167 } 168 150 169 static void inet_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg) 151 170 { … … 153 172 ipc_call_t call; 154 173 ipc_callid_t callid = async_get_call(&call); 155 174 156 175 if (!IPC_GET_IMETHOD(call)) { 157 176 /* TODO: Handle hangup */ 158 177 return; 159 178 } 160 179 161 180 switch (IPC_GET_IMETHOD(call)) { 162 181 case INET_EV_RECV: 163 async_answer_0(callid, EOK);182 inet_ev_recv(callid, &call); 164 183 break; 165 184 default: -
uspace/srv/inet/inet.c
recff3d9 r59157eb 47 47 #include <sys/types.h> 48 48 49 #include "inet.h" 50 49 51 #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;57 52 58 53 static void inet_client_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg); … … 111 106 ipc_call_t *call) 112 107 { 113 uint32_t src_ipv4; 114 uint32_t dest_ipv4; 115 uint8_t tos; 108 inet_dgram_t dgram; 116 109 uint8_t ttl; 117 110 int df; 118 void *data;119 size_t size;120 111 int rc; 121 112 122 113 log_msg(LVL_DEBUG, "inet_send()"); 123 114 124 src_ipv4 = IPC_GET_ARG1(*call);125 d est_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); 127 118 ttl = IPC_GET_ARG4(*call); 128 119 df = IPC_GET_ARG5(*call); 129 120 130 (void)src_ipv4;131 (void)dest_ipv4;132 (void)tos;133 121 (void)ttl; 134 122 (void)df; 135 123 136 rc = async_data_write_accept(&d ata, false, 0, 0, 0, &size);124 rc = async_data_write_accept(&dgram.data, false, 0, 0, 0, &dgram.size); 137 125 if (rc != EOK) { 138 126 async_answer_0(callid, rc); … … 140 128 } 141 129 142 free(d ata);130 free(dgram.data); 143 131 async_answer_0(callid, ENOTSUP); 144 132 } … … 223 211 } 224 212 213 int 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 225 236 int main(int argc, char *argv[]) 226 237 { -
uspace/srv/tcp/tcp.c
recff3d9 r59157eb 54 54 #define NAME "tcp" 55 55 56 #define IP_PROTO_TCP 6 57 56 58 static int tcp_inet_ev_recv(inet_dgram_t *dgram); 57 59 static void tcp_received_pdu(tcp_pdu_t *pdu); … … 185 187 if (0) tcp_test(); 186 188 187 rc = inet_init( 42, &tcp_inet_ev_ops);189 rc = inet_init(IP_PROTO_TCP, &tcp_inet_ev_ops); 188 190 if (rc != EOK) { 189 191 log_msg(LVL_ERROR, "Failed connecting to internet service.");
Note:
See TracChangeset
for help on using the changeset viewer.