This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 9/9] Phoenix-RTOS: Adjust network-related headers to new kernel API.


From: Kuba Sejdak <jakub.sejdak@phoesys.com>

---
 newlib/libc/sys/phoenix/include/arpa/inet.h    |  1 +
 newlib/libc/sys/phoenix/include/net/if.h       | 58 +-------------------------
 newlib/libc/sys/phoenix/include/netinet/in.h   | 40 ++----------------
 newlib/libc/sys/phoenix/include/netinet6/in6.h | 23 +---------
 newlib/libc/sys/phoenix/net/inet_aton.c        |  1 +
 newlib/libc/sys/phoenix/socket.c               |  1 +
 newlib/libc/sys/phoenix/sockopt.c              |  6 ++-
 newlib/libc/sys/phoenix/sys/socket.h           |  7 ++++
 8 files changed, 20 insertions(+), 117 deletions(-)

diff --git a/newlib/libc/sys/phoenix/include/arpa/inet.h b/newlib/libc/sys/phoenix/include/arpa/inet.h
index aca1920..8b76fc0 100644
--- a/newlib/libc/sys/phoenix/include/arpa/inet.h
+++ b/newlib/libc/sys/phoenix/include/arpa/inet.h
@@ -26,6 +26,7 @@
 #define	_ARPA_INET_H
 
 #include <netinet/in.h>
+#include <phoenix/socket.h>
 #include <stdint.h>
 
 #define	INET_ADDRSTRLEN		16
diff --git a/newlib/libc/sys/phoenix/include/net/if.h b/newlib/libc/sys/phoenix/include/net/if.h
index ad089f3..516af21 100644
--- a/newlib/libc/sys/phoenix/include/net/if.h
+++ b/newlib/libc/sys/phoenix/include/net/if.h
@@ -37,6 +37,7 @@
 #ifndef _NET_IF_H
 #define	_NET_IF_H
 
+#include <phoenix/iface.h>
 #include <sys/queue.h>
 #include <sys/socket.h>
 #include <sys/time.h>
@@ -106,24 +107,6 @@ struct if_data {
 	struct timeval ifi_lastchange;		/* Time of last administrative change */
 };
 
-#define	IFF_UP				0x1			/* Interface is up */
-#define	IFF_BROADCAST		0x2			/* Broadcast address valid */
-#define	IFF_DEBUG			0x4			/* Turn on debugging */
-#define	IFF_LOOPBACK		0x8			/* Is a loopback net */
-#define	IFF_POINTOPOINT		0x10		/* Interface is point-to-point link */
-#define	IFF_NOTRAILERS		0x20		/* Avoid use of trailers */
-#define	IFF_RUNNING			0x40		/* Resources allocated */
-#define	IFF_NOARP			0x80		/* No address resolution protocol */
-#define	IFF_PROMISC			0x100		/* Receive all packets */
-#define	IFF_ALLMULTI		0x200		/* Receive all multicast packets */
-#define	IFF_OACTIVE			0x400		/* Transmission in progress */
-#define	IFF_SIMPLEX			0x800		/* Can't hear own transmissions */
-#define	IFF_LINK0			0x1000		/* Per link layer defined bit */
-#define	IFF_LINK1			0x2000		/* Per link layer defined bit */
-#define	IFF_LINK2			0x4000		/* Per link layer defined bit */
-#define	IFF_ALTPHYS			IFF_LINK2	/* Use alternate physical connection */
-#define	IFF_MULTICAST		0x8000		/* Supports multicast */
-
 /*
  * The following flag(s) ought to go in if_flags, but we cannot change
  * struct ifnet because of binary compatibility, so we store them in
@@ -191,45 +174,6 @@ struct if_announcemsghdr {
 #define	IFAN_ARRIVAL		0		/* Interface arrival */
 #define	IFAN_DEPARTURE		1		/* Interface departure */
 
-/*
- * Interface request structure used for socket
- * ioctl's.  All interface ioctl's must have parameter
- * definitions which begin with ifr_name.  The
- * remainder may be interface specific.
- */
-struct ifreq {
-	char ifr_name[IFNAMSIZ];		/* if name, e.g. "en0" */
-	union {
-		struct sockaddr ifru_addr;
-		struct sockaddr ifru_dstaddr;
-		struct sockaddr ifru_broadaddr;
-		struct sockaddr ifru_netmask;
-		short ifru_flags[2];
-		short ifru_index;
-		int	ifru_metric;
-		int	ifru_mtu;
-		int	ifru_phys;
-		int	ifru_media;
-		caddr_t	ifru_data;
-		int	ifru_cap[2];
-	} ifr_ifru;
-
-#define	ifr_addr		ifr_ifru.ifru_addr			/* Address */
-#define	ifr_dstaddr		ifr_ifru.ifru_dstaddr		/* Other end of p-to-p link */
-#define	ifr_broadaddr	ifr_ifru.ifru_broadaddr		/* Broadcast address */
-#define	ifr_netmask		ifr_ifru.ifru_netmask		/* Interface net mask	*/
-#define	ifr_flags		ifr_ifru.ifru_flags[0]		/* Flags */
-#define	ifr_prevflags	ifr_ifru.ifru_flags[1]		/* Flags */
-#define	ifr_metric		ifr_ifru.ifru_metric		/* Metric */
-#define	ifr_mtu			ifr_ifru.ifru_mtu			/* Mtu */
-#define ifr_phys		ifr_ifru.ifru_phys			/* Physical wire */
-#define ifr_media		ifr_ifru.ifru_media			/* Physical media */
-#define	ifr_data		ifr_ifru.ifru_data			/* For use by interface */
-#define	ifr_reqcap		ifr_ifru.ifru_cap[0]		/* Requested capabilities */
-#define	ifr_curcap		ifr_ifru.ifru_cap[1]		/* Current capabilities */
-#define	ifr_index		ifr_ifru.ifru_index			/* Interface index */
-};
-
 struct ifaliasreq {
 	char ifra_name[IFNAMSIZ];	/* if name, e.g. "en0" */
 	struct sockaddr ifra_addr;
diff --git a/newlib/libc/sys/phoenix/include/netinet/in.h b/newlib/libc/sys/phoenix/include/netinet/in.h
index 18fabfe..9db5f61 100644
--- a/newlib/libc/sys/phoenix/include/netinet/in.h
+++ b/newlib/libc/sys/phoenix/include/netinet/in.h
@@ -40,8 +40,8 @@
 #define _NETINET_IN_H
 
 #include <machine/endian.h>
-#include <netinet6/in6.h>
-#include <sys/socket.h>
+#include <phoenix/netinet.h>
+#include <sys/types.h>
 
 #if BYTE_ORDER == BIG_ENDIAN
 #define htons(a)	(a)
@@ -72,35 +72,9 @@ static uint16_t ntohs(uint16_t netshort)
 }
 #endif
 
-/* Protocols common to RFC 1700, POSIX, and X/Open. */
-#define	IPPROTO_IP			0						/* Dummy for IP */
-#define	IPPROTO_ICMP		1						/* Control message protocol */
-#define	IPPROTO_TCP			6						/* TCP */
-#define	IPPROTO_UDP			17						/* User datagram protocol */
-
-#define	INADDR_ANY			(u_int32_t) 0x00000000
-#define	INADDR_BROADCAST	(u_int32_t) 0xffffffff	/* Must be masked */
-
-typedef	uint32_t			in_addr_t;
-typedef	uint16_t			in_port_t;
-
-/* Internet address (a structure for historical reasons). */
-struct in_addr {
-	in_addr_t s_addr;
-};
-
-/* Socket address, internet style. */
-struct sockaddr_in {
-	uint8_t sin_len;
-	sa_family_t sin_family;
-	in_port_t sin_port;
-	struct in_addr sin_addr;
-	char sin_zero[8];
-};
-
 #if __POSIX_VISIBLE >= 200112
-#define	IPPROTO_RAW			255		/* Raw IP packet */
-#define	INET_ADDRSTRLEN		16
+#define	IPPROTO_RAW				255			/* Raw IP packet */
+#define	INET_ADDRSTRLEN			16
 #endif
 
 /*
@@ -282,12 +256,6 @@ struct sockaddr_in {
 #define	IP_DEFAULT_MULTICAST_LOOP	1		/* Normally hear sends if a member  */
 #define	IP_MAX_MEMBERSHIPS			20		/* Per socket */
 
-/* Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. */
-struct ip_mreq {
-	struct in_addr imr_multiaddr;			/* IP multicast address of group */
-	struct in_addr imr_interface;			/* Local IP address of interface */
-};
-
 /* Argument for IP_PORTRANGE - which range to search when port is unspecified at bind() or connect() */
 #define	IP_PORTRANGE_DEFAULT		0		/* Default range */
 #define	IP_PORTRANGE_HIGH			1		/* "high" - request firewall bypass */
diff --git a/newlib/libc/sys/phoenix/include/netinet6/in6.h b/newlib/libc/sys/phoenix/include/netinet6/in6.h
index 1ebbc1d..956723b 100644
--- a/newlib/libc/sys/phoenix/include/netinet6/in6.h
+++ b/newlib/libc/sys/phoenix/include/netinet6/in6.h
@@ -70,6 +70,7 @@
 #ifndef _NETINET6_IN6_H
 #define _NETINET6_IN6_H
 
+#include <phoenix/netinet6.h>
 #include <sys/types.h>
 
 /*
@@ -114,33 +115,11 @@
 #define	IPV6PORT_RESERVEDMIN	600
 #define	IPV6PORT_RESERVEDMAX	(IPV6PORT_RESERVED-1)
 
-/* IPv6 address */
-struct in6_addr {
-	union {
-		uint8_t __u6_addr8[16];
-		uint16_t __u6_addr16[8];
-		uint32_t __u6_addr32[4];
-	} __u6_addr;		/* 128-bit IP6 address */
-};
-
-#define s6_addr					__u6_addr.__u6_addr8
-
-#define INET6_ADDRSTRLEN		46
-
 /* Socket address for IPv6 */
 #ifndef _XOPEN_SOURCE
 #define SIN6_LEN
 #endif
 
-struct sockaddr_in6 {
-	uint8_t sin6_family;		/* AF_INET6 (sa_family_t) */
-	uint16_t sin6_port;			/* Transport layer port # (in_port_t) */
-	uint32_t sin6_flowinfo;		/* IP6 flow information */
-	struct in6_addr sin6_addr;	/* IP6 address */
-	uint32_t sin6_scope_id;		/* scope zone index */
-};
-
-
 /* Definition of some useful macros to handle IP6 addresses */
 #define IN6ADDR_ANY_INIT \
 	{{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
diff --git a/newlib/libc/sys/phoenix/net/inet_aton.c b/newlib/libc/sys/phoenix/net/inet_aton.c
index f595e87..9013bca 100644
--- a/newlib/libc/sys/phoenix/net/inet_aton.c
+++ b/newlib/libc/sys/phoenix/net/inet_aton.c
@@ -60,6 +60,7 @@
 #include <arpa/inet.h>
 #include <ctype.h>
 #include <errno.h>
+#include <netinet/in.h>
 #include <stdlib.h>
 
 int inet_aton(const char *cp, struct in_addr *inp)
diff --git a/newlib/libc/sys/phoenix/socket.c b/newlib/libc/sys/phoenix/socket.c
index 213345f..39e4ab2 100644
--- a/newlib/libc/sys/phoenix/socket.c
+++ b/newlib/libc/sys/phoenix/socket.c
@@ -25,6 +25,7 @@
 #include "syscall.h"
 
 #include <errno.h>
+#include <phoenix/socket_args.h>
 #include <sys/socket.h>
 
 int socket(int domain, int type, int protocol)
diff --git a/newlib/libc/sys/phoenix/sockopt.c b/newlib/libc/sys/phoenix/sockopt.c
index a0acca8..6486e7b 100644
--- a/newlib/libc/sys/phoenix/sockopt.c
+++ b/newlib/libc/sys/phoenix/sockopt.c
@@ -25,6 +25,8 @@
 #include "syscall.h"
 
 #include <errno.h>
+#include <phoenix/socket_args.h>
+#include <phoenix/sockios.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 
@@ -41,7 +43,7 @@ int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
 
 int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen)
 {
-	struct setsockopt_args args;
+	struct sockopt_args args;
 	args.level = level;
 	args.optname = optname;
 	args.optval = optval;
@@ -59,7 +61,7 @@ int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optl
 
 int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen)
 {
-	struct setsockopt_args args;
+	struct sockopt_args args;
 	args.level = level;
 	args.optname = optname;
 	args.optval = (void *) optval;
diff --git a/newlib/libc/sys/phoenix/sys/socket.h b/newlib/libc/sys/phoenix/sys/socket.h
index 670dfa1..78776f5 100644
--- a/newlib/libc/sys/phoenix/sys/socket.h
+++ b/newlib/libc/sys/phoenix/sys/socket.h
@@ -25,7 +25,10 @@
 #ifndef _SYS_SOCKET_H
 #define	_SYS_SOCKET_H
 
+#include <phoenix/netinet.h>
+#include <phoenix/netinet6.h>
 #include <phoenix/socket.h>
+#include <phoenix/sockios.h>
 #include <sys/types.h>
 
 #define	_SS_MAXSIZE		128U
@@ -41,6 +44,10 @@ struct sockaddr_storage {
 	char __ss_pad2[_SS_PAD2SIZE];
 };
 
+#define HAVE_STRUCT_SOCKADDR_STORAGE
+#define HAVE_STRUCT_IN6_ADDR
+#define HAVE_STRUCT_SOCKADDR_IN6
+
 int socket(int domain, int type, int protocol);
 int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
 int listen(int sockfd, int backlog);
-- 
2.7.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]