Changeset d8b47eca in mainline for uspace/srv/net/inetsrv/inetsrv.c
- Timestamp:
- 2013-07-03T17:16:44Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 66366470, 882bc4b
- Parents:
- 1d24ad3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/inetsrv/inetsrv.c
r1d24ad3 rd8b47eca 207 207 } 208 208 209 static void inet_get_srcaddr_srv(inet_client_t *client, ipc_callid_t callid,210 ipc_call_t * call)209 static void inet_get_srcaddr_srv(inet_client_t *client, ipc_callid_t iid, 210 ipc_call_t *icall) 211 211 { 212 212 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_get_srcaddr_srv()"); 213 213 214 addr32_t remote_v4 = IPC_GET_ARG1(*call); 215 uint8_t tos = IPC_GET_ARG2(*call); 214 uint8_t tos = IPC_GET_ARG1(*icall); 215 216 ipc_callid_t callid; 217 size_t size; 218 if (!async_data_write_receive(&callid, &size)) { 219 async_answer_0(callid, EREFUSED); 220 async_answer_0(iid, EREFUSED); 221 return; 222 } 223 224 if (size != sizeof(inet_addr_t)) { 225 async_answer_0(callid, EINVAL); 226 async_answer_0(iid, EINVAL); 227 return; 228 } 216 229 217 230 inet_addr_t remote; 218 inet_addr_set(remote_v4, &remote); 231 int rc = async_data_write_finalize(callid, &remote, size); 232 if (rc != EOK) { 233 async_answer_0(callid, rc); 234 async_answer_0(iid, rc); 235 } 219 236 220 237 inet_addr_t local; 221 int rc = inet_get_srcaddr(&remote, tos, &local); 238 rc = inet_get_srcaddr(&remote, tos, &local); 239 if (rc != EOK) { 240 async_answer_0(iid, rc); 241 return; 242 } 243 244 if (!async_data_read_receive(&callid, &size)) { 245 async_answer_0(callid, EREFUSED); 246 async_answer_0(iid, EREFUSED); 247 return; 248 } 249 250 if (size != sizeof(inet_addr_t)) { 251 async_answer_0(callid, EINVAL); 252 async_answer_0(iid, EINVAL); 253 return; 254 } 255 256 rc = async_data_read_finalize(callid, &local, size); 222 257 if (rc != EOK) { 223 258 async_answer_0(callid, rc); 224 return; 225 } 226 227 addr32_t local_v4; 228 uint16_t family = inet_addr_get(&local, &local_v4, NULL); 229 if (family != AF_INET) { 259 async_answer_0(iid, rc); 260 return; 261 } 262 263 async_answer_0(iid, rc); 264 } 265 266 static void inet_send_srv(inet_client_t *client, ipc_callid_t iid, 267 ipc_call_t *icall) 268 { 269 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_send_srv()"); 270 271 inet_dgram_t dgram; 272 273 dgram.tos = IPC_GET_ARG1(*icall); 274 275 uint8_t ttl = IPC_GET_ARG2(*icall); 276 int df = IPC_GET_ARG3(*icall); 277 278 ipc_callid_t callid; 279 size_t size; 280 if (!async_data_write_receive(&callid, &size)) { 281 async_answer_0(callid, EREFUSED); 282 async_answer_0(iid, EREFUSED); 283 return; 284 } 285 286 if (size != sizeof(inet_addr_t)) { 230 287 async_answer_0(callid, EINVAL); 231 return; 232 } 233 234 async_answer_1(callid, rc, (sysarg_t) local_v4); 235 } 236 237 static void inet_send_srv(inet_client_t *client, ipc_callid_t callid, 238 ipc_call_t *call) 239 { 240 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_send_srv()"); 241 242 addr32_t src_v4 = IPC_GET_ARG1(*call); 243 addr32_t dest_v4 = IPC_GET_ARG2(*call); 244 245 inet_dgram_t dgram; 246 247 inet_addr_set(src_v4, &dgram.src); 248 inet_addr_set(dest_v4, &dgram.dest); 249 dgram.tos = IPC_GET_ARG3(*call); 250 251 uint8_t ttl = IPC_GET_ARG4(*call); 252 int df = IPC_GET_ARG5(*call); 253 254 int rc = async_data_write_accept(&dgram.data, false, 0, 0, 0, 288 async_answer_0(iid, EINVAL); 289 return; 290 } 291 292 int rc = async_data_write_finalize(callid, &dgram.src, size); 293 if (rc != EOK) { 294 async_answer_0(callid, rc); 295 async_answer_0(iid, rc); 296 } 297 298 if (!async_data_write_receive(&callid, &size)) { 299 async_answer_0(callid, EREFUSED); 300 async_answer_0(iid, EREFUSED); 301 return; 302 } 303 304 if (size != sizeof(inet_addr_t)) { 305 async_answer_0(callid, EINVAL); 306 async_answer_0(iid, EINVAL); 307 return; 308 } 309 310 rc = async_data_write_finalize(callid, &dgram.dest, size); 311 if (rc != EOK) { 312 async_answer_0(callid, rc); 313 async_answer_0(iid, rc); 314 } 315 316 rc = async_data_write_accept(&dgram.data, false, 0, 0, 0, 255 317 &dgram.size); 256 318 if (rc != EOK) { 257 async_answer_0( callid, rc);319 async_answer_0(iid, rc); 258 320 return; 259 321 } … … 262 324 263 325 free(dgram.data); 264 async_answer_0( callid, rc);326 async_answer_0(iid, rc); 265 327 } 266 328
Note:
See TracChangeset
for help on using the changeset viewer.