lwpa  0.1.0
LightWeight Platform Abstraction (lwpa)
View other versions:
lwpa_socket_plat.h
1 /******************************************************************************
2  * Copyright 2018 ETC Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *******************************************************************************
16  * This file is a part of lwpa. For more information, go to:
17  * https://github.com/ETCLabs/lwpa
18  ******************************************************************************/
19 
20 #ifndef _LWPA_SOCKET_PLAT_H_
21 #define _LWPA_SOCKET_PLAT_H_
22 
23 #include <WinSock2.h>
24 #include <Windows.h>
25 
26 typedef SOCKET lwpa_socket_t;
27 
30 #define LWPA_SOCKET_INVALID INVALID_SOCKET
31 
32 #define LWPA_SOCKET_MAX_POLL_SIZE FD_SETSIZE
33 
34 typedef struct LwpaSocketPlatformData
35 {
36  WORD wsver;
37  WSADATA wsdata;
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 #define ip_plat_to_lwpa_v4(lwpaipptr, pfipptr) lwpaip_set_v4_address((lwpaipptr), ntohl((pfipptr)->s_addr))
45 #define ip_lwpa_to_plat_v4(pfipptr, lwpaipptr) ((pfipptr)->s_addr = htonl(lwpaip_v4_address(lwpaipptr)))
46 #define ip_plat_to_lwpa_v6(lwpaipptr, pfipptr) lwpaip_set_v6_address((lwpaipptr), (pfipptr)->s6_addr)
47 #define ip_lwpa_to_plat_v6(pfipptr, lwpaipptr) memcpy((pfipptr)->s6_addr, lwpaip_v6_address(lwpaipptr), IPV6_BYTES)
48 
49 bool sockaddr_plat_to_lwpa(LwpaSockaddr *sa, const struct sockaddr *pfsa);
50 size_t sockaddr_lwpa_to_plat(struct sockaddr *pfsa, const LwpaSockaddr *sa);
51 
52 #ifdef __cplusplus
53 }
54 #endif
55 
56 #endif /* _LWPA_SOCKET_PLAT_H_ */
UNDEFINED lwpa_socket_t
A socket handle.
Definition: lwpa_socket.dox:10
An IP address with associated interface and port.
Definition: lwpa_inet.h:176
Definition: lwpa_socket_plat.h:35