Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset c6533a7 in mainline


Ignore:
Timestamp:
2012-01-30T21:51:13Z (8 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
c8916d15
Parents:
4d9fe7b
Message:

Remove most of net-related code from libnet and libc, except parts which are
presumably needed to implement sockets. Socket implementation will be replaced
later. NIC drivers should not include/link libnet.

Location:
uspace
Files:
56 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • uspace/Makefile

    r4d9fe7b rc6533a7  
    6565        app/nettest2 \
    6666        app/nettest3 \
    67         app/ping \
    6867        app/websrv \
    6968        app/sysinfo \
  • uspace/app/netecho/print_error.c

    r4d9fe7b rc6533a7  
    4040#include <errno.h>
    4141
    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 
    10442/** Prints the error description.
    10543 *
    106  * Supports ICMP and socket error codes.
     44 * Supports socket error codes.
    10745 *
    10846 * @param[in] output The description output stream. May be NULL.
     
    11351void print_error(FILE *output, int error_code, const char *prefix, const char *suffix)
    11452{
    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))
    11854                socket_print_error(output, error_code, prefix, suffix);
    11955}
  • uspace/drv/nic/e1k/Makefile

    r4d9fe7b rc6533a7  
    2828
    2929USPACE_PREFIX = ../../..
    30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBNET_PREFIX)/libnet.a $(LIBNIC_PREFIX)/libnic.a
    31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBNET_PREFIX)/include -I$(LIBNIC_PREFIX)/include
     30LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBNIC_PREFIX)/libnic.a
     31EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBNIC_PREFIX)/include
    3232BINARY = e1k
    3333
  • uspace/drv/nic/e1k/e1k.c

    r4d9fe7b rc6533a7  
    5050#include <device/pci.h>
    5151#include <nic.h>
    52 #include <nil_remote.h>
    5352#include <ops/nic.h>
    5453#include "e1k.h"
  • uspace/drv/nic/lo/Makefile

    r4d9fe7b rc6533a7  
    2828
    2929USPACE_PREFIX = ../../..
    30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBNET_PREFIX)/libnet.a $(LIBNIC_PREFIX)/libnic.a
    31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBNET_PREFIX)/include -I$(LIBNIC_PREFIX)/include
     30LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBNIC_PREFIX)/libnic.a
     31EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBNIC_PREFIX)/include
    3232BINARY = lo
    3333
  • uspace/drv/nic/ne2k/Makefile

    r4d9fe7b rc6533a7  
    2828
    2929USPACE_PREFIX = ../../..
    30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBNET_PREFIX)/libnet.a $(LIBNIC_PREFIX)/libnic.a
    31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBNET_PREFIX)/include -I$(LIBNIC_PREFIX)/include
     30LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBNIC_PREFIX)/libnic.a
     31EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBNIC_PREFIX)/include
    3232BINARY = ne2k
    3333
  • uspace/drv/nic/rtl8139/Makefile

    r4d9fe7b rc6533a7  
    2828
    2929USPACE_PREFIX = ../../..
    30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBNET_PREFIX)/libnet.a $(LIBNIC_PREFIX)/libnic.a
    31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBNET_PREFIX)/include -I$(LIBNIC_PREFIX)/include
     30LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBNIC_PREFIX)/libnic.a
     31EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBNIC_PREFIX)/include
    3232BINARY = rtl8139
    3333
  • uspace/drv/nic/rtl8139/driver.c

    r4d9fe7b rc6533a7  
    4444#include <sysinfo.h>
    4545#include <ipc/ns.h>
    46 
    47 #include <net_checksum.h>
    4846
    4947#include <str.h>
  • uspace/lib/c/Makefile

    r4d9fe7b rc6533a7  
    118118        generic/vfs/canonify.c \
    119119        generic/net/inet.c \
    120         generic/net/icmp_common.c \
    121         generic/net/icmp_api.c \
    122120        generic/net/modules.c \
    123         generic/net/packet.c \
    124121        generic/net/socket_client.c \
    125122        generic/net/socket_parse.c \
  • uspace/lib/c/include/ipc/net.h

    r4d9fe7b rc6533a7  
    4040#include <ipc/services.h>
    4141#include <net/device.h>
    42 #include <net/packet.h>
    4342
    4443/** Return a value indicating whether the value is in the interval.
  • uspace/lib/net/Makefile

    r4d9fe7b rc6533a7  
    3333
    3434SOURCES = \
    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
    5536
    5637include $(USPACE_PREFIX)/Makefile.common
  • uspace/lib/net/include/socket_core.h

    r4d9fe7b rc6533a7  
    4444#include <net/in.h>
    4545#include <net/device.h>
    46 #include <net/packet.h>
    4746#include <async.h>
    4847
     
    8079        /** Bound port. */
    8180        int port;
    82         /** Received packets queue. */
    83         dyn_fifo_t received;
    8481        /** Sockets for acceptance queue. */
    8582        dyn_fifo_t accepted;
     
    118115extern int socket_destroy(async_sess_t *, int, socket_cores_t *,
    119116    socket_ports_t *, void (*)(socket_core_t *));
    120 extern int socket_reply_packets(packet_t *, size_t *);
    121117extern socket_core_t *socket_port_find(socket_ports_t *, int, const uint8_t *,
    122118    size_t);
  • uspace/lib/net/tl/socket_core.c

    r4d9fe7b rc6533a7  
    3636
    3737#include <socket_core.h>
    38 #include <packet_client.h>
    39 #include <packet_remote.h>
    4038#include <net/socket_codes.h>
    4139#include <net/in.h>
    4240#include <net/inet.h>
    43 #include <net/packet.h>
    4441#include <net/modules.h>
    4542#include <stdint.h>
     
    9289        }
    9390       
    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);
    10091        dyn_fifo_destroy(&socket->accepted);
    10192       
     
    448439        socket->key_length = 0;
    449440        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);
    451443        if (rc != EOK) {
    452444                free(socket);
    453445                return rc;
    454446        }
    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         }
    462447        socket->socket_id = *socket_id;
    463448        rc = socket_cores_add(local_sockets, socket->socket_id, socket);
    464449        if (rc < 0) {
    465                 dyn_fifo_destroy(&socket->received);
    466450                dyn_fifo_destroy(&socket->accepted);
    467451                free(socket);
     
    506490        socket_destroy_core(sess, socket, local_sockets, global_sockets,
    507491            socket_release);
    508        
    509         return EOK;
    510 }
    511 
    512 /** Replies the packet or the packet queue data to the application via the
    513  * 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         }
    591492       
    592493        return EOK;
Note: See TracChangeset for help on using the changeset viewer.