Changeset 973ef9fc in mainline for uspace/srv/net
- Timestamp:
- 2010-12-25T21:20:28Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 631ee0c
- Parents:
- 1bfd3d3 (diff), 09178b7f (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. - Location:
- uspace/srv/net
- Files:
-
- 2 deleted
- 22 edited
-
cfg/Makefile (modified) (1 diff)
-
cfg/lo.netif_nil_bundle (deleted)
-
cfg/ne2k.netif_nil_bundle (deleted)
-
il/arp/arp.c (modified) (35 diffs)
-
il/arp/arp.h (modified) (5 diffs)
-
il/arp/arp_module.c (modified) (2 diffs)
-
il/ip/ip.c (modified) (28 diffs)
-
il/ip/ip_module.c (modified) (2 diffs)
-
net/net.c (modified) (4 diffs)
-
netif/lo/Makefile (modified) (1 diff)
-
netif/lo/lo.c (modified) (3 diffs)
-
nil/eth/Makefile (modified) (1 diff)
-
nil/eth/eth.c (modified) (12 diffs)
-
nil/eth/eth_module.c (modified) (2 diffs)
-
nil/nildummy/Makefile (modified) (1 diff)
-
nil/nildummy/nildummy.c (modified) (9 diffs)
-
nil/nildummy/nildummy_module.c (modified) (2 diffs)
-
tl/icmp/icmp.c (modified) (15 diffs)
-
tl/icmp/icmp_module.c (modified) (2 diffs)
-
tl/tcp/tcp.c (modified) (37 diffs)
-
tl/tcp/tcp.h (modified) (2 diffs)
-
tl/tcp/tcp_module.c (modified) (2 diffs)
-
tl/udp/udp.c (modified) (12 diffs)
-
tl/udp/udp_module.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/cfg/Makefile
r1bfd3d3 r973ef9fc 36 36 -include $(CONFIG_MAKEFILE) 37 37 38 ifeq ($(CONFIG_NETIF_NIL_BUNDLE),y) 39 LO_SOURCE = lo.netif_nil_bundle 40 NE2K_SOURCE = ne2k.netif_nil_bundle 41 else 42 LO_SOURCE = lo.netif_standalone 43 NE2K_SOURCE = ne2k.netif_standalone 44 endif 38 LO_SOURCE = lo.netif_standalone 39 NE2K_SOURCE = ne2k.netif_standalone 45 40 46 41 LO_TARGET = lo -
uspace/srv/net/il/arp/arp.c
r1bfd3d3 r973ef9fc 72 72 #define NAME "arp" 73 73 74 /** Number of microseconds to wait for an ARP reply. */ 75 #define ARP_TRANS_WAIT 1000000 76 74 77 /** ARP global data. */ 75 78 arp_globals_t arp_globals; … … 77 80 DEVICE_MAP_IMPLEMENT(arp_cache, arp_device_t); 78 81 INT_MAP_IMPLEMENT(arp_protos, arp_proto_t); 79 GENERIC_CHAR_MAP_IMPLEMENT(arp_addr, measured_string_t); 82 GENERIC_CHAR_MAP_IMPLEMENT(arp_addr, arp_trans_t); 83 84 static void arp_clear_trans(arp_trans_t *trans) 85 { 86 if (trans->hw_addr) { 87 free(trans->hw_addr); 88 trans->hw_addr = NULL; 89 } 90 fibril_condvar_broadcast(&trans->cv); 91 } 92 93 static void arp_clear_addr(arp_addr_t *addresses) 94 { 95 int count; 96 arp_trans_t *trans; 97 98 for (count = arp_addr_count(addresses) - 1; count >= 0; count--) { 99 trans = arp_addr_items_get_index(&addresses->values, count); 100 if (trans) 101 arp_clear_trans(trans); 102 } 103 } 104 80 105 81 106 /** Clears the device specific data. … … 96 121 if (proto->addr_data) 97 122 free(proto->addr_data); 123 arp_clear_addr(&proto->addresses); 98 124 arp_addr_destroy(&proto->addresses); 99 125 } … … 107 133 arp_device_t *device; 108 134 109 fibril_ rwlock_write_lock(&arp_globals.lock);135 fibril_mutex_lock(&arp_globals.lock); 110 136 for (count = arp_cache_count(&arp_globals.cache) - 1; count >= 0; 111 137 count--) { … … 120 146 } 121 147 arp_cache_clear(&arp_globals.cache); 122 fibril_ rwlock_write_unlock(&arp_globals.lock);148 fibril_mutex_unlock(&arp_globals.lock); 123 149 printf("Cache cleaned\n"); 124 150 return EOK; … … 130 156 arp_device_t *device; 131 157 arp_proto_t *proto; 132 133 fibril_rwlock_write_lock(&arp_globals.lock); 158 arp_trans_t *trans; 159 160 fibril_mutex_lock(&arp_globals.lock); 134 161 device = arp_cache_find(&arp_globals.cache, device_id); 135 162 if (!device) { 136 fibril_ rwlock_write_unlock(&arp_globals.lock);163 fibril_mutex_unlock(&arp_globals.lock); 137 164 return ENOENT; 138 165 } 139 166 proto = arp_protos_find(&device->protos, protocol); 140 167 if (!proto) { 141 fibril_ rwlock_write_unlock(&arp_globals.lock);168 fibril_mutex_unlock(&arp_globals.lock); 142 169 return ENOENT; 143 170 } 171 trans = arp_addr_find(&proto->addresses, address->value, address->length); 172 if (trans) 173 arp_clear_trans(trans); 144 174 arp_addr_exclude(&proto->addresses, address->value, address->length); 145 fibril_ rwlock_write_unlock(&arp_globals.lock);175 fibril_mutex_unlock(&arp_globals.lock); 146 176 return EOK; 147 177 } … … 152 182 arp_device_t *device; 153 183 154 fibril_ rwlock_write_lock(&arp_globals.lock);184 fibril_mutex_lock(&arp_globals.lock); 155 185 device = arp_cache_find(&arp_globals.cache, device_id); 156 186 if (!device) { 157 fibril_ rwlock_write_unlock(&arp_globals.lock);187 fibril_mutex_unlock(&arp_globals.lock); 158 188 return ENOENT; 159 189 } 160 190 arp_clear_device(device); 161 191 printf("Device %d cleared\n", device_id); 162 fibril_ rwlock_write_unlock(&arp_globals.lock);192 fibril_mutex_unlock(&arp_globals.lock); 163 193 return EOK; 164 194 } … … 221 251 int rc; 222 252 223 fibril_ rwlock_write_lock(&arp_globals.lock);253 fibril_mutex_lock(&arp_globals.lock); 224 254 225 255 /* An existing device? */ … … 229 259 if (device->service != service) { 230 260 printf("Device %d already exists\n", device->device_id); 231 fibril_ rwlock_write_unlock(&arp_globals.lock);261 fibril_mutex_unlock(&arp_globals.lock); 232 262 return EEXIST; 233 263 } … … 241 271 rc = arp_proto_create(&proto, protocol, address); 242 272 if (rc != EOK) { 243 fibril_ rwlock_write_unlock(&arp_globals.lock);273 fibril_mutex_unlock(&arp_globals.lock); 244 274 return rc; 245 275 } … … 247 277 proto); 248 278 if (index < 0) { 249 fibril_ rwlock_write_unlock(&arp_globals.lock);279 fibril_mutex_unlock(&arp_globals.lock); 250 280 free(proto); 251 281 return index; … … 262 292 device = (arp_device_t *) malloc(sizeof(arp_device_t)); 263 293 if (!device) { 264 fibril_ rwlock_write_unlock(&arp_globals.lock);294 fibril_mutex_unlock(&arp_globals.lock); 265 295 return ENOMEM; 266 296 } … … 269 299 rc = arp_protos_initialize(&device->protos); 270 300 if (rc != EOK) { 271 fibril_ rwlock_write_unlock(&arp_globals.lock);301 fibril_mutex_unlock(&arp_globals.lock); 272 302 free(device); 273 303 return rc; … … 275 305 rc = arp_proto_create(&proto, protocol, address); 276 306 if (rc != EOK) { 277 fibril_ rwlock_write_unlock(&arp_globals.lock);307 fibril_mutex_unlock(&arp_globals.lock); 278 308 free(device); 279 309 return rc; … … 281 311 index = arp_protos_add(&device->protos, proto->service, proto); 282 312 if (index < 0) { 283 fibril_ rwlock_write_unlock(&arp_globals.lock);313 fibril_mutex_unlock(&arp_globals.lock); 284 314 arp_protos_destroy(&device->protos); 285 315 free(device); … … 290 320 /* Bind the new one */ 291 321 device->phone = nil_bind_service(device->service, 292 ( ipcarg_t) device->device_id, SERVICE_ARP,322 (sysarg_t) device->device_id, SERVICE_ARP, 293 323 arp_globals.client_connection); 294 324 if (device->phone < 0) { 295 fibril_ rwlock_write_unlock(&arp_globals.lock);325 fibril_mutex_unlock(&arp_globals.lock); 296 326 arp_protos_destroy(&device->protos); 297 327 free(device); … … 303 333 &device->packet_dimension); 304 334 if (rc != EOK) { 305 fibril_ rwlock_write_unlock(&arp_globals.lock);335 fibril_mutex_unlock(&arp_globals.lock); 306 336 arp_protos_destroy(&device->protos); 307 337 free(device); … … 313 343 &device->addr_data); 314 344 if (rc != EOK) { 315 fibril_ rwlock_write_unlock(&arp_globals.lock);345 fibril_mutex_unlock(&arp_globals.lock); 316 346 arp_protos_destroy(&device->protos); 317 347 free(device); … … 323 353 &device->broadcast_addr, &device->broadcast_data); 324 354 if (rc != EOK) { 325 fibril_ rwlock_write_unlock(&arp_globals.lock);355 fibril_mutex_unlock(&arp_globals.lock); 326 356 free(device->addr); 327 357 free(device->addr_data); … … 334 364 device); 335 365 if (rc != EOK) { 336 fibril_ rwlock_write_unlock(&arp_globals.lock);366 fibril_mutex_unlock(&arp_globals.lock); 337 367 free(device->addr); 338 368 free(device->addr_data); … … 347 377 device->service, protocol); 348 378 } 349 fibril_ rwlock_write_unlock(&arp_globals.lock);379 fibril_mutex_unlock(&arp_globals.lock); 350 380 351 381 return EOK; … … 363 393 int rc; 364 394 365 fibril_ rwlock_initialize(&arp_globals.lock);366 fibril_ rwlock_write_lock(&arp_globals.lock);395 fibril_mutex_initialize(&arp_globals.lock); 396 fibril_mutex_lock(&arp_globals.lock); 367 397 arp_globals.client_connection = client_connection; 368 398 rc = arp_cache_initialize(&arp_globals.cache); 369 fibril_ rwlock_write_unlock(&arp_globals.lock);399 fibril_mutex_unlock(&arp_globals.lock); 370 400 371 401 return rc; … … 383 413 arp_device_t *device; 384 414 385 fibril_ rwlock_write_lock(&arp_globals.lock);415 fibril_mutex_lock(&arp_globals.lock); 386 416 device = arp_cache_find(&arp_globals.cache, device_id); 387 417 if (!device) { 388 fibril_ rwlock_write_unlock(&arp_globals.lock);418 fibril_mutex_unlock(&arp_globals.lock); 389 419 return ENOENT; 390 420 } 391 421 device->packet_dimension.content = mtu; 392 fibril_ rwlock_write_unlock(&arp_globals.lock);393 printf("arp - device %d changed mtu to % d\n\n", device_id, mtu);422 fibril_mutex_unlock(&arp_globals.lock); 423 printf("arp - device %d changed mtu to %zu\n\n", device_id, mtu); 394 424 return EOK; 395 425 } … … 415 445 * @return ENOMEM if there is not enough memory left. 416 446 */ 417 static int arp_receive_message(device_id_t device_id, packet_t packet)447 static int arp_receive_message(device_id_t device_id, packet_t *packet) 418 448 { 419 449 size_t length; … … 421 451 arp_device_t *device; 422 452 arp_proto_t *proto; 423 measured_string_t *hw_source;453 arp_trans_t *trans; 424 454 uint8_t *src_hw; 425 455 uint8_t *src_proto; … … 452 482 des_hw = src_proto + header->protocol_length; 453 483 des_proto = des_hw + header->hardware_length; 454 hw_source= arp_addr_find(&proto->addresses, (char *) src_proto,455 CONVERT_SIZE(uint8_t, char, header->protocol_length));484 trans = arp_addr_find(&proto->addresses, (char *) src_proto, 485 header->protocol_length); 456 486 /* Exists? */ 457 if (hw_source) { 458 if (hw_source->length != CONVERT_SIZE(uint8_t, char, 459 header->hardware_length)) { 487 if (trans && trans->hw_addr) { 488 if (trans->hw_addr->length != header->hardware_length) 460 489 return EINVAL; 461 } 462 memcpy(hw_source->value, src_hw, hw_source->length); 490 memcpy(trans->hw_addr->value, src_hw, trans->hw_addr->length); 463 491 } 464 492 /* Is my protocol address? */ 465 if (proto->addr->length != CONVERT_SIZE(uint8_t, char, 466 header->protocol_length)) { 493 if (proto->addr->length != header->protocol_length) 467 494 return EINVAL; 468 }469 495 if (!str_lcmp(proto->addr->value, (char *) des_proto, 470 496 proto->addr->length)) { 471 497 /* Not already updated? */ 472 if (!hw_source) { 473 hw_source = measured_string_create_bulk((char *) src_hw, 474 CONVERT_SIZE(uint8_t, char, 475 header->hardware_length)); 476 if (!hw_source) 498 if (!trans) { 499 trans = (arp_trans_t *) malloc(sizeof(arp_trans_t)); 500 if (!trans) 477 501 return ENOMEM; 478 502 trans->hw_addr = NULL; 503 fibril_condvar_initialize(&trans->cv); 479 504 rc = arp_addr_add(&proto->addresses, (char *) src_proto, 480 CONVERT_SIZE(uint8_t, char,481 header->protocol_length), hw_source);482 if (rc != EOK)505 header->protocol_length, trans); 506 if (rc != EOK) { 507 /* The generic char map has already freed trans! */ 483 508 return rc; 509 } 510 } 511 if (!trans->hw_addr) { 512 trans->hw_addr = measured_string_create_bulk( 513 (char *) src_hw, header->hardware_length); 514 if (!trans->hw_addr) 515 return ENOMEM; 516 517 /* Notify the fibrils that wait for the translation. */ 518 fibril_condvar_broadcast(&trans->cv); 484 519 } 485 520 if (ntohs(header->operation) == ARPOP_REQUEST) { … … 490 525 memcpy(src_hw, device->addr->value, 491 526 device->packet_dimension.addr_len); 492 memcpy(des_hw, hw_source->value,527 memcpy(des_hw, trans->hw_addr->value, 493 528 header->hardware_length); 494 529 … … 516 551 * @param[in] protocol The protocol service. 517 552 * @param[in] target The target protocol address. 518 * @return The hardware address of the target. 519 * @return NULL if the target parameter is NULL. 520 * @return NULL if the device is not found. 521 * @return NULL if the device packet is too small to send a 522 * request. 523 * @return NULL if the hardware address is not found in the cache. 524 */ 525 static measured_string_t * 553 * @param[out] translation Where the hardware address of the target is stored. 554 * @return EOK on success. 555 * @return EAGAIN if the caller should try again. 556 * @return Other error codes in case of error. 557 */ 558 static int 526 559 arp_translate_message(device_id_t device_id, services_t protocol, 527 measured_string_t *target )560 measured_string_t *target, measured_string_t **translation) 528 561 { 529 562 arp_device_t *device; 530 563 arp_proto_t *proto; 531 measured_string_t *addr;564 arp_trans_t *trans; 532 565 size_t length; 533 packet_t packet;566 packet_t *packet; 534 567 arp_header_t *header; 535 536 if (!target) 537 return NULL; 568 bool retry = false; 569 int rc; 570 571 restart: 572 if (!target || !translation) 573 return EBADMEM; 538 574 539 575 device = arp_cache_find(&arp_globals.cache, device_id); 540 576 if (!device) 541 return NULL;577 return ENOENT; 542 578 543 579 proto = arp_protos_find(&device->protos, protocol); 544 580 if (!proto || (proto->addr->length != target->length)) 545 return NULL; 546 547 addr = arp_addr_find(&proto->addresses, target->value, target->length); 548 if (addr) 549 return addr; 581 return ENOENT; 582 583 trans = arp_addr_find(&proto->addresses, target->value, target->length); 584 if (trans) { 585 if (trans->hw_addr) { 586 *translation = trans->hw_addr; 587 return EOK; 588 } 589 if (retry) 590 return EAGAIN; 591 rc = fibril_condvar_wait_timeout(&trans->cv, &arp_globals.lock, 592 ARP_TRANS_WAIT); 593 if (rc == ETIMEOUT) 594 return ENOENT; 595 retry = true; 596 goto restart; 597 } 598 if (retry) 599 return EAGAIN; 550 600 551 601 /* ARP packet content size = header + (address + translation) * 2 */ 552 length = 8 + 2 * (CONVERT_SIZE(char, uint8_t, proto->addr->length) + 553 CONVERT_SIZE(char, uint8_t, device->addr->length)); 602 length = 8 + 2 * (proto->addr->length + device->addr->length); 554 603 if (length > device->packet_dimension.content) 555 return NULL;604 return ELIMIT; 556 605 557 606 packet = packet_get_4_remote(arp_globals.net_phone, … … 559 608 length, device->packet_dimension.suffix); 560 609 if (!packet) 561 return NULL;610 return ENOMEM; 562 611 563 612 header = (arp_header_t *) packet_suffix(packet, length); 564 613 if (!header) { 565 614 pq_release_remote(arp_globals.net_phone, packet_get_id(packet)); 566 return NULL;615 return ENOMEM; 567 616 } 568 617 … … 583 632 memcpy(((uint8_t *) header) + length, target->value, target->length); 584 633 585 if (packet_set_addr(packet, (uint8_t *) device->addr->value,586 (uint8_t *) device->broadcast_addr->value, 587 CONVERT_SIZE(char, uint8_t, device->addr->length))!= EOK) {634 rc = packet_set_addr(packet, (uint8_t *) device->addr->value, 635 (uint8_t *) device->broadcast_addr->value, device->addr->length); 636 if (rc != EOK) { 588 637 pq_release_remote(arp_globals.net_phone, packet_get_id(packet)); 589 return NULL;638 return rc; 590 639 } 591 640 592 641 nil_send_msg(device->phone, device_id, packet, SERVICE_ARP); 593 return NULL; 642 643 trans = (arp_trans_t *) malloc(sizeof(arp_trans_t)); 644 if (!trans) 645 return ENOMEM; 646 trans->hw_addr = NULL; 647 fibril_condvar_initialize(&trans->cv); 648 rc = arp_addr_add(&proto->addresses, target->value, target->length, 649 trans); 650 if (rc != EOK) { 651 /* The generic char map has already freed trans! */ 652 return rc; 653 } 654 655 rc = fibril_condvar_wait_timeout(&trans->cv, &arp_globals.lock, 656 ARP_TRANS_WAIT); 657 if (rc == ETIMEOUT) 658 return ENOENT; 659 retry = true; 660 goto restart; 594 661 } 595 662 … … 615 682 measured_string_t *translation; 616 683 char *data; 617 packet_t packet;618 packet_t next;684 packet_t *packet; 685 packet_t *next; 619 686 int rc; 620 687 621 688 *answer_count = 0; 622 switch (IPC_GET_ METHOD(*call)) {689 switch (IPC_GET_IMETHOD(*call)) { 623 690 case IPC_M_PHONE_HUNGUP: 624 691 return EOK; … … 642 709 return rc; 643 710 644 fibril_ rwlock_read_lock(&arp_globals.lock);645 translation= arp_translate_message(IPC_GET_DEVICE(call),646 IPC_GET_SERVICE(call), address );711 fibril_mutex_lock(&arp_globals.lock); 712 rc = arp_translate_message(IPC_GET_DEVICE(call), 713 IPC_GET_SERVICE(call), address, &translation); 647 714 free(address); 648 715 free(data); 716 if (rc != EOK) { 717 fibril_mutex_unlock(&arp_globals.lock); 718 return rc; 719 } 649 720 if (!translation) { 650 fibril_ rwlock_read_unlock(&arp_globals.lock);721 fibril_mutex_unlock(&arp_globals.lock); 651 722 return ENOENT; 652 723 } 653 724 rc = measured_strings_reply(translation, 1); 654 fibril_ rwlock_read_unlock(&arp_globals.lock);725 fibril_mutex_unlock(&arp_globals.lock); 655 726 return rc; 656 727 … … 682 753 return rc; 683 754 684 fibril_ rwlock_read_lock(&arp_globals.lock);755 fibril_mutex_lock(&arp_globals.lock); 685 756 do { 686 757 next = pq_detach(packet); … … 692 763 packet = next; 693 764 } while (packet); 694 fibril_ rwlock_read_unlock(&arp_globals.lock);765 fibril_mutex_unlock(&arp_globals.lock); 695 766 696 767 return EOK; … … 736 807 * result. 737 808 */ 738 if ((IPC_GET_ METHOD(call) == IPC_M_PHONE_HUNGUP) ||809 if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) || 739 810 (res == EHANGUP)) 740 811 return; -
uspace/srv/net/il/arp/arp.h
r1bfd3d3 r973ef9fc 65 65 typedef struct arp_proto arp_proto_t; 66 66 67 /** Type definition of the ARP address translation record. 68 * @see arp_trans 69 */ 70 typedef struct arp_trans arp_trans_t; 71 67 72 /** ARP address map. 68 73 * … … 70 75 * @see generic_char_map.h 71 76 */ 72 GENERIC_CHAR_MAP_DECLARE(arp_addr, measured_string_t);77 GENERIC_CHAR_MAP_DECLARE(arp_addr, arp_trans_t); 73 78 74 79 /** ARP address cache. … … 89 94 struct arp_device { 90 95 /** Actual device hardware address. */ 91 measured_string_t * addr;96 measured_string_t *addr; 92 97 /** Actual device hardware address data. */ 93 98 char *addr_data; 94 99 /** Broadcast device hardware address. */ 95 measured_string_t * broadcast_addr;100 measured_string_t *broadcast_addr; 96 101 /** Broadcast device hardware address data. */ 97 102 char *broadcast_data; … … 129 134 int net_phone; 130 135 /** Safety lock. */ 131 fibril_ rwlock_t lock;136 fibril_mutex_t lock; 132 137 }; 133 138 … … 144 149 }; 145 150 151 /** ARP address translation record. */ 152 struct arp_trans { 153 /** 154 * Hardware address for the translation. NULL denotes an incomplete 155 * record with possible waiters. 156 */ 157 measured_string_t *hw_addr; 158 /** Condition variable used for waiting for completion of the record. */ 159 fibril_condvar_t cv; 160 }; 161 146 162 #endif 147 163 148 164 /** @} 149 165 */ 166 -
uspace/srv/net/il/arp/arp_module.c
r1bfd3d3 r973ef9fc 65 65 int il_module_start_standalone(async_client_conn_t client_connection) 66 66 { 67 ipcarg_t phonehash;67 sysarg_t phonehash; 68 68 int rc; 69 69 … … 79 79 goto out; 80 80 81 rc = REGISTER_ME(SERVICE_ARP, &phonehash);81 rc = ipc_connect_to_me(PHONE_NS, SERVICE_ARP, 0, 0, &phonehash); 82 82 if (rc != EOK) 83 83 goto out; -
uspace/srv/net/il/ip/ip.c
r1bfd3d3 r973ef9fc 129 129 * @return The result parameter. 130 130 */ 131 static int ip_release_and_return(packet_t packet, int result)131 static int ip_release_and_return(packet_t *packet, int result) 132 132 { 133 133 pq_release_remote(ip_globals.net_phone, packet_get_id(packet)); … … 170 170 * @return Other error codes as defined for the packet_set_addr(). 171 171 */ 172 static int ip_prepare_icmp(packet_t packet, ip_header_t *header)173 { 174 packet_t next;172 static int ip_prepare_icmp(packet_t *packet, ip_header_t *header) 173 { 174 packet_t *next; 175 175 struct sockaddr *dest; 176 176 struct sockaddr_in dest_in; … … 233 233 */ 234 234 static int 235 ip_prepare_icmp_and_get_phone(services_t error, packet_t packet,235 ip_prepare_icmp_and_get_phone(services_t error, packet_t *packet, 236 236 ip_header_t *header) 237 237 { … … 430 430 // binds the netif service which also initializes the device 431 431 ip_netif->phone = nil_bind_service(ip_netif->service, 432 ( ipcarg_t) ip_netif->device_id, SERVICE_IP,432 (sysarg_t) ip_netif->device_id, SERVICE_IP, 433 433 ip_globals.client_connection); 434 434 if (ip_netif->phone < 0) { … … 442 442 if (route) { 443 443 address.value = (char *) &route->address.s_addr; 444 address.length = CONVERT_SIZE(in_addr_t, char, 1);444 address.length = sizeof(in_addr_t); 445 445 446 446 rc = arp_device_req(ip_netif->arp->phone, … … 461 461 462 462 if (ip_netif->packet_dimension.content < IP_MIN_CONTENT) { 463 printf("Maximum transmission unit % dbytes is too small, at "463 printf("Maximum transmission unit %zu bytes is too small, at " 464 464 "least %d bytes are needed\n", 465 465 ip_netif->packet_dimension.content, IP_MIN_CONTENT); … … 502 502 fibril_rwlock_write_unlock(&ip_globals.netifs_lock); 503 503 504 printf("%s: Device %d changed MTU to % d\n", NAME, device_id, mtu);504 printf("%s: Device %d changed MTU to %zu\n", NAME, device_id, mtu); 505 505 506 506 return EOK; … … 543 543 */ 544 544 static ip_header_t * 545 ip_create_middle_header(packet_t packet, ip_header_t *last)545 ip_create_middle_header(packet_t *packet, ip_header_t *last) 546 546 { 547 547 ip_header_t *middle; … … 622 622 */ 623 623 static int 624 ip_prepare_packet(in_addr_t *source, in_addr_t dest, packet_t packet,624 ip_prepare_packet(in_addr_t *source, in_addr_t dest, packet_t *packet, 625 625 measured_string_t *destination) 626 626 { … … 629 629 ip_header_t *last_header; 630 630 ip_header_t *middle_header; 631 packet_t next;631 packet_t *next; 632 632 int rc; 633 633 … … 639 639 if (destination) { 640 640 rc = packet_set_addr(packet, NULL, (uint8_t *) destination->value, 641 CONVERT_SIZE(char, uint8_t, destination->length));641 destination->length); 642 642 } else { 643 643 rc = packet_set_addr(packet, NULL, NULL, 0); … … 687 687 rc = packet_set_addr(next, NULL, 688 688 (uint8_t *) destination->value, 689 CONVERT_SIZE(char, uint8_t, 690 destination->length)); 689 destination->length); 691 690 if (rc != EOK) { 692 691 free(last_header); … … 718 717 rc = packet_set_addr(next, NULL, 719 718 (uint8_t *) destination->value, 720 CONVERT_SIZE(char, uint8_t, destination->length));719 destination->length); 721 720 if (rc != EOK) { 722 721 free(last_header); … … 754 753 */ 755 754 static int 756 ip_fragment_packet_data(packet_t packet, packet_tnew_packet,755 ip_fragment_packet_data(packet_t *packet, packet_t *new_packet, 757 756 ip_header_t *header, ip_header_t *new_header, size_t length, 758 757 const struct sockaddr *src, const struct sockaddr *dest, socklen_t addrlen) … … 816 815 */ 817 816 static int 818 ip_fragment_packet(packet_t packet, size_t length, size_t prefix, size_t suffix,817 ip_fragment_packet(packet_t *packet, size_t length, size_t prefix, size_t suffix, 819 818 socklen_t addr_len) 820 819 { 821 packet_t new_packet;820 packet_t *new_packet; 822 821 ip_header_t *header; 823 822 ip_header_t *middle_header; … … 922 921 * @return NULL if there are no packets left. 923 922 */ 924 static packet_t 925 ip_split_packet(packet_t packet, size_t prefix, size_t content, size_t suffix,923 static packet_t * 924 ip_split_packet(packet_t *packet, size_t prefix, size_t content, size_t suffix, 926 925 socklen_t addr_len, services_t error) 927 926 { 928 927 size_t length; 929 packet_t next;930 packet_t new_packet;928 packet_t *next; 929 packet_t *new_packet; 931 930 int result; 932 931 int phone; … … 993 992 */ 994 993 static int 995 ip_send_route(packet_t packet, ip_netif_t *netif, ip_route_t *route,994 ip_send_route(packet_t *packet, ip_netif_t *netif, ip_route_t *route, 996 995 in_addr_t *src, in_addr_t dest, services_t error) 997 996 { … … 1006 1005 destination.value = route->gateway.s_addr ? 1007 1006 (char *) &route->gateway.s_addr : (char *) &dest.s_addr; 1008 destination.length = CONVERT_SIZE(dest.s_addr, char, 1);1007 destination.length = sizeof(dest.s_addr); 1009 1008 1010 1009 rc = arp_translate_req(netif->arp->phone, netif->device_id, … … 1247 1246 1248 1247 static int 1249 ip_send_msg_local(int il_phone, device_id_t device_id, packet_t packet,1248 ip_send_msg_local(int il_phone, device_id_t device_id, packet_t *packet, 1250 1249 services_t sender, services_t error) 1251 1250 { … … 1451 1450 */ 1452 1451 static int 1453 ip_deliver_local(device_id_t device_id, packet_t packet, ip_header_t *header,1452 ip_deliver_local(device_id_t device_id, packet_t *packet, ip_header_t *header, 1454 1453 services_t error) 1455 1454 { … … 1553 1552 */ 1554 1553 static int 1555 ip_process_packet(device_id_t device_id, packet_t packet)1554 ip_process_packet(device_id_t device_id, packet_t *packet) 1556 1555 { 1557 1556 ip_header_t *header; … … 1715 1714 static int 1716 1715 ip_received_error_msg_local(int ip_phone, device_id_t device_id, 1717 packet_t packet, services_t target, services_t error)1716 packet_t *packet, services_t target, services_t error) 1718 1717 { 1719 1718 uint8_t *data; … … 1758 1757 // clear the ARP mapping if any 1759 1758 address.value = (char *) &header->destination_address; 1760 address.length = CONVERT_SIZE(uint8_t, char, 1761 sizeof(header->destination_address)); 1759 address.length = sizeof(header->destination_address); 1762 1760 arp_clear_address_req(netif->arp->phone, 1763 1761 netif->device_id, SERVICE_IP, &address); … … 1859 1857 * @return ENOMEM if there is not enough memory left. 1860 1858 */ 1861 static int ip_receive_message(device_id_t device_id, packet_t packet)1862 { 1863 packet_t next;1859 static int ip_receive_message(device_id_t device_id, packet_t *packet) 1860 { 1861 packet_t *next; 1864 1862 1865 1863 do { … … 1890 1888 int *answer_count) 1891 1889 { 1892 packet_t packet;1890 packet_t *packet; 1893 1891 struct sockaddr *addr; 1894 1892 size_t addrlen; … … 1902 1900 1903 1901 *answer_count = 0; 1904 switch (IPC_GET_ METHOD(*call)) {1902 switch (IPC_GET_IMETHOD(*call)) { 1905 1903 case IPC_M_PHONE_HUNGUP: 1906 1904 return EOK; … … 1951 1949 1952 1950 case NET_IP_GET_ROUTE: 1953 rc = data_receive((void **) &addr, &addrlen); 1951 rc = async_data_write_accept((void **) &addr, false, 0, 0, 0, 1952 &addrlen); 1954 1953 if (rc != EOK) 1955 1954 return rc; … … 2025 2024 * result. 2026 2025 */ 2027 if ((IPC_GET_ METHOD(call) == IPC_M_PHONE_HUNGUP) ||2026 if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) || 2028 2027 (res == EHANGUP)) { 2029 2028 return; -
uspace/srv/net/il/ip/ip_module.c
r1bfd3d3 r973ef9fc 66 66 int il_module_start_standalone(async_client_conn_t client_connection) 67 67 { 68 ipcarg_t phonehash;68 sysarg_t phonehash; 69 69 int rc; 70 70 … … 80 80 goto out; 81 81 82 rc = REGISTER_ME(SERVICE_IP, &phonehash);82 rc = ipc_connect_to_me(PHONE_NS, SERVICE_IP, 0, 0, &phonehash); 83 83 if (rc != EOK) 84 84 goto out; -
uspace/srv/net/net/net.c
r1bfd3d3 r973ef9fc 322 322 static int net_module_start(async_client_conn_t client_connection) 323 323 { 324 ipcarg_t phonehash;324 sysarg_t phonehash; 325 325 int rc; 326 326 … … 335 335 goto out; 336 336 337 rc = REGISTER_ME(SERVICE_NETWORKING, &phonehash);337 rc = ipc_connect_to_me(PHONE_NS, SERVICE_NETWORKING, 0, 0, &phonehash); 338 338 if (rc != EOK) 339 339 goto out; … … 632 632 633 633 *answer_count = 0; 634 switch (IPC_GET_ METHOD(*call)) {634 switch (IPC_GET_IMETHOD(*call)) { 635 635 case IPC_M_PHONE_HUNGUP: 636 636 return EOK; … … 697 697 698 698 /* End if told to either by the message or the processing result */ 699 if ((IPC_GET_ METHOD(call) == IPC_M_PHONE_HUNGUP) || (res == EHANGUP))699 if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) || (res == EHANGUP)) 700 700 return; 701 701 -
uspace/srv/net/netif/lo/Makefile
r1bfd3d3 r973ef9fc 39 39 -include $(CONFIG_MAKEFILE) 40 40 41 ifeq ($(CONFIG_NETIF_NIL_BUNDLE),y)42 LIBS += $(USPACE_PREFIX)/srv/net/nil/nildummy/libnildummy.a43 endif44 45 41 BINARY = lo 46 42 -
uspace/srv/net/netif/lo/lo.c
r1bfd3d3 r973ef9fc 164 164 int netif_initialize(void) 165 165 { 166 ipcarg_t phonehash;167 168 return REGISTER_ME(SERVICE_LO, &phonehash);166 sysarg_t phonehash; 167 168 return ipc_connect_to_me(PHONE_NS, SERVICE_LO, 0, 0, &phonehash); 169 169 } 170 170 … … 185 185 } 186 186 187 int netif_send_message(device_id_t device_id, packet_t packet, services_t sender)187 int netif_send_message(device_id_t device_id, packet_t *packet, services_t sender) 188 188 { 189 189 netif_device_t *device; 190 190 size_t length; 191 packet_t next;191 packet_t *next; 192 192 int phone; 193 193 int rc; … … 262 262 * result. 263 263 */ 264 if ((IPC_GET_ METHOD(call) == IPC_M_PHONE_HUNGUP) ||264 if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) || 265 265 (res == EHANGUP)) 266 266 return; -
uspace/srv/net/nil/eth/Makefile
r1bfd3d3 r973ef9fc 39 39 -include $(CONFIG_MAKEFILE) 40 40 41 ifeq ($(CONFIG_NETIF_NIL_BUNDLE),y) 42 LIBRARY = libeth 43 else 44 BINARY = eth 45 endif 41 BINARY = eth 46 42 47 43 SOURCES = \ -
uspace/srv/net/nil/eth/eth.c
r1bfd3d3 r973ef9fc 201 201 202 202 eth_globals.broadcast_addr = 203 measured_string_create_bulk("\xFF\xFF\xFF\xFF\xFF\xFF", 204 CONVERT_SIZE(uint8_t, char, ETH_ADDR)); 203 measured_string_create_bulk("\xFF\xFF\xFF\xFF\xFF\xFF", ETH_ADDR); 205 204 if (!eth_globals.broadcast_addr) { 206 205 rc = ENOMEM; … … 234 233 static void eth_receiver(ipc_callid_t iid, ipc_call_t *icall) 235 234 { 236 packet_t packet;235 packet_t *packet; 237 236 int rc; 238 237 239 238 while (true) { 240 switch (IPC_GET_ METHOD(*icall)) {239 switch (IPC_GET_IMETHOD(*icall)) { 241 240 case NET_NIL_DEVICE_STATE: 242 241 nil_device_state_msg_local(0, IPC_GET_DEVICE(icall), … … 251 250 IPC_GET_DEVICE(icall), packet, 0); 252 251 } 253 ipc_answer_0(iid, ( ipcarg_t) rc);252 ipc_answer_0(iid, (sysarg_t) rc); 254 253 break; 255 254 default: 256 ipc_answer_0(iid, ( ipcarg_t) ENOTSUP);255 ipc_answer_0(iid, (sysarg_t) ENOTSUP); 257 256 } 258 257 … … 315 314 device->mtu = ETH_MAX_TAGGED_CONTENT(device->flags); 316 315 317 printf("Device %d already exists:\tMTU\t= % d\n",316 printf("Device %d already exists:\tMTU\t= %zu\n", 318 317 device->device_id, device->mtu); 319 318 fibril_rwlock_write_unlock(ð_globals.devices_lock); … … 407 406 } 408 407 409 printf("%s: Device registered (id: %d, service: %d: mtu: % d, "408 printf("%s: Device registered (id: %d, service: %d: mtu: %zu, " 410 409 "mac: %x:%x:%x:%x:%x:%x, flags: 0x%x)\n", 411 410 NAME, device->device_id, device->service, device->mtu, … … 429 428 * @return NULL if the packet address length is not big enough. 430 429 */ 431 static eth_proto_t *eth_process_packet(int flags, packet_t packet)430 static eth_proto_t *eth_process_packet(int flags, packet_t *packet) 432 431 { 433 432 eth_header_snap_t *header; … … 509 508 510 509 int nil_received_msg_local(int nil_phone, device_id_t device_id, 511 packet_t packet, services_t target)510 packet_t *packet, services_t target) 512 511 { 513 512 eth_proto_t *proto; 514 packet_t next;513 packet_t *next; 515 514 eth_device_t *device; 516 515 int flags; … … 680 679 */ 681 680 static int 682 eth_prepare_packet(int flags, packet_t packet, uint8_t *src_addr, int ethertype,681 eth_prepare_packet(int flags, packet_t *packet, uint8_t *src_addr, int ethertype, 683 682 size_t mtu) 684 683 { … … 787 786 * @return EINVAL if the service parameter is not known. 788 787 */ 789 static int eth_send_message(device_id_t device_id, packet_t packet,788 static int eth_send_message(device_id_t device_id, packet_t *packet, 790 789 services_t sender) 791 790 { 792 791 eth_device_t *device; 793 packet_t next;794 packet_t tmp;792 packet_t *next; 793 packet_t *tmp; 795 794 int ethertype; 796 795 int rc; … … 841 840 { 842 841 measured_string_t *address; 843 packet_t packet;842 packet_t *packet; 844 843 size_t addrlen; 845 844 size_t prefix; … … 849 848 850 849 *answer_count = 0; 851 switch (IPC_GET_ METHOD(*call)) {850 switch (IPC_GET_IMETHOD(*call)) { 852 851 case IPC_M_PHONE_HUNGUP: 853 852 return EOK; … … 926 925 * result. 927 926 */ 928 if ((IPC_GET_ METHOD(call) == IPC_M_PHONE_HUNGUP) ||927 if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) || 929 928 (res == EHANGUP)) 930 929 return; -
uspace/srv/net/nil/eth/eth_module.c
r1bfd3d3 r973ef9fc 52 52 int nil_module_start_standalone(async_client_conn_t client_connection) 53 53 { 54 ipcarg_t phonehash;54 sysarg_t phonehash; 55 55 int rc; 56 56 … … 66 66 goto out; 67 67 68 rc = REGISTER_ME(SERVICE_ETHERNET, &phonehash);68 rc = ipc_connect_to_me(PHONE_NS, SERVICE_ETHERNET, 0, 0, &phonehash); 69 69 if (rc != EOK) 70 70 goto out; -
uspace/srv/net/nil/nildummy/Makefile
r1bfd3d3 r973ef9fc 39 39 -include $(CONFIG_MAKEFILE) 40 40 41 ifeq ($(CONFIG_NETIF_NIL_BUNDLE),y) 42 LIBRARY = libnildummy 43 else 44 BINARY = nildummy 45 endif 41 BINARY = nildummy 46 42 47 43 SOURCES = \ -
uspace/srv/net/nil/nildummy/nildummy.c
r1bfd3d3 r973ef9fc 106 106 static void nildummy_receiver(ipc_callid_t iid, ipc_call_t *icall) 107 107 { 108 packet_t packet;108 packet_t *packet; 109 109 int rc; 110 110 111 111 while (true) { 112 switch (IPC_GET_ METHOD(*icall)) {112 switch (IPC_GET_IMETHOD(*icall)) { 113 113 case NET_NIL_DEVICE_STATE: 114 114 rc = nil_device_state_msg_local(0, 115 115 IPC_GET_DEVICE(icall), IPC_GET_STATE(icall)); 116 ipc_answer_0(iid, ( ipcarg_t) rc);116 ipc_answer_0(iid, (sysarg_t) rc); 117 117 break; 118 118 … … 124 124 IPC_GET_DEVICE(icall), packet, 0); 125 125 } 126 ipc_answer_0(iid, ( ipcarg_t) rc);126 ipc_answer_0(iid, (sysarg_t) rc); 127 127 break; 128 128 129 129 default: 130 ipc_answer_0(iid, ( ipcarg_t) ENOTSUP);130 ipc_answer_0(iid, (sysarg_t) ENOTSUP); 131 131 } 132 132 … … 175 175 device->mtu = NET_DEFAULT_MTU; 176 176 177 printf("Device %d already exists:\tMTU\t= % d\n",177 printf("Device %d already exists:\tMTU\t= %zu\n", 178 178 device->device_id, device->mtu); 179 179 fibril_rwlock_write_unlock(&nildummy_globals.devices_lock); … … 232 232 } 233 233 234 printf("%s: Device registered (id: %d, service: %d, mtu: % d)\n",234 printf("%s: Device registered (id: %d, service: %d, mtu: %zu)\n", 235 235 NAME, device->device_id, device->service, device->mtu); 236 236 fibril_rwlock_write_unlock(&nildummy_globals.devices_lock); … … 304 304 305 305 int nil_received_msg_local(int nil_phone, device_id_t device_id, 306 packet_t packet, services_t target)307 { 308 packet_t next;306 packet_t *packet, services_t target) 307 { 308 packet_t *next; 309 309 310 310 fibril_rwlock_read_lock(&nildummy_globals.protos_lock); … … 354 354 * @return EINVAL if the service parameter is not known. 355 355 */ 356 static int nildummy_send_message(device_id_t device_id, packet_t packet,356 static int nildummy_send_message(device_id_t device_id, packet_t *packet, 357 357 services_t sender) 358 358 { … … 378 378 { 379 379 measured_string_t *address; 380 packet_t packet;380 packet_t *packet; 381 381 size_t addrlen; 382 382 size_t prefix; … … 386 386 387 387 *answer_count = 0; 388 switch (IPC_GET_ METHOD(*call)) {388 switch (IPC_GET_IMETHOD(*call)) { 389 389 case IPC_M_PHONE_HUNGUP: 390 390 return EOK; … … 466 466 * result. 467 467 */ 468 if ((IPC_GET_ METHOD(call) == IPC_M_PHONE_HUNGUP) ||468 if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) || 469 469 (res == EHANGUP)) 470 470 return; -
uspace/srv/net/nil/nildummy/nildummy_module.c
r1bfd3d3 r973ef9fc 52 52 int nil_module_start_standalone(async_client_conn_t client_connection) 53 53 { 54 ipcarg_t phonehash;54 sysarg_t phonehash; 55 55 int rc; 56 56 … … 67 67 goto out; 68 68 69 rc = REGISTER_ME(SERVICE_NILDUMMY, &phonehash);69 rc = ipc_connect_to_me(PHONE_NS, SERVICE_NILDUMMY, 0, 0, &phonehash); 70 70 if (rc != EOK) 71 71 goto out; -
uspace/srv/net/tl/icmp/icmp.c
r1bfd3d3 r973ef9fc 130 130 * @return The result parameter. 131 131 */ 132 static int icmp_release_and_return(packet_t packet, int result)132 static int icmp_release_and_return(packet_t *packet, int result) 133 133 { 134 134 pq_release_remote(icmp_globals.net_phone, packet_get_id(packet)); … … 155 155 * @return EPERM if the error message is not allowed. 156 156 */ 157 static int icmp_send_packet(icmp_type_t type, icmp_code_t code, packet_t packet,157 static int icmp_send_packet(icmp_type_t type, icmp_code_t code, packet_t *packet, 158 158 icmp_header_t *header, services_t error, ip_ttl_t ttl, ip_tos_t tos, 159 159 int dont_fragment) … … 189 189 * @return NULL on errors. 190 190 */ 191 static icmp_header_t *icmp_prepare_packet(packet_t packet)191 static icmp_header_t *icmp_prepare_packet(packet_t *packet) 192 192 { 193 193 icmp_header_t *header; … … 248 248 { 249 249 icmp_header_t *header; 250 packet_t packet;250 packet_t *packet; 251 251 size_t length; 252 252 uint8_t *data; … … 340 340 341 341 static int icmp_destination_unreachable_msg_local(int icmp_phone, 342 icmp_code_t code, icmp_param_t mtu, packet_t packet)342 icmp_code_t code, icmp_param_t mtu, packet_t *packet) 343 343 { 344 344 icmp_header_t *header; … … 355 355 } 356 356 357 static int icmp_source_quench_msg_local(int icmp_phone, packet_t packet)357 static int icmp_source_quench_msg_local(int icmp_phone, packet_t *packet) 358 358 { 359 359 icmp_header_t *header; … … 368 368 369 369 static int icmp_time_exceeded_msg_local(int icmp_phone, icmp_code_t code, 370 packet_t packet)370 packet_t *packet) 371 371 { 372 372 icmp_header_t *header; … … 381 381 382 382 static int icmp_parameter_problem_msg_local(int icmp_phone, icmp_code_t code, 383 icmp_param_t pointer, packet_t packet)383 icmp_param_t pointer, packet_t *packet) 384 384 { 385 385 icmp_header_t *header; … … 479 479 * @param[in] code The received reply message code. 480 480 */ 481 static void icmp_process_echo_reply(packet_t packet, icmp_header_t *header,481 static void icmp_process_echo_reply(packet_t *packet, icmp_header_t *header, 482 482 icmp_type_t type, icmp_code_t code) 483 483 { … … 518 518 * ip_client_process_packet() function. 519 519 */ 520 static int icmp_process_packet(packet_t packet, services_t error)520 static int icmp_process_packet(packet_t *packet, services_t error) 521 521 { 522 522 size_t length; … … 658 658 * icmp_process_packet() function. 659 659 */ 660 static int icmp_received_msg_local(device_id_t device_id, packet_t packet,660 static int icmp_received_msg_local(device_id_t device_id, packet_t *packet, 661 661 services_t receiver, services_t error) 662 662 { … … 690 690 static int icmp_process_message(ipc_call_t *call) 691 691 { 692 packet_t packet;692 packet_t *packet; 693 693 int rc; 694 694 695 switch (IPC_GET_ METHOD(*call)) {695 switch (IPC_GET_IMETHOD(*call)) { 696 696 case NET_ICMP_DEST_UNREACH: 697 697 rc = packet_translate_remote(icmp_globals.net_phone, &packet, … … 824 824 825 825 /* Process the call */ 826 switch (IPC_GET_ METHOD(call)) {826 switch (IPC_GET_IMETHOD(call)) { 827 827 case IPC_M_PHONE_HUNGUP: 828 828 keep_on_going = false; … … 896 896 ipc_call_t *answer, int *answer_count) 897 897 { 898 packet_t packet;898 packet_t *packet; 899 899 int rc; 900 900 901 901 *answer_count = 0; 902 switch (IPC_GET_ METHOD(*call)) {902 switch (IPC_GET_IMETHOD(*call)) { 903 903 case NET_TL_RECEIVED: 904 904 rc = packet_translate_remote(icmp_globals.net_phone, &packet, … … 953 953 * result. 954 954 */ 955 if ((IPC_GET_ METHOD(call) == IPC_M_PHONE_HUNGUP) ||955 if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) || 956 956 (res == EHANGUP)) 957 957 return; -
uspace/srv/net/tl/icmp/icmp_module.c
r1bfd3d3 r973ef9fc 58 58 int tl_module_start_standalone(async_client_conn_t client_connection) 59 59 { 60 ipcarg_t phonehash;60 sysarg_t phonehash; 61 61 int rc; 62 62 … … 74 74 goto out; 75 75 76 rc = REGISTER_ME(SERVICE_ICMP, &phonehash);76 rc = ipc_connect_to_me(PHONE_NS, SERVICE_ICMP, 0, 0, &phonehash); 77 77 if (rc != EOK) 78 78 goto out; -
uspace/srv/net/tl/tcp/tcp.c
r1bfd3d3 r973ef9fc 160 160 }; 161 161 162 static int tcp_release_and_return(packet_t , int);162 static int tcp_release_and_return(packet_t *, int); 163 163 static void tcp_prepare_operation_header(socket_core_t *, tcp_socket_data_t *, 164 164 tcp_header_t *, int synchronize, int); … … 171 171 static int tcp_release_after_timeout(void *); 172 172 173 static int tcp_process_packet(device_id_t, packet_t , services_t);173 static int tcp_process_packet(device_id_t, packet_t *, services_t); 174 174 static int tcp_connect_core(socket_core_t *, socket_cores_t *, 175 175 struct sockaddr *, socklen_t); 176 176 static int tcp_queue_prepare_packet(socket_core_t *, tcp_socket_data_t *, 177 packet_t , size_t);178 static int tcp_queue_packet(socket_core_t *, tcp_socket_data_t *, packet_t ,177 packet_t *, size_t); 178 static int tcp_queue_packet(socket_core_t *, tcp_socket_data_t *, packet_t *, 179 179 size_t); 180 static packet_t tcp_get_packets_to_send(socket_core_t *, tcp_socket_data_t *);181 static void tcp_send_packets(device_id_t, packet_t );180 static packet_t *tcp_get_packets_to_send(socket_core_t *, tcp_socket_data_t *); 181 static void tcp_send_packets(device_id_t, packet_t *); 182 182 183 183 static void tcp_process_acknowledgement(socket_core_t *, tcp_socket_data_t *, 184 184 tcp_header_t *); 185 static packet_t tcp_send_prepare_packet(socket_core_t *, tcp_socket_data_t *,186 packet_t , size_t, size_t);187 static packet_t tcp_prepare_copy(socket_core_t *, tcp_socket_data_t *, packet_t,188 size_t, size_t);185 static packet_t *tcp_send_prepare_packet(socket_core_t *, tcp_socket_data_t *, 186 packet_t *, size_t, size_t); 187 static packet_t *tcp_prepare_copy(socket_core_t *, tcp_socket_data_t *, 188 packet_t *, size_t, size_t); 189 189 /* static */ void tcp_retransmit_packet(socket_core_t *, tcp_socket_data_t *, 190 190 size_t); 191 static int tcp_create_notification_packet(packet_t * , socket_core_t *,191 static int tcp_create_notification_packet(packet_t **, socket_core_t *, 192 192 tcp_socket_data_t *, int, int); 193 193 static void tcp_refresh_socket_data(tcp_socket_data_t *); … … 196 196 197 197 static int tcp_process_listen(socket_core_t *, tcp_socket_data_t *, 198 tcp_header_t *, packet_t , struct sockaddr *, struct sockaddr *, size_t);198 tcp_header_t *, packet_t *, struct sockaddr *, struct sockaddr *, size_t); 199 199 static int tcp_process_syn_sent(socket_core_t *, tcp_socket_data_t *, 200 tcp_header_t *, packet_t );200 tcp_header_t *, packet_t *); 201 201 static int tcp_process_syn_received(socket_core_t *, tcp_socket_data_t *, 202 tcp_header_t *, packet_t );202 tcp_header_t *, packet_t *); 203 203 static int tcp_process_established(socket_core_t *, tcp_socket_data_t *, 204 tcp_header_t *, packet_t , int, size_t);204 tcp_header_t *, packet_t *, int, size_t); 205 205 static int tcp_queue_received_packet(socket_core_t *, tcp_socket_data_t *, 206 packet_t , int, size_t);207 208 static int tcp_received_msg(device_id_t, packet_t , services_t, services_t);206 packet_t *, int, size_t); 207 208 static int tcp_received_msg(device_id_t, packet_t *, services_t, services_t); 209 209 static int tcp_process_client_messages(ipc_callid_t, ipc_call_t); 210 210 … … 262 262 } 263 263 264 int tcp_received_msg(device_id_t device_id, packet_t packet,264 int tcp_received_msg(device_id_t device_id, packet_t *packet, 265 265 services_t receiver, services_t error) 266 266 { … … 280 280 } 281 281 282 int tcp_process_packet(device_id_t device_id, packet_t packet, services_t error)282 int tcp_process_packet(device_id_t device_id, packet_t *packet, services_t error) 283 283 { 284 284 size_t length; … … 288 288 socket_core_t *socket; 289 289 tcp_socket_data_t *socket_data; 290 packet_t next_packet;290 packet_t *next_packet; 291 291 size_t total_length; 292 292 uint32_t checksum; … … 453 453 454 454 has_error_service: 455 fibril_rwlock_ read_unlock(&tcp_globals.lock);455 fibril_rwlock_write_unlock(&tcp_globals.lock); 456 456 457 457 /* TODO error reporting/handling */ … … 493 493 494 494 int tcp_process_established(socket_core_t *socket, tcp_socket_data_t * 495 socket_data, tcp_header_t *header, packet_t packet, int fragments,495 socket_data, tcp_header_t *header, packet_t *packet, int fragments, 496 496 size_t total_length) 497 497 { 498 packet_t next_packet;499 packet_t tmp_packet;498 packet_t *next_packet; 499 packet_t *tmp_packet; 500 500 uint32_t old_incoming; 501 501 size_t order; … … 801 801 802 802 int tcp_queue_received_packet(socket_core_t *socket, 803 tcp_socket_data_t *socket_data, packet_t packet, int fragments,803 tcp_socket_data_t *socket_data, packet_t *packet, int fragments, 804 804 size_t total_length) 805 805 { … … 829 829 /* Notify the destination socket */ 830 830 async_msg_5(socket->phone, NET_SOCKET_RECEIVED, 831 ( ipcarg_t) socket->socket_id,831 (sysarg_t) socket->socket_id, 832 832 ((packet_dimension->content < socket_data->data_fragment_size) ? 833 833 packet_dimension->content : socket_data->data_fragment_size), 0, 0, 834 ( ipcarg_t) fragments);834 (sysarg_t) fragments); 835 835 836 836 return EOK; … … 838 838 839 839 int tcp_process_syn_sent(socket_core_t *socket, tcp_socket_data_t * 840 socket_data, tcp_header_t *header, packet_t packet)841 { 842 packet_t next_packet;840 socket_data, tcp_header_t *header, packet_t *packet) 841 { 842 packet_t *next_packet; 843 843 int rc; 844 844 … … 897 897 int tcp_process_listen(socket_core_t *listening_socket, 898 898 tcp_socket_data_t *listening_socket_data, tcp_header_t *header, 899 packet_t packet, struct sockaddr *src, struct sockaddr *dest,899 packet_t *packet, struct sockaddr *src, struct sockaddr *dest, 900 900 size_t addrlen) 901 901 { 902 packet_t next_packet;902 packet_t *next_packet; 903 903 socket_core_t *socket; 904 904 tcp_socket_data_t *socket_data; … … 1056 1056 1057 1057 int tcp_process_syn_received(socket_core_t *socket, 1058 tcp_socket_data_t *socket_data, tcp_header_t *header, packet_t packet)1058 tcp_socket_data_t *socket_data, tcp_header_t *header, packet_t *packet) 1059 1059 { 1060 1060 socket_core_t *listening_socket; … … 1090 1090 /* Notify the destination socket */ 1091 1091 async_msg_5(socket->phone, NET_SOCKET_ACCEPTED, 1092 ( ipcarg_t) listening_socket->socket_id,1092 (sysarg_t) listening_socket->socket_id, 1093 1093 socket_data->data_fragment_size, TCP_HEADER_SIZE, 1094 0, ( ipcarg_t) socket->socket_id);1094 0, (sysarg_t) socket->socket_id); 1095 1095 1096 1096 fibril_rwlock_write_unlock(socket_data->local_lock); … … 1127 1127 size_t number; 1128 1128 size_t length; 1129 packet_t packet;1130 packet_t next;1131 packet_t acknowledged = NULL;1129 packet_t *packet; 1130 packet_t *next; 1131 packet_t *acknowledged = NULL; 1132 1132 uint32_t old; 1133 1133 … … 1232 1232 ipc_call_t *answer, int *answer_count) 1233 1233 { 1234 packet_t packet;1234 packet_t *packet; 1235 1235 int rc; 1236 1236 … … 1240 1240 1241 1241 *answer_count = 0; 1242 switch (IPC_GET_ METHOD(*call)) {1242 switch (IPC_GET_IMETHOD(*call)) { 1243 1243 case NET_TL_RECEIVED: 1244 1244 // fibril_rwlock_read_lock(&tcp_globals.lock); … … 1323 1323 1324 1324 /* Process the call */ 1325 switch (IPC_GET_ METHOD(call)) {1325 switch (IPC_GET_IMETHOD(call)) { 1326 1326 case IPC_M_PHONE_HUNGUP: 1327 1327 keep_on_going = false; … … 1365 1365 1366 1366 case NET_SOCKET_BIND: 1367 res = data_receive((void **) &addr, &addrlen); 1367 res = async_data_write_accept((void **) &addr, false, 1368 0, 0, 0, &addrlen); 1368 1369 if (res != EOK) 1369 1370 break; … … 1402 1403 1403 1404 case NET_SOCKET_CONNECT: 1404 res = data_receive((void **) &addr, &addrlen); 1405 res = async_data_write_accept((void **) &addr, false, 1406 0, 0, 0, &addrlen); 1405 1407 if (res != EOK) 1406 1408 break; … … 1453 1455 1454 1456 case NET_SOCKET_SENDTO: 1455 res = data_receive((void **) &addr, &addrlen); 1457 res = async_data_write_accept((void **) &addr, false, 1458 0, 0, 0, &addrlen); 1456 1459 if (res != EOK) 1457 1460 break; … … 1654 1657 socket_data, size_t sequence_number) 1655 1658 { 1656 packet_t packet;1657 packet_t copy;1659 packet_t *packet; 1660 packet_t *copy; 1658 1661 size_t data_length; 1659 1662 … … 1736 1739 { 1737 1740 tcp_socket_data_t *socket_data; 1738 packet_t packet;1741 packet_t *packet; 1739 1742 int rc; 1740 1743 … … 1800 1803 fibril_rwlock_write_unlock(socket_data->local_lock); 1801 1804 1805 socket_data->state = TCP_SOCKET_SYN_SENT; 1806 1802 1807 /* Send the packet */ 1803 1808 printf("connecting %d\n", packet_get_id(packet)); … … 1824 1829 1825 1830 int tcp_queue_prepare_packet(socket_core_t *socket, 1826 tcp_socket_data_t *socket_data, packet_t packet, size_t data_length)1831 tcp_socket_data_t *socket_data, packet_t *packet, size_t data_length) 1827 1832 { 1828 1833 tcp_header_t *header; … … 1855 1860 1856 1861 int tcp_queue_packet(socket_core_t *socket, tcp_socket_data_t *socket_data, 1857 packet_t packet, size_t data_length)1862 packet_t *packet, size_t data_length) 1858 1863 { 1859 1864 int rc; … … 1876 1881 } 1877 1882 1878 packet_t tcp_get_packets_to_send(socket_core_t *socket, tcp_socket_data_t *1883 packet_t *tcp_get_packets_to_send(socket_core_t *socket, tcp_socket_data_t * 1879 1884 socket_data) 1880 1885 { 1881 packet_t packet;1882 packet_t copy;1883 packet_t sending = NULL;1884 packet_t previous = NULL;1886 packet_t *packet; 1887 packet_t *copy; 1888 packet_t *sending = NULL; 1889 packet_t *previous = NULL; 1885 1890 size_t data_length; 1886 1891 int rc; … … 1936 1941 } 1937 1942 1938 packet_t tcp_send_prepare_packet(socket_core_t *socket, tcp_socket_data_t *1939 socket_data, packet_t packet, size_t data_length, size_t sequence_number)1943 packet_t *tcp_send_prepare_packet(socket_core_t *socket, tcp_socket_data_t * 1944 socket_data, packet_t *packet, size_t data_length, size_t sequence_number) 1940 1945 { 1941 1946 tcp_header_t *header; … … 1997 2002 } 1998 2003 1999 packet_t tcp_prepare_copy(socket_core_t *socket, tcp_socket_data_t *2000 socket_data, packet_t packet, size_t data_length, size_t sequence_number)2001 { 2002 packet_t copy;2004 packet_t *tcp_prepare_copy(socket_core_t *socket, tcp_socket_data_t * 2005 socket_data, packet_t *packet, size_t data_length, size_t sequence_number) 2006 { 2007 packet_t *copy; 2003 2008 2004 2009 assert(socket); … … 2015 2020 } 2016 2021 2017 void tcp_send_packets(device_id_t device_id, packet_t packet)2018 { 2019 packet_t next;2022 void tcp_send_packets(device_id_t device_id, packet_t *packet) 2023 { 2024 packet_t *next; 2020 2025 2021 2026 while (packet) { … … 2082 2087 if (!fibril) { 2083 2088 free(operation_timeout); 2084 return EPARTY; /* FIXME: use another EC */ 2085 } 2089 return ENOMEM; 2090 } 2091 2086 2092 // fibril_mutex_lock(&socket_data->operation.mutex); 2087 2093 /* Start the timeout fibril */ … … 2097 2103 tcp_socket_data_t *socket_data; 2098 2104 int packet_id; 2099 packet_t packet;2105 packet_t *packet; 2100 2106 size_t length; 2101 2107 int rc; … … 2155 2161 tcp_socket_data_t *socket_data; 2156 2162 packet_dimension_t *packet_dimension; 2157 packet_t packet;2163 packet_t *packet; 2158 2164 size_t total_length; 2159 2165 tcp_header_t *header; … … 2229 2235 socket_core_t *socket; 2230 2236 tcp_socket_data_t *socket_data; 2231 packet_t packet;2237 packet_t *packet; 2232 2238 int rc; 2233 2239 … … 2293 2299 } 2294 2300 2295 int tcp_create_notification_packet(packet_t * packet, socket_core_t *socket,2301 int tcp_create_notification_packet(packet_t **packet, socket_core_t *socket, 2296 2302 tcp_socket_data_t *socket_data, int synchronize, int finalize) 2297 2303 { … … 2442 2448 * @return The result parameter. 2443 2449 */ 2444 int tcp_release_and_return(packet_t packet, int result)2450 int tcp_release_and_return(packet_t *packet, int result) 2445 2451 { 2446 2452 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); … … 2481 2487 * result. 2482 2488 */ 2483 if ((IPC_GET_ METHOD(call) == IPC_M_PHONE_HUNGUP) ||2489 if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) || 2484 2490 (res == EHANGUP)) 2485 2491 return; -
uspace/srv/net/tl/tcp/tcp.h
r1bfd3d3 r973ef9fc 239 239 * Packets metric is set as their data length. 240 240 */ 241 packet_t incoming;241 packet_t *incoming; 242 242 243 243 /** Outgoing packet queue. … … 249 249 * Packets metric is set as their data length. 250 250 */ 251 packet_t outgoing;251 packet_t *outgoing; 252 252 253 253 /** IP pseudo header. */ -
uspace/srv/net/tl/tcp/tcp_module.c
r1bfd3d3 r973ef9fc 61 61 int tl_module_start_standalone(async_client_conn_t client_connection) 62 62 { 63 ipcarg_t phonehash;63 sysarg_t phonehash; 64 64 int rc; 65 65 … … 75 75 goto out; 76 76 77 rc = REGISTER_ME(SERVICE_TCP, &phonehash);77 rc = ipc_connect_to_me(PHONE_NS, SERVICE_TCP, 0, 0, &phonehash); 78 78 if (rc != EOK) 79 79 goto out; -
uspace/srv/net/tl/udp/udp.c
r1bfd3d3 r973ef9fc 190 190 * @return The result parameter. 191 191 */ 192 static int udp_release_and_return(packet_t packet, int result)192 static int udp_release_and_return(packet_t *packet, int result) 193 193 { 194 194 pq_release_remote(udp_globals.net_phone, packet_get_id(packet)); … … 217 217 * ip_client_process_packet() function. 218 218 */ 219 static int udp_process_packet(device_id_t device_id, packet_t packet,219 static int udp_process_packet(device_id_t device_id, packet_t *packet, 220 220 services_t error) 221 221 { … … 225 225 udp_header_t *header; 226 226 socket_core_t *socket; 227 packet_t next_packet;227 packet_t *next_packet; 228 228 size_t total_length; 229 229 uint32_t checksum; 230 230 int fragments; 231 packet_t tmp_packet;231 packet_t *tmp_packet; 232 232 icmp_type_t type; 233 233 icmp_code_t code; … … 393 393 fibril_rwlock_write_unlock(&udp_globals.lock); 394 394 async_msg_5(socket->phone, NET_SOCKET_RECEIVED, 395 ( ipcarg_t) socket->socket_id, packet_dimension->content, 0, 0,396 ( ipcarg_t) fragments);395 (sysarg_t) socket->socket_id, packet_dimension->content, 0, 0, 396 (sysarg_t) fragments); 397 397 398 398 return EOK; … … 413 413 * udp_process_packet() function. 414 414 */ 415 static int udp_received_msg(device_id_t device_id, packet_t packet,415 static int udp_received_msg(device_id_t device_id, packet_t *packet, 416 416 services_t receiver, services_t error) 417 417 { … … 458 458 { 459 459 socket_core_t *socket; 460 packet_t packet;461 packet_t next_packet;460 packet_t *packet; 461 packet_t *next_packet; 462 462 udp_header_t *header; 463 463 int index; … … 614 614 socket_core_t *socket; 615 615 int packet_id; 616 packet_t packet;616 packet_t *packet; 617 617 udp_header_t *header; 618 618 struct sockaddr *addr; … … 742 742 743 743 /* Process the call */ 744 switch (IPC_GET_ METHOD(call)) {744 switch (IPC_GET_IMETHOD(call)) { 745 745 case IPC_M_PHONE_HUNGUP: 746 746 keep_on_going = false; … … 771 771 772 772 case NET_SOCKET_BIND: 773 res = data_receive((void **) &addr, &addrlen); 773 res = async_data_write_accept((void **) &addr, false, 774 0, 0, 0, &addrlen); 774 775 if (res != EOK) 775 776 break; … … 784 785 785 786 case NET_SOCKET_SENDTO: 786 res = data_receive((void **) &addr, &addrlen); 787 res = async_data_write_accept((void **) &addr, false, 788 0, 0, 0, &addrlen); 787 789 if (res != EOK) 788 790 break; … … 861 863 ipc_call_t *answer, int *answer_count) 862 864 { 863 packet_t packet;865 packet_t *packet; 864 866 int rc; 865 867 866 868 *answer_count = 0; 867 869 868 switch (IPC_GET_ METHOD(*call)) {870 switch (IPC_GET_IMETHOD(*call)) { 869 871 case NET_TL_RECEIVED: 870 872 rc = packet_translate_remote(udp_globals.net_phone, &packet, … … 913 915 * result. 914 916 */ 915 if ((IPC_GET_ METHOD(call) == IPC_M_PHONE_HUNGUP) ||917 if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) || 916 918 (res == EHANGUP)) 917 919 return; -
uspace/srv/net/tl/udp/udp_module.c
r1bfd3d3 r973ef9fc 59 59 int tl_module_start_standalone(async_client_conn_t client_connection) 60 60 { 61 ipcarg_t phonehash;61 sysarg_t phonehash; 62 62 int rc; 63 63 … … 75 75 goto out; 76 76 77 rc = REGISTER_ME(SERVICE_UDP, &phonehash);77 rc = ipc_connect_to_me(PHONE_NS, SERVICE_UDP, 0, 0, &phonehash); 78 78 if (rc != EOK) 79 79 goto out;
Note:
See TracChangeset
for help on using the changeset viewer.
