Changeset b1213b0 in mainline for uspace/srv/net/udp


Ignore:
Timestamp:
2012-04-17T07:13:35Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
96c0b7b
Parents:
d76a329 (diff), 06a1d077 (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.
Message:

Merge internet stack rewrite (IP+ICMP, UDP, IP over Ethernet).

Location:
uspace/srv/net/udp
Files:
10 added
6 moved

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/udp/Makefile

    rd76a329 rb1213b0  
    11#
    2 # Copyright (c) 2005 Martin Decky
    3 # Copyright (c) 2007 Jakub Jermar
     2# Copyright (c) 2012 Jiri Svoboda
    43# All rights reserved.
    54#
     
    2827#
    2928
    30 USPACE_PREFIX = ../../../..
     29USPACE_PREFIX = ../../..
    3130LIBS = $(LIBNET_PREFIX)/libnet.a
    3231EXTRA_CFLAGS = -I$(LIBNET_PREFIX)/include
     
    3433
    3534SOURCES = \
    36         udp.c
     35        assoc.c \
     36        msg.c \
     37        sock.c \
     38        pdu.c \
     39        ucall.c \
     40        udp.c \
     41        udp_inet.c
    3742
    3843include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/net/udp/assoc.h

    rd76a329 rb1213b0  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2012 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libnet
     29/** @addtogroup udp
    3030 * @{
    3131 */
    32 
    33 /** @file
    34  * Ethernet protocol numbers according to the on-line IANA - Ethernet numbers
    35  * http://www.iana.org/assignments/ethernet-numbers
    36  * cited January 17 2009.
     32/** @file UDP associations
    3733 */
    3834
    39 #ifndef LIBNET_ETHERNET_PROTOCOLS_H_
    40 #define LIBNET_ETHERNET_PROTOCOLS_H_
     35#ifndef ASSOC_H
     36#define ASSOC_H
    4137
    4238#include <sys/types.h>
     39#include "udp_type.h"
    4340
    44 /** Ethernet protocol type definition. */
    45 typedef uint16_t eth_type_t;
     41extern udp_assoc_t *udp_assoc_new(udp_sock_t *, udp_sock_t *);
     42extern void udp_assoc_delete(udp_assoc_t *);
     43extern void udp_assoc_add(udp_assoc_t *);
     44extern void udp_assoc_remove(udp_assoc_t *);
     45extern void udp_assoc_addref(udp_assoc_t *);
     46extern void udp_assoc_delref(udp_assoc_t *);
     47extern void udp_assoc_set_foreign(udp_assoc_t *, udp_sock_t *);
     48extern void udp_assoc_set_local(udp_assoc_t *, udp_sock_t *);
     49extern int udp_assoc_send(udp_assoc_t *, udp_sock_t *, udp_msg_t *);
     50extern int udp_assoc_recv(udp_assoc_t *, udp_msg_t **, udp_sock_t *);
     51extern void udp_assoc_received(udp_sockpair_t *, udp_msg_t *);
    4652
    47 /** @name Ethernet protocols definitions */
    48 /*@{*/
    49 
    50 /** Ethernet minimal protocol number.
    51  * According to the IEEE 802.3 specification.
    52  */
    53 #define ETH_MIN_PROTO           0x0600 /* 1536 */
    54 
    55 /** Internet IP (IPv4) ethernet protocol type. */
    56 #define ETH_P_IP                0x0800
    57 
    58 /** ARP ethernet protocol type. */
    59 #define ETH_P_ARP               0x0806
    60 
    61 /*@}*/
    6253
    6354#endif
  • uspace/srv/net/udp/sock.h

    rd76a329 rb1213b0  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2012 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libc
    30  *  @{
     29/** @addtogroup udp
     30 * @{
     31 */
     32/** @file Socket provider
    3133 */
    3234
    33 /** @file
    34  * ICMP module common interface.
    35  */
     35#ifndef SOCK_H
     36#define SOCK_H
    3637
    37 #ifndef LIBC_ICMP_COMMON_H_
    38 #define LIBC_ICMP_COMMON_H_
    39 
    40 #include <ipc/services.h>
    41 #include <sys/time.h>
    4238#include <async.h>
    4339
    44 extern async_sess_t *icmp_connect_module(void);
     40extern int udp_sock_init(void);
    4541
    4642#endif
  • uspace/srv/net/udp/ucall.h

    rd76a329 rb1213b0  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2012 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libc
     29/** @addtogroup udp
    3030 * @{
    3131 */
    32 
    33 /** @file
    34  * ICMP module application interface.
     32/** @file UDP user calls
    3533 */
    3634
    37 #ifndef LIBC_ICMP_API_H_
    38 #define LIBC_ICMP_API_H_
     35#ifndef UCALL_H
     36#define UCALL_H
    3937
    40 #include <net/socket_codes.h>
    41 #include <net/inet.h>
    4238#include <sys/types.h>
    43 #include <sys/time.h>
    44 #include <adt/measured_strings.h>
    45 #include <net/ip_codes.h>
    46 #include <net/icmp_codes.h>
    47 #include <net/icmp_common.h>
    48 #include <async.h>
     39#include "udp_type.h"
    4940
    50 /** @name ICMP module application interface
    51  * This interface is used by other application modules.
    52  */
    53 /*@{*/
    54 
    55 extern int icmp_echo_msg(async_sess_t *, size_t, mseconds_t, ip_ttl_t, ip_tos_t,
    56     int, const struct sockaddr *, socklen_t);
    57 
    58 /*@}*/
     41extern udp_error_t udp_uc_create(udp_assoc_t **);
     42extern udp_error_t udp_uc_set_foreign(udp_assoc_t *, udp_sock_t *);
     43extern udp_error_t udp_uc_set_local(udp_assoc_t *, udp_sock_t *);
     44extern udp_error_t udp_uc_send(udp_assoc_t *, udp_sock_t *, void *, size_t,
     45    xflags_t);
     46extern udp_error_t udp_uc_receive(udp_assoc_t *, void *, size_t, size_t *,
     47    xflags_t *, udp_sock_t *);
     48extern void udp_uc_status(udp_assoc_t *, udp_assoc_status_t *);
     49extern void udp_uc_destroy(udp_assoc_t *);
    5950
    6051#endif
  • uspace/srv/net/udp/udp.c

    rd76a329 rb1213b0  
    11/*
    2  * Copyright (c) 2008 Lukas Mejdrech
     2 * Copyright (c) 2012 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3131 */
    3232
    33 /** @file
    34  * UDP module.
     33/**
     34 * @file UDP (User Datagram Protocol) service
    3535 */
    3636
    37 #ifndef NET_UDP_H_
    38 #define NET_UDP_H_
     37#include <async.h>
     38#include <errno.h>
     39#include <io/log.h>
     40#include <stdio.h>
     41#include <task.h>
    3942
    40 #include <async.h>
    41 #include <fibril_synch.h>
    42 #include <socket_core.h>
    43 #include <tl_common.h>
     43#include "udp_inet.h"
     44#include "sock.h"
    4445
    45 /** Type definition of the UDP global data.
    46  * @see udp_globals
     46#define NAME       "udp"
     47
     48static int udp_init(void)
     49{
     50        int rc;
     51
     52        log_msg(LVL_DEBUG, "udp_init()");
     53
     54        rc = udp_inet_init();
     55        if (rc != EOK) {
     56                log_msg(LVL_ERROR, "Failed connecting to internet service.");
     57                return ENOENT;
     58        }
     59
     60        rc = udp_sock_init();
     61        if (rc != EOK) {
     62                log_msg(LVL_ERROR, "Failed initializing socket service.");
     63                return ENOENT;
     64        }
     65
     66        return EOK;
     67}
     68
     69int main(int argc, char **argv)
     70{
     71        int rc;
     72
     73        printf(NAME ": UDP (User Datagram Protocol) service\n");
     74
     75        rc = log_init(NAME, LVL_WARN);
     76        if (rc != EOK) {
     77                printf(NAME ": Failed to initialize log.\n");
     78                return 1;
     79        }
     80
     81        rc = udp_init();
     82        if (rc != EOK)
     83                return 1;
     84
     85        printf(NAME ": Accepting connections.\n");
     86        task_retval(0);
     87        async_manager();
     88
     89        /* Not reached */
     90        return 0;
     91}
     92
     93/**
     94 * @}
    4795 */
    48 typedef struct udp_globals udp_globals_t;
    49 
    50 /** UDP global data. */
    51 struct udp_globals {
    52         /** Networking module session. */
    53         async_sess_t *net_sess;
    54         /** IP module session. */
    55         async_sess_t *ip_sess;
    56         /** ICMP module session. */
    57         async_sess_t *icmp_sess;
    58         /** Packet dimension. */
    59         packet_dimension_t packet_dimension;
    60         /** Indicates whether UDP checksum computing is enabled. */
    61         int checksum_computing;
    62         /** Indicates whether UDP autobnding on send is enabled. */
    63         int autobinding;
    64         /** Last used free port. */
    65         int last_used_port;
    66         /** Active sockets. */
    67         socket_ports_t sockets;
    68         /** Device packet dimensions. */
    69         packet_dimensions_t dimensions;
    70         /** Safety lock. */
    71         fibril_rwlock_t lock;
    72 };
    73 
    74 #endif
    75 
    76 /** @}
    77  */
  • uspace/srv/net/udp/udp_inet.h

    rd76a329 rb1213b0  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libnet
     29/** @addtogroup udp
    3030 * @{
    3131 */
    32 
    3332/** @file
    34  * ICMP client interface.
    3533 */
    3634
    37 #ifndef LIBNET_ICMP_CLIENT_H_
    38 #define LIBNET_ICMP_CLIENT_H_
     35#ifndef UDP_INET_H
     36#define UDP_INET_H
    3937
    40 #include <net/icmp_codes.h>
    41 #include <net/packet.h>
     38#include "udp_type.h"
    4239
    43 extern int icmp_client_process_packet(packet_t *, icmp_type_t *, icmp_code_t *,
    44     icmp_param_t *, icmp_param_t *);
    45 extern size_t icmp_client_header_length(packet_t *);
     40extern int udp_inet_init(void);
     41extern int udp_transmit_pdu(udp_pdu_t *);
    4642
    4743#endif
Note: See TracChangeset for help on using the changeset viewer.