Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasWoodtli committed Jan 9, 2025
1 parent eef69c3 commit 277a93b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
7 changes: 5 additions & 2 deletions transport/tinydtls/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#define COAPS_PORT "5684"
#define URI_LENGTH 256

// after 40sec of inactivity we rehandshake
#define DTLS_NAT_TIMEOUT 40

typedef struct _lwm2m_connection_t {
struct _lwm2m_connection_t *next;
int sock;
Expand Down Expand Up @@ -370,8 +373,8 @@ lwm2m_connection_t *lwm2m_connection_find(lwm2m_connection_t *connList, const st
return connP;
}

lwm2m_connection_t *lwm2m_connection_new_incoming(lwm2m_connection_t *connList, int sock,
const struct sockaddr *addr, size_t addrLen) {
lwm2m_connection_t *lwm2m_connection_new_incoming(lwm2m_connection_t *connList, int sock, const struct sockaddr *addr,
size_t addrLen) {
lwm2m_connection_t *connP;

connP = (lwm2m_connection_t *)malloc(sizeof(lwm2m_connection_t));
Expand Down
12 changes: 3 additions & 9 deletions transport/tinydtls/include/tinydtls/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,14 @@
#define LWM2M_BSSERVER_PORT_STR "5685"
#define LWM2M_BSSERVER_PORT 5685

// after 40sec of inactivity we rehandshake
#define DTLS_NAT_TIMEOUT 40

typedef struct _lwm2m_connection_t lwm2m_connection_t;

int lwm2m_create_socket(const char *portStr, int ai_family);

lwm2m_connection_t *lwm2m_connection_find(lwm2m_connection_t *connList, const struct sockaddr_storage *addr,
size_t addrLen);
lwm2m_connection_t *lwm2m_connection_new_incoming(lwm2m_connection_t *connList, int sock,
const struct sockaddr *addr, size_t addrLen);
lwm2m_connection_t *lwm2m_connection_create(lwm2m_connection_t *connList, int sock,
lwm2m_object_t *securityObj, int instanceId, lwm2m_context_t *lwm2mH,
int addressFamily);
lwm2m_connection_t *lwm2m_connection_find(lwm2m_connection_t *connList, const struct sockaddr_storage *addr, size_t addrLen);
lwm2m_connection_t *lwm2m_connection_new_incoming(lwm2m_connection_t *connList, int sock, const struct sockaddr *addr, size_t addrLen);
lwm2m_connection_t *lwm2m_connection_create(lwm2m_connection_t *connList, int sock, lwm2m_object_t *securityObj, int instanceId, lwm2m_context_t *lwm2mH, int addressFamily);
lwm2m_connection_t *lwm2m_connection_remove_one(lwm2m_connection_t *connList);

void lwm2m_connection_free(lwm2m_connection_t *connList);
Expand Down
22 changes: 11 additions & 11 deletions transport/udp/include/udp/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,16 @@
*
* Contributors:
* David Navarro, Intel Corporation - initial API and implementation
* Lukas Woodtli, Gardena AG - Combine connection implementations
*
*******************************************************************************/

#ifndef CONNECTION_H_
#define CONNECTION_H_
#ifndef WAKAAMA_CONNECTION_H_
#define WAKAAMA_CONNECTION_H_


#include <arpa/inet.h>
#include <liblwm2m.h>
#include <netdb.h>
#include <netinet/in.h>
#include <stdio.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <unistd.h>

#define LWM2M_STANDARD_PORT_STR "5683"
#define LWM2M_STANDARD_PORT 5683
Expand All @@ -34,13 +30,13 @@
#define LWM2M_BSSERVER_PORT_STR "5685"
#define LWM2M_BSSERVER_PORT 5685


typedef struct _lwm2m_connection_t lwm2m_connection_t;

int lwm2m_create_socket(const char *portStr, int ai_family);

lwm2m_connection_t *lwm2m_connection_find(lwm2m_connection_t *connList, struct sockaddr_storage *addr, size_t addrLen);
lwm2m_connection_t *lwm2m_connection_new_incoming(lwm2m_connection_t *connList, int sock, struct sockaddr *addr,
size_t addrLen);
lwm2m_connection_t *lwm2m_connection_find(lwm2m_connection_t *connList, const struct sockaddr_storage *addr, size_t addrLen);
lwm2m_connection_t *lwm2m_connection_new_incoming(lwm2m_connection_t *connList, int sock, const struct sockaddr *addr, size_t addrLen);
lwm2m_connection_t *lwm2m_connection_create(lwm2m_connection_t *connList, int sock, char *host, char *port,
int addressFamily);

Expand All @@ -49,5 +45,9 @@ lwm2m_connection_t *lwm2m_connection_remove_one(lwm2m_connection_t *connList);
void lwm2m_connection_free(lwm2m_connection_t *connList);

int lwm2m_connection_send(lwm2m_connection_t *connP, uint8_t *buffer, size_t length);
int lwm2m_connection_handle_packet(lwm2m_connection_t *connP, uint8_t *buffer, size_t length);

// rehandshake a connection, useful when your NAT timed out and your client has a new IP/PORT
int lwm2m_connection_rehandshake(lwm2m_connection_t *connP, bool sendCloseNotify);

#endif

0 comments on commit 277a93b

Please sign in to comment.