Changeset c6533a7 in mainline
- Timestamp:
- 2012-01-30T21:51:13Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c8916d15
- Parents:
- 4d9fe7b
- Location:
- uspace
- Files:
-
- 56 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/Makefile
r4d9fe7b rc6533a7 65 65 app/nettest2 \ 66 66 app/nettest3 \ 67 app/ping \68 67 app/websrv \ 69 68 app/sysinfo \ -
uspace/app/netecho/print_error.c
r4d9fe7b rc6533a7 40 40 #include <errno.h> 41 41 42 #include <net/icmp_codes.h>43 44 /** Prints the specific ICMP error description.45 *46 * @param[in] output The description output stream. May be NULL.47 * @param[in] error_code The ICMP error code.48 * @param[in] prefix The error description prefix. May be NULL.49 * @param[in] suffix The error description suffix. May be NULL.50 */51 void icmp_print_error(FILE *output, int error_code, const char *prefix, const char *suffix)52 {53 if (!output)54 return;55 56 if (prefix)57 fprintf(output, "%s", prefix);58 59 switch (error_code) {60 case ICMP_DEST_UNREACH:61 fprintf(output, "ICMP Destination Unreachable (%d) error", error_code);62 break;63 case ICMP_SOURCE_QUENCH:64 fprintf(output, "ICMP Source Quench (%d) error", error_code);65 break;66 case ICMP_REDIRECT:67 fprintf(output, "ICMP Redirect (%d) error", error_code);68 break;69 case ICMP_ALTERNATE_ADDR:70 fprintf(output, "ICMP Alternate Host Address (%d) error", error_code);71 break;72 case ICMP_ROUTER_ADV:73 fprintf(output, "ICMP Router Advertisement (%d) error", error_code);74 break;75 case ICMP_ROUTER_SOL:76 fprintf(output, "ICMP Router Solicitation (%d) error", error_code);77 break;78 case ICMP_TIME_EXCEEDED:79 fprintf(output, "ICMP Time Exceeded (%d) error", error_code);80 break;81 case ICMP_PARAMETERPROB:82 fprintf(output, "ICMP Paramenter Problem (%d) error", error_code);83 break;84 case ICMP_CONVERSION_ERROR:85 fprintf(output, "ICMP Datagram Conversion Error (%d) error", error_code);86 break;87 case ICMP_REDIRECT_MOBILE:88 fprintf(output, "ICMP Mobile Host Redirect (%d) error", error_code);89 break;90 case ICMP_SKIP:91 fprintf(output, "ICMP SKIP (%d) error", error_code);92 break;93 case ICMP_PHOTURIS:94 fprintf(output, "ICMP Photuris (%d) error", error_code);95 break;96 default:97 fprintf(output, "Other (%d) error", error_code);98 }99 100 if (suffix)101 fprintf(output, "%s", suffix);102 }103 104 42 /** Prints the error description. 105 43 * 106 * Supports ICMP andsocket error codes.44 * Supports socket error codes. 107 45 * 108 46 * @param[in] output The description output stream. May be NULL. … … 113 51 void print_error(FILE *output, int error_code, const char *prefix, const char *suffix) 114 52 { 115 if (IS_ICMP_ERROR(error_code)) 116 icmp_print_error(output, error_code, prefix, suffix); 117 else if(IS_SOCKET_ERROR(error_code)) 53 if(IS_SOCKET_ERROR(error_code)) 118 54 socket_print_error(output, error_code, prefix, suffix); 119 55 } -
uspace/drv/nic/e1k/Makefile
r4d9fe7b rc6533a7 28 28 29 29 USPACE_PREFIX = ../../.. 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBN ET_PREFIX)/libnet.a $(LIBNIC_PREFIX)/libnic.a31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBN ET_PREFIX)/include -I$(LIBNIC_PREFIX)/include30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBNIC_PREFIX)/libnic.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBNIC_PREFIX)/include 32 32 BINARY = e1k 33 33 -
uspace/drv/nic/e1k/e1k.c
r4d9fe7b rc6533a7 50 50 #include <device/pci.h> 51 51 #include <nic.h> 52 #include <nil_remote.h>53 52 #include <ops/nic.h> 54 53 #include "e1k.h" -
uspace/drv/nic/lo/Makefile
r4d9fe7b rc6533a7 28 28 29 29 USPACE_PREFIX = ../../.. 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBN ET_PREFIX)/libnet.a $(LIBNIC_PREFIX)/libnic.a31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBN ET_PREFIX)/include -I$(LIBNIC_PREFIX)/include30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBNIC_PREFIX)/libnic.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBNIC_PREFIX)/include 32 32 BINARY = lo 33 33 -
uspace/drv/nic/ne2k/Makefile
r4d9fe7b rc6533a7 28 28 29 29 USPACE_PREFIX = ../../.. 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBN ET_PREFIX)/libnet.a $(LIBNIC_PREFIX)/libnic.a31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBN ET_PREFIX)/include -I$(LIBNIC_PREFIX)/include30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBNIC_PREFIX)/libnic.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBNIC_PREFIX)/include 32 32 BINARY = ne2k 33 33 -
uspace/drv/nic/rtl8139/Makefile
r4d9fe7b rc6533a7 28 28 29 29 USPACE_PREFIX = ../../.. 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBN ET_PREFIX)/libnet.a $(LIBNIC_PREFIX)/libnic.a31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBN ET_PREFIX)/include -I$(LIBNIC_PREFIX)/include30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBNIC_PREFIX)/libnic.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBNIC_PREFIX)/include 32 32 BINARY = rtl8139 33 33 -
uspace/drv/nic/rtl8139/driver.c
r4d9fe7b rc6533a7 44 44 #include <sysinfo.h> 45 45 #include <ipc/ns.h> 46 47 #include <net_checksum.h>48 46 49 47 #include <str.h> -
uspace/lib/c/Makefile
r4d9fe7b rc6533a7 118 118 generic/vfs/canonify.c \ 119 119 generic/net/inet.c \ 120 generic/net/icmp_common.c \121 generic/net/icmp_api.c \122 120 generic/net/modules.c \ 123 generic/net/packet.c \124 121 generic/net/socket_client.c \ 125 122 generic/net/socket_parse.c \ -
uspace/lib/c/include/ipc/net.h
r4d9fe7b rc6533a7 40 40 #include <ipc/services.h> 41 41 #include <net/device.h> 42 #include <net/packet.h>43 42 44 43 /** Return a value indicating whether the value is in the interval. -
uspace/lib/net/Makefile
r4d9fe7b rc6533a7 33 33 34 34 SOURCES = \ 35 generic/generic.c \ 36 generic/net_remote.c \ 37 generic/net_checksum.c \ 38 generic/packet_client.c \ 39 generic/packet_remote.c \ 40 generic/protocol_map.c \ 41 adt/module_map.c \ 42 nil/nil_remote.c \ 43 nil/nil_skel.c \ 44 il/il_remote.c \ 45 il/il_skel.c \ 46 il/ip_remote.c \ 47 il/ip_client.c \ 48 il/arp_remote.c \ 49 tl/icmp_remote.c \ 50 tl/icmp_client.c \ 51 tl/socket_core.c \ 52 tl/tl_common.c \ 53 tl/tl_remote.c \ 54 tl/tl_skel.c 35 tl/socket_core.c 55 36 56 37 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/net/include/socket_core.h
r4d9fe7b rc6533a7 44 44 #include <net/in.h> 45 45 #include <net/device.h> 46 #include <net/packet.h>47 46 #include <async.h> 48 47 … … 80 79 /** Bound port. */ 81 80 int port; 82 /** Received packets queue. */83 dyn_fifo_t received;84 81 /** Sockets for acceptance queue. */ 85 82 dyn_fifo_t accepted; … … 118 115 extern int socket_destroy(async_sess_t *, int, socket_cores_t *, 119 116 socket_ports_t *, void (*)(socket_core_t *)); 120 extern int socket_reply_packets(packet_t *, size_t *);121 117 extern socket_core_t *socket_port_find(socket_ports_t *, int, const uint8_t *, 122 118 size_t); -
uspace/lib/net/tl/socket_core.c
r4d9fe7b rc6533a7 36 36 37 37 #include <socket_core.h> 38 #include <packet_client.h>39 #include <packet_remote.h>40 38 #include <net/socket_codes.h> 41 39 #include <net/in.h> 42 40 #include <net/inet.h> 43 #include <net/packet.h>44 41 #include <net/modules.h> 45 42 #include <stdint.h> … … 92 89 } 93 90 94 /* Release all received packets */95 int packet_id;96 while ((packet_id = dyn_fifo_pop(&socket->received)) >= 0)97 pq_release_remote(sess, packet_id);98 99 dyn_fifo_destroy(&socket->received);100 91 dyn_fifo_destroy(&socket->accepted); 101 92 … … 448 439 socket->key_length = 0; 449 440 socket->specific_data = specific_data; 450 rc = dyn_fifo_initialize(&socket->received, SOCKET_INITIAL_RECEIVED_SIZE); 441 442 rc = dyn_fifo_initialize(&socket->accepted, SOCKET_INITIAL_ACCEPTED_SIZE); 451 443 if (rc != EOK) { 452 444 free(socket); 453 445 return rc; 454 446 } 455 456 rc = dyn_fifo_initialize(&socket->accepted, SOCKET_INITIAL_ACCEPTED_SIZE);457 if (rc != EOK) {458 dyn_fifo_destroy(&socket->received);459 free(socket);460 return rc;461 }462 447 socket->socket_id = *socket_id; 463 448 rc = socket_cores_add(local_sockets, socket->socket_id, socket); 464 449 if (rc < 0) { 465 dyn_fifo_destroy(&socket->received);466 450 dyn_fifo_destroy(&socket->accepted); 467 451 free(socket); … … 506 490 socket_destroy_core(sess, socket, local_sockets, global_sockets, 507 491 socket_release); 508 509 return EOK;510 }511 512 /** Replies the packet or the packet queue data to the application via the513 * socket.514 *515 * Uses the current message processing fibril.516 *517 * @param[in] packet The packet to be transfered.518 * @param[out] length The total data length.519 * @return EOK on success.520 * @return EBADMEM if the length parameter is NULL.521 * @return ENOMEM if there is not enough memory left.522 * @return Other error codes as defined for the data_reply()523 * function.524 */525 int socket_reply_packets(packet_t *packet, size_t *length)526 {527 packet_t *next_packet;528 size_t fragments;529 size_t *lengths;530 size_t index;531 int rc;532 533 if (!length)534 return EBADMEM;535 536 next_packet = pq_next(packet);537 if (!next_packet) {538 /* Write all if only one fragment */539 rc = data_reply(packet_get_data(packet),540 packet_get_data_length(packet));541 if (rc != EOK)542 return rc;543 /* Store the total length */544 *length = packet_get_data_length(packet);545 } else {546 /* Count the packet fragments */547 fragments = 1;548 next_packet = pq_next(packet);549 while ((next_packet = pq_next(next_packet)))550 ++fragments;551 552 /* Compute and store the fragment lengths */553 lengths = (size_t *) malloc(sizeof(size_t) * fragments +554 sizeof(size_t));555 if (!lengths)556 return ENOMEM;557 558 lengths[0] = packet_get_data_length(packet);559 lengths[fragments] = lengths[0];560 next_packet = pq_next(packet);561 562 for (index = 1; index < fragments; ++index) {563 lengths[index] = packet_get_data_length(next_packet);564 lengths[fragments] += lengths[index];565 next_packet = pq_next(packet);566 }567 568 /* Write the fragment lengths */569 rc = data_reply(lengths, sizeof(int) * (fragments + 1));570 if (rc != EOK) {571 free(lengths);572 return rc;573 }574 next_packet = packet;575 576 /* Write the fragments */577 for (index = 0; index < fragments; ++index) {578 rc = data_reply(packet_get_data(next_packet),579 lengths[index]);580 if (rc != EOK) {581 free(lengths);582 return rc;583 }584 next_packet = pq_next(next_packet);585 }586 587 /* Store the total length */588 *length = lengths[fragments];589 free(lengths);590 }591 492 592 493 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.