Changeset b1213b0 in mainline for uspace/srv/net/udp
- Timestamp:
- 2012-04-17T07:13:35Z (14 years ago)
- 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. - Location:
- uspace/srv/net/udp
- Files:
-
- 10 added
- 6 moved
-
Makefile (moved) (moved from uspace/srv/net/tl/udp/Makefile ) (3 diffs)
-
assoc.c (added)
-
assoc.h (moved) (moved from uspace/lib/net/include/ethernet_protocols.h ) (2 diffs)
-
msg.c (added)
-
msg.h (added)
-
pdu.c (added)
-
pdu.h (added)
-
sock.c (added)
-
sock.h (moved) (moved from uspace/lib/c/include/net/icmp_common.h ) (2 diffs)
-
std.h (added)
-
ucall.c (added)
-
ucall.h (moved) (moved from uspace/lib/c/include/net/icmp_api.h ) (2 diffs)
-
udp.c (moved) (moved from uspace/srv/net/tl/udp/udp.h ) (2 diffs)
-
udp_inet.c (added)
-
udp_inet.h (moved) (moved from uspace/lib/net/include/icmp_client.h ) (2 diffs)
-
udp_type.h (added)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/udp/Makefile
rd76a329 rb1213b0 1 1 # 2 # Copyright (c) 2005 Martin Decky 3 # Copyright (c) 2007 Jakub Jermar 2 # Copyright (c) 2012 Jiri Svoboda 4 3 # All rights reserved. 5 4 # … … 28 27 # 29 28 30 USPACE_PREFIX = ../../.. /..29 USPACE_PREFIX = ../../.. 31 30 LIBS = $(LIBNET_PREFIX)/libnet.a 32 31 EXTRA_CFLAGS = -I$(LIBNET_PREFIX)/include … … 34 33 35 34 SOURCES = \ 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 37 42 38 43 include $(USPACE_PREFIX)/Makefile.common -
uspace/srv/net/udp/assoc.h
rd76a329 rb1213b0 1 1 /* 2 * Copyright (c) 20 09 Lukas Mejdrech2 * Copyright (c) 2012 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libnet29 /** @addtogroup udp 30 30 * @{ 31 31 */ 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 37 33 */ 38 34 39 #ifndef LIBNET_ETHERNET_PROTOCOLS_H_40 #define LIBNET_ETHERNET_PROTOCOLS_H_35 #ifndef ASSOC_H 36 #define ASSOC_H 41 37 42 38 #include <sys/types.h> 39 #include "udp_type.h" 43 40 44 /** Ethernet protocol type definition. */ 45 typedef uint16_t eth_type_t; 41 extern udp_assoc_t *udp_assoc_new(udp_sock_t *, udp_sock_t *); 42 extern void udp_assoc_delete(udp_assoc_t *); 43 extern void udp_assoc_add(udp_assoc_t *); 44 extern void udp_assoc_remove(udp_assoc_t *); 45 extern void udp_assoc_addref(udp_assoc_t *); 46 extern void udp_assoc_delref(udp_assoc_t *); 47 extern void udp_assoc_set_foreign(udp_assoc_t *, udp_sock_t *); 48 extern void udp_assoc_set_local(udp_assoc_t *, udp_sock_t *); 49 extern int udp_assoc_send(udp_assoc_t *, udp_sock_t *, udp_msg_t *); 50 extern int udp_assoc_recv(udp_assoc_t *, udp_msg_t **, udp_sock_t *); 51 extern void udp_assoc_received(udp_sockpair_t *, udp_msg_t *); 46 52 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 0x080057 58 /** ARP ethernet protocol type. */59 #define ETH_P_ARP 0x080660 61 /*@}*/62 53 63 54 #endif -
uspace/srv/net/udp/sock.h
rd76a329 rb1213b0 1 1 /* 2 * Copyright (c) 20 09 Lukas Mejdrech2 * Copyright (c) 2012 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libc 30 * @{ 29 /** @addtogroup udp 30 * @{ 31 */ 32 /** @file Socket provider 31 33 */ 32 34 33 /** @file 34 * ICMP module common interface. 35 */ 35 #ifndef SOCK_H 36 #define SOCK_H 36 37 37 #ifndef LIBC_ICMP_COMMON_H_38 #define LIBC_ICMP_COMMON_H_39 40 #include <ipc/services.h>41 #include <sys/time.h>42 38 #include <async.h> 43 39 44 extern async_sess_t *icmp_connect_module(void);40 extern int udp_sock_init(void); 45 41 46 42 #endif -
uspace/srv/net/udp/ucall.h
rd76a329 rb1213b0 1 1 /* 2 * Copyright (c) 20 09 Lukas Mejdrech2 * Copyright (c) 2012 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libc29 /** @addtogroup udp 30 30 * @{ 31 31 */ 32 33 /** @file 34 * ICMP module application interface. 32 /** @file UDP user calls 35 33 */ 36 34 37 #ifndef LIBC_ICMP_API_H_38 #define LIBC_ICMP_API_H_35 #ifndef UCALL_H 36 #define UCALL_H 39 37 40 #include <net/socket_codes.h>41 #include <net/inet.h>42 38 #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" 49 40 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 /*@}*/ 41 extern udp_error_t udp_uc_create(udp_assoc_t **); 42 extern udp_error_t udp_uc_set_foreign(udp_assoc_t *, udp_sock_t *); 43 extern udp_error_t udp_uc_set_local(udp_assoc_t *, udp_sock_t *); 44 extern udp_error_t udp_uc_send(udp_assoc_t *, udp_sock_t *, void *, size_t, 45 xflags_t); 46 extern udp_error_t udp_uc_receive(udp_assoc_t *, void *, size_t, size_t *, 47 xflags_t *, udp_sock_t *); 48 extern void udp_uc_status(udp_assoc_t *, udp_assoc_status_t *); 49 extern void udp_uc_destroy(udp_assoc_t *); 59 50 60 51 #endif -
uspace/srv/net/udp/udp.c
rd76a329 rb1213b0 1 1 /* 2 * Copyright (c) 20 08 Lukas Mejdrech2 * Copyright (c) 2012 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 31 31 */ 32 32 33 /** @file34 * UDP module.33 /** 34 * @file UDP (User Datagram Protocol) service 35 35 */ 36 36 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> 39 42 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" 44 45 45 /** Type definition of the UDP global data. 46 * @see udp_globals 46 #define NAME "udp" 47 48 static 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 69 int 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 * @} 47 95 */ 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 #endif75 76 /** @}77 */ -
uspace/srv/net/udp/udp_inet.h
rd76a329 rb1213b0 1 1 /* 2 * Copyright (c) 20 09 Lukas Mejdrech2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libnet29 /** @addtogroup udp 30 30 * @{ 31 31 */ 32 33 32 /** @file 34 * ICMP client interface.35 33 */ 36 34 37 #ifndef LIBNET_ICMP_CLIENT_H_38 #define LIBNET_ICMP_CLIENT_H_35 #ifndef UDP_INET_H 36 #define UDP_INET_H 39 37 40 #include <net/icmp_codes.h> 41 #include <net/packet.h> 38 #include "udp_type.h" 42 39 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 *); 40 extern int udp_inet_init(void); 41 extern int udp_transmit_pdu(udp_pdu_t *); 46 42 47 43 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
