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 <rtcs.h>
24 #include "lwpa_inet.h"
25 
26 typedef uint32_t lwpa_socket_t;
27 
29 #define LWPA_SOCKET_INVALID RTCS_SOCKET_ERROR
30 
31 #define LWPA_SOCKET_MAX_POLL_SIZE RTCSCFG_FD_SETSIZE
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #define ip_plat_to_lwpa_v4(lwpaipptr, pfipptr) lwpaip_set_v4_address((lwpaipptr), (pfipptr)->s_addr)
38 #define ip_lwpa_to_plat_v4(pfipptr, lwpaipptr) ((pfipptr)->s_addr = lwpaip_v4_address(lwpaipptr))
39 #define ip_plat_to_lwpa_v6(lwpaipptr, pfipptr) lwpaip_set_v6_address((lwpaipptr), (pfipptr)->s6_addr)
40 #define ip_lwpa_to_plat_v6(pfipptr, lwpaipptr) memcpy((pfipptr)->s6_addr, lwpaip_v6_address(lwpaipptr), IPV6_BYTES)
41 
42 bool sockaddr_plat_to_lwpa(LwpaSockaddr *sa, const struct sockaddr *pfsa);
43 size_t sockaddr_lwpa_to_plat(struct sockaddr *pfsa, const LwpaSockaddr *sa);
44 
45 #ifdef __cplusplus
46 }
47 #endif
48 
49 #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