Changeset 98abd40 in mainline for uspace/srv/net/inetsrv/inetsrv.c
- Timestamp:
- 2013-07-06T21:57:22Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c8bb1633, cdc8a391
- Parents:
- b8e72fd1 (diff), 507c6f3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/inetsrv/inetsrv.c
rb8e72fd1 r98abd40 46 46 #include <stdlib.h> 47 47 #include <sys/types.h> 48 48 #include <net/socket_codes.h> 49 49 #include "addrobj.h" 50 50 #include "icmp.h" 51 51 #include "icmp_std.h" 52 #include "icmpv6.h" 53 #include "icmpv6_std.h" 52 54 #include "inetsrv.h" 53 55 #include "inetcfg.h" 54 56 #include "inetping.h" 57 #include "inetping6.h" 55 58 #include "inet_link.h" 56 59 #include "reass.h" … … 93 96 rc = loc_service_register_with_iface(SERVICE_NAME_INETPING, &sid, 94 97 INET_PORT_PING); 98 if (rc != EOK) { 99 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering service (%d).", rc); 100 return EEXIST; 101 } 102 103 rc = loc_service_register_with_iface(SERVICE_NAME_INETPING6, &sid, 104 INET_PORT_PING6); 95 105 if (rc != EOK) { 96 106 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering service (%d).", rc); … … 104 114 } 105 115 106 sroute->dest.ipv4 = 0; 107 sroute->dest.bits = 0; 108 sroute->router.ipv4 = (10 << 24) | (0 << 16) | (2 << 8) | 2; 116 inet_naddr(&sroute->dest, 0, 0, 0, 0, 0); 117 inet_addr(&sroute->router, 10, 0, 2, 2); 109 118 sroute->name = str_dup("default"); 110 119 inet_sroute_add(sroute); 111 120 112 121 rc = inet_link_discovery_start(); 113 122 if (rc != EOK) 114 123 return EEXIST; … … 194 203 195 204 /* Take source address from the address object */ 196 local->ipv4 = dir.aobj->naddr.ipv4;205 inet_naddr_addr(&dir.aobj->naddr, local); 197 206 return EOK; 198 207 } 199 208 200 static void inet_get_srcaddr_srv(inet_client_t *client, ipc_callid_t callid, 201 ipc_call_t *call) 202 { 209 static void inet_get_srcaddr_srv(inet_client_t *client, ipc_callid_t iid, 210 ipc_call_t *icall) 211 { 212 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_get_srcaddr_srv()"); 213 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 } 229 203 230 inet_addr_t remote; 204 uint8_t tos; 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 } 236 205 237 inet_addr_t local; 206 int rc;207 208 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_get_srcaddr_srv()");209 210 remote.ipv4 = IPC_GET_ARG1(*call);211 tos = IPC_GET_ARG2(*call);212 local.ipv4 = 0;213 214 238 rc = inet_get_srcaddr(&remote, tos, &local); 215 async_answer_1(callid, rc, local.ipv4); 216 } 217 218 static void inet_send_srv(inet_client_t *client, ipc_callid_t callid, 219 ipc_call_t *call) 220 { 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); 257 if (rc != EOK) { 258 async_answer_0(callid, rc); 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 221 271 inet_dgram_t dgram; 222 uint8_t ttl; 223 int df; 224 int rc; 225 226 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_send_srv()"); 227 228 dgram.src.ipv4 = IPC_GET_ARG1(*call); 229 dgram.dest.ipv4 = IPC_GET_ARG2(*call); 230 dgram.tos = IPC_GET_ARG3(*call); 231 ttl = IPC_GET_ARG4(*call); 232 df = IPC_GET_ARG5(*call); 233 234 rc = async_data_write_accept(&dgram.data, false, 0, 0, 0, &dgram.size); 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)) { 287 async_answer_0(callid, EINVAL); 288 async_answer_0(iid, EINVAL); 289 return; 290 } 291 292 int rc = async_data_write_finalize(callid, &dgram.src, size); 235 293 if (rc != EOK) { 236 294 async_answer_0(callid, rc); 237 return; 238 } 239 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, 317 &dgram.size); 318 if (rc != EOK) { 319 async_answer_0(iid, rc); 320 return; 321 } 322 240 323 rc = inet_send(client, &dgram, client->protocol, ttl, df); 241 324 242 325 free(dgram.data); 243 async_answer_0( callid, rc);326 async_answer_0(iid, rc); 244 327 } 245 328 … … 339 422 inetping_conn(iid, icall, arg); 340 423 break; 424 case INET_PORT_PING6: 425 inetping6_conn(iid, icall, arg); 426 break; 341 427 default: 342 428 async_answer_0(iid, ENOTSUP); … … 366 452 { 367 453 async_exch_t *exch = async_exchange_begin(client->sess); 368 454 369 455 ipc_call_t answer; 370 aid_t req = async_send_3(exch, INET_EV_RECV, dgram->src.ipv4, 371 dgram->dest.ipv4, dgram->tos, &answer); 372 int rc = async_data_write_start(exch, dgram->data, dgram->size); 373 async_exchange_end(exch); 374 375 if (rc != EOK) { 456 aid_t req = async_send_1(exch, INET_EV_RECV, dgram->tos, &answer); 457 458 int rc = async_data_write_start(exch, &dgram->src, sizeof(inet_addr_t)); 459 if (rc != EOK) { 460 async_exchange_end(exch); 376 461 async_forget(req); 377 462 return rc; 378 463 } 379 464 465 rc = async_data_write_start(exch, &dgram->dest, sizeof(inet_addr_t)); 466 if (rc != EOK) { 467 async_exchange_end(exch); 468 async_forget(req); 469 return rc; 470 } 471 472 rc = async_data_write_start(exch, dgram->data, dgram->size); 473 474 async_exchange_end(exch); 475 476 if (rc != EOK) { 477 async_forget(req); 478 return rc; 479 } 480 380 481 sysarg_t retval; 381 482 async_wait_for(req, &retval); 382 if (retval != EOK) 383 return retval; 384 385 return EOK; 483 484 return (int) retval; 386 485 } 387 486 … … 392 491 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_recv_dgram_local()"); 393 492 394 /* ICMP messages are handled internally */493 /* ICMP and ICMPv6 messages are handled internally */ 395 494 if (proto == IP_PROTO_ICMP) 396 495 return icmp_recv(dgram); 496 497 if (proto == IP_PROTO_ICMPV6) 498 return icmpv6_recv(dgram); 397 499 398 500 client = inet_client_find(proto);
Note:
See TracChangeset
for help on using the changeset viewer.