• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * libwebsockets - small server side websockets and web server implementation
3  *
4  * Copyright (C) 2010 - 2019 Andy Green <andy@warmcat.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22  * IN THE SOFTWARE.
23  */
24 
25 #ifndef __LWS_OPTEE_H
26 #define __LWS_OPTEE_H
27 
28 /* 128-bit IP6 address */
29 struct in6_addr {
30 	union {
31 		uint8_t	  u6_addr8[16];
32 		uint16_t  u6_addr16[8];
33 		uint32_t  u6_addr32[4];
34 	};
35 };
36 
37 #define		_SS_MAXSIZE	128U
38 #define		_SS_ALIGNSIZE	(sizeof(int64_t))
39 #define		_SS_PAD1SIZE	(_SS_ALIGNSIZE - \
40 			sizeof(sa_family_t))
41 #define		_SS_PAD2SIZE	(_SS_MAXSIZE - \
42 			sizeof(sa_family_t) - _SS_PAD1SIZE - _SS_ALIGNSIZE)
43 
44 struct sockaddr_storage {
45 	sa_family_t	ss_family;	/* address family */
46 	char		__ss_pad1[_SS_PAD1SIZE];
47 	int64_t		__ss_align;	/* force desired struct alignment */
48 	char		__ss_pad2[_SS_PAD2SIZE];
49 };
50 
51 #define __SOCK_SIZE__	16		/* sizeof(struct sockaddr)      */
52 struct sockaddr {
53 	sa_family_t	sa_family;	/* address family */
54 	uint8_t		sa_data[__SOCK_SIZE__	/* address value */
55 				- sizeof(sa_family_t)];
56 };
57 
58 /* 16 bytes */
59 struct sockaddr_in {
60 	sa_family_t	sin_family;
61 	in_port_t	sin_port;
62 	struct in_addr	sin_addr;
63 	uint8_t		sin_zero[__SOCK_SIZE__	/* padding until 16 bytes */
64 				- sizeof(sa_family_t)
65 				- sizeof(in_port_t)
66 				- sizeof(struct  in_addr)];
67 };
68 
69 struct sockaddr_in6 {
70 	sa_family_t	sin6_family;	/* AF_INET6 */
71 	in_port_t	sin6_port;	/* Transport layer port # */
72 	uint32_t	sin6_flowinfo;	/* IP6 flow information */
73 	struct in6_addr	sin6_addr;	/* IP6 address */
74 	uint32_t	sin6_scope_id;	/* scope zone index */
75 };
76 
77 #endif /* __LWS_OPTEE_H */
78