• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * coap_tcp_internal.h -- TCP functions for libcoap
3  *
4  * Copyright (C) 2019--2020 Olaf Bergmann <bergmann@tzi.org> and others
5  *
6  * SPDX-License-Identifier: BSD-2-Clause
7  *
8  * This file is part of the CoAP library libcoap. Please see README for terms
9  * of use.
10  */
11 
12 /**
13  * @file coap_tcp_internal.h
14  * @brief COAP tcp internal information
15  */
16 
17 #ifndef COAP_TCP_INTERNAL_H_
18 #define COAP_TCP_INTERNAL_H_
19 
20 #include "coap_io.h"
21 
22 /**
23  * @defgroup tcp TCP Support (Internal)
24  * CoAP TCP Structures, Enums and Functions that are not exposed to
25  * applications
26  * @{
27  */
28 
29 #if !COAP_DISABLE_TCP
30 
31 /**
32  * Create a new TCP socket and initiate the connection
33  *
34  * Internal function.
35  *
36  * @param sock Where socket information is to be filled in
37  * @param local_if The local address to use or NULL
38  * @param server The address to connect to
39  * @param default_port The port to use if not set in @p server
40  * @param local_addr Filled in after connection initiation with
41  *                   the local address
42  * @param remote_addr Filled in after connection initiation with
43  *                    the remote address
44  *
45  * @return @c 1 if succesful, @c 0 if failure of some sort
46 */
47 int
48 coap_socket_connect_tcp1(coap_socket_t *sock,
49                          const coap_address_t *local_if,
50                          const coap_address_t *server,
51                          int default_port,
52                          coap_address_t *local_addr,
53                          coap_address_t *remote_addr);
54 
55 /**
56  * Complete the TCP Connection
57  *
58  * Internal function.
59  *
60  * @param sock The socket information to use
61  * @param local_addr Filled in with the final local address
62  * @param remote_addr Filled in with the final remote address
63  *
64  * @return @c 1 if succesful, @c 0 if failure of some sort
65 */
66 int
67 coap_socket_connect_tcp2(coap_socket_t *sock,
68                          coap_address_t *local_addr,
69                          coap_address_t *remote_addr);
70 
71 /**
72  * Create a new TCP socket and then listen for new incoming TCP sessions
73  *
74  * Internal function.
75  *
76  * @param sock Where socket information is to be filled in
77  * @param listen_addr The address to be listening for new incoming sessions
78  * @param bound_addr Filled in with the address that the TCP layer
79  *                   is listening on for new incoming TCP sessions
80  *
81  * @return @c 1 if succesful, @c 0 if failure of some sort
82 */
83 int
84 coap_socket_bind_tcp(coap_socket_t *sock,
85                      const coap_address_t *listen_addr,
86                      coap_address_t *bound_addr);
87 
88 /**
89  * Accept a new incoming TCP session
90  *
91  * Internal function.
92  *
93  * @param server The socket information to use to accept the TCP connection
94  * @param new_client Filled in socket information with the new incoming
95  *                   session information
96  * @param local_addr Filled in with the local address
97  * @param remote_addr Filled in with the remote address
98  *
99  * @return @c 1 if succesful, @c 0 if failure of some sort
100 */
101 int
102 coap_socket_accept_tcp(coap_socket_t *server,
103                        coap_socket_t *new_client,
104                        coap_address_t *local_addr,
105                        coap_address_t *remote_addr);
106 
107 #endif /* !COAP_DISABLE_TCP */
108 
109 /** @} */
110 
111 #endif /* COAP_TCP_INTERNAL_H_ */
112