Changes in uspace/lib/c/generic/inet.c [695b6ff:77ad86c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/inet.c
r695b6ff r77ad86c 30 30 #include <assert.h> 31 31 #include <errno.h> 32 #include <net/socket_codes.h>33 32 #include <inet/inet.h> 34 33 #include <ipc/inet.h> … … 109 108 { 110 109 async_exch_t *exch = async_exchange_begin(inet_sess); 111 110 112 111 ipc_call_t answer; 113 aid_t req = async_send_4(exch, INET_SEND, dgram->iplink, dgram->tos, 114 ttl, df, &answer); 115 116 int rc = async_data_write_start(exch, &dgram->src, sizeof(inet_addr_t)); 117 if (rc != EOK) { 118 async_exchange_end(exch); 119 async_forget(req); 120 return rc; 121 } 122 123 rc = async_data_write_start(exch, &dgram->dest, sizeof(inet_addr_t)); 124 if (rc != EOK) { 125 async_exchange_end(exch); 126 async_forget(req); 127 return rc; 128 } 129 130 rc = async_data_write_start(exch, dgram->data, dgram->size); 131 112 aid_t req = async_send_5(exch, INET_SEND, dgram->src.ipv4, 113 dgram->dest.ipv4, dgram->tos, ttl, df, &answer); 114 int rc = async_data_write_start(exch, dgram->data, dgram->size); 132 115 async_exchange_end(exch); 133 116 134 117 if (rc != EOK) { 135 118 async_forget(req); 136 119 return rc; 137 120 } 138 121 139 122 sysarg_t retval; 140 123 async_wait_for(req, &retval); 141 142 return (int) retval; 124 if (retval != EOK) 125 return retval; 126 127 return EOK; 143 128 } 144 129 145 130 int inet_get_srcaddr(inet_addr_t *remote, uint8_t tos, inet_addr_t *local) 146 131 { 132 sysarg_t local_addr; 147 133 async_exch_t *exch = async_exchange_begin(inet_sess); 148 149 ipc_call_t answer; 150 aid_t req = async_send_1(exch, INET_GET_SRCADDR, tos, &answer); 151 152 int rc = async_data_write_start(exch, remote, sizeof(inet_addr_t)); 153 if (rc != EOK) { 154 async_exchange_end(exch); 155 async_forget(req); 134 135 int rc = async_req_2_1(exch, INET_GET_SRCADDR, remote->ipv4, 136 tos, &local_addr); 137 async_exchange_end(exch); 138 139 if (rc != EOK) 156 140 return rc; 157 } 158 159 rc = async_data_read_start(exch, local, sizeof(inet_addr_t)); 160 161 async_exchange_end(exch); 162 163 if (rc != EOK) { 164 async_forget(req); 165 return rc; 166 } 167 168 sysarg_t retval; 169 async_wait_for(req, &retval); 170 171 return (int) retval; 141 142 local->ipv4 = local_addr; 143 return EOK; 172 144 } 173 145 174 static void inet_ev_recv(ipc_callid_t iid, ipc_call_t *icall)146 static void inet_ev_recv(ipc_callid_t callid, ipc_call_t *call) 175 147 { 148 int rc; 176 149 inet_dgram_t dgram; 177 178 dgram. tos = IPC_GET_ARG1(*icall);179 180 ipc_callid_t callid;181 size_t size; 182 if (!async_data_write_receive(&callid, &size)) {183 async_answer_0(callid, EINVAL);184 async_answer_0( iid, EINVAL);150 151 dgram.src.ipv4 = IPC_GET_ARG1(*call); 152 dgram.dest.ipv4 = IPC_GET_ARG2(*call); 153 dgram.tos = IPC_GET_ARG3(*call); 154 155 rc = async_data_write_accept(&dgram.data, false, 0, 0, 0, &dgram.size); 156 if (rc != EOK) { 157 async_answer_0(callid, rc); 185 158 return; 186 159 } 187 188 if (size != sizeof(inet_addr_t)) { 189 async_answer_0(callid, EINVAL); 190 async_answer_0(iid, EINVAL); 191 return; 192 } 193 194 int rc = async_data_write_finalize(callid, &dgram.src, size); 195 if (rc != EOK) { 196 async_answer_0(callid, rc); 197 async_answer_0(iid, rc); 198 return; 199 } 200 201 if (!async_data_write_receive(&callid, &size)) { 202 async_answer_0(callid, EINVAL); 203 async_answer_0(iid, EINVAL); 204 return; 205 } 206 207 if (size != sizeof(inet_addr_t)) { 208 async_answer_0(callid, EINVAL); 209 async_answer_0(iid, EINVAL); 210 return; 211 } 212 213 rc = async_data_write_finalize(callid, &dgram.dest, size); 214 if (rc != EOK) { 215 async_answer_0(callid, rc); 216 async_answer_0(iid, rc); 217 return; 218 } 219 220 rc = async_data_write_accept(&dgram.data, false, 0, 0, 0, &dgram.size); 221 if (rc != EOK) { 222 async_answer_0(iid, rc); 223 return; 224 } 225 160 226 161 rc = inet_ev_ops->recv(&dgram); 227 async_answer_0( iid, rc);162 async_answer_0(callid, rc); 228 163 } 229 164 … … 233 168 ipc_call_t call; 234 169 ipc_callid_t callid = async_get_call(&call); 235 170 236 171 if (!IPC_GET_IMETHOD(call)) { 237 172 /* TODO: Handle hangup */ 238 173 return; 239 174 } 240 175 241 176 switch (IPC_GET_IMETHOD(call)) { 242 177 case INET_EV_RECV:
Note:
See TracChangeset
for help on using the changeset viewer.