mirror of
https://github.com/obgm/libcoap.git
synced 2026-12-05 20:02:19 +03:00
LwIP: Support TCP
If LWIP_TCP is set, then CoAP TCP support is compiled in.
This commit is contained in:
1 parent
fa88e3235b
commit
805d148dd0
15 files changed
+377
-83
No files matched your search
@@ -33,7 +33,12 @@ struct uip_udp_conn;
|
||||
|
||||
struct coap_socket_t {
|
||||
#if defined(WITH_LWIP)
|
||||
struct udp_pcb *pcb;
|
||||
struct pbuf *p;
|
||||
struct udp_pcb *udp_pcb;
|
||||
#if ! COAP_DISABLE_TCP
|
||||
struct tcp_pcb *tcp_pcb;
|
||||
#endif /* ! COAP_DISABLE_TCP */
|
||||
|
||||
#elif defined(WITH_CONTIKI)
|
||||
struct uip_udp_conn *udp_conn;
|
||||
coap_context_t *context;
|
||||
|
||||
@@ -143,13 +143,26 @@ coap_free(void *object) {
|
||||
COAP_STATIC_INLINE void
|
||||
coap_memory_init(void) {}
|
||||
|
||||
#if MEMP_STATS
|
||||
COAP_STATIC_INLINE void *
|
||||
coap_malloc_error(uint16_t *err) {
|
||||
(*err)++;
|
||||
return NULL;
|
||||
}
|
||||
#endif /* MEMP_STATS */
|
||||
/* It would be nice to check that size equals the size given at the memp
|
||||
* declaration, but i currently don't see a standard way to check that without
|
||||
* sourcing the custom memp pools and becoming dependent of its syntax
|
||||
*/
|
||||
#if MEMP_STATS
|
||||
#define coap_malloc_type(type, asize) \
|
||||
(((asize) <= memp_pools[MEMP_ ## type]->size) ? \
|
||||
memp_malloc(MEMP_ ## type) : coap_malloc_error(&memp_pools[MEMP_ ## type]->stats->err))
|
||||
#else /* ! MEMP_STATS */
|
||||
#define coap_malloc_type(type, asize) \
|
||||
(((asize) <= memp_pools[MEMP_ ## type]->size) ? \
|
||||
memp_malloc(MEMP_ ## type) : NULL)
|
||||
#endif /* ! MEMP_STATS */
|
||||
#define coap_free_type(type, p) memp_free(MEMP_ ## type, p)
|
||||
|
||||
/* As these are fixed size, return value if already defined */
|
||||
|
||||
@@ -128,10 +128,12 @@ int coap_netif_strm_listen(coap_endpoint_t *endpoint,
|
||||
*
|
||||
* @param endpoint Endpoint to to do the accept on.
|
||||
* @param session Session to to do the accept update on.
|
||||
* @param extra Available for use by any underlying network stack.
|
||||
*
|
||||
* @return @c 1 OK, 0 on failure.
|
||||
*/
|
||||
int coap_netif_strm_accept(coap_endpoint_t *endpoint, coap_session_t *session);
|
||||
int coap_netif_strm_accept(coap_endpoint_t *endpoint, coap_session_t *session,
|
||||
void *extra);
|
||||
|
||||
/**
|
||||
* Layer function interface for Netif stream connect (tcp).
|
||||
|
||||
@@ -309,14 +309,14 @@ int coap_session_refresh_psk_identity(coap_session_t *session,
|
||||
* Creates a new server session for the specified endpoint.
|
||||
* @param ctx The CoAP context.
|
||||
* @param ep An endpoint where an incoming connection request is pending.
|
||||
* @param extra Available for use by any underlying network stack.
|
||||
*
|
||||
* @return A new CoAP session or NULL if failed. Call coap_session_release to
|
||||
* add to unused queue.
|
||||
*/
|
||||
coap_session_t *coap_new_server_session(
|
||||
coap_context_t *ctx,
|
||||
coap_endpoint_t *ep
|
||||
);
|
||||
coap_session_t *coap_new_server_session(coap_context_t *ctx,
|
||||
coap_endpoint_t *ep,
|
||||
void *extra);
|
||||
#endif /* COAP_SERVER_SUPPORT */
|
||||
|
||||
/**
|
||||
@@ -384,6 +384,10 @@ coap_session_t *coap_session_new_dtls_session(coap_session_t *session,
|
||||
void coap_session_free(coap_session_t *session);
|
||||
void coap_session_mfree(coap_session_t *session);
|
||||
|
||||
void coap_read_session(coap_context_t *ctx, coap_session_t *session, coap_tick_t now);
|
||||
|
||||
void coap_connect_session(coap_session_t *session, coap_tick_t now);
|
||||
|
||||
#define COAP_SESSION_REF(s) ((s)->ref
|
||||
|
||||
/* RFC7252 */
|
||||
|
||||
@@ -93,13 +93,15 @@ int coap_socket_bind_tcp(coap_socket_t *sock,
|
||||
* session information
|
||||
* @param local_addr Filled in with the local address
|
||||
* @param remote_addr Filled in with the remote address
|
||||
* @param extra Available for use by any underlying network stack.
|
||||
*
|
||||
* @return @c 1 if succesful, @c 0 if failure of some sort
|
||||
*/
|
||||
int coap_socket_accept_tcp(coap_socket_t *server,
|
||||
coap_socket_t *new_client,
|
||||
coap_address_t *local_addr,
|
||||
coap_address_t *remote_addr);
|
||||
coap_address_t *remote_addr,
|
||||
void *extra);
|
||||
|
||||
#endif /* !COAP_DISABLE_TCP */
|
||||
|
||||
|
||||
Reference in new issue
Block a user