-
Notifications
You must be signed in to change notification settings - Fork 20
/
session.h
67 lines (57 loc) · 1.82 KB
/
session.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*******************************************************************************
*
* Copyright (c) 2011, 2012, 2013, 2014, 2015 Olaf Bergmann (TZI) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v. 1.0 which accompanies this distribution.
*
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Olaf Bergmann - initial API and implementation
*
*******************************************************************************/
#ifndef _DTLS_SESSION_H_
#define _DTLS_SESSION_H_
#include <string.h>
#include "tinydtls.h"
#include "global.h"
#ifdef WITH_CONTIKI
#include "net/ip/uip.h"
typedef struct {
unsigned char size;
uip_ipaddr_t addr;
unsigned short port;
int ifindex;
} session_t;
#else /* WITH_CONTIKI */
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
typedef struct {
socklen_t size; /**< size of addr */
union {
struct sockaddr sa;
struct sockaddr_storage st;
struct sockaddr_in sin;
struct sockaddr_in6 sin6;
} addr;
uint8_t ifindex;
} session_t;
#endif /* WITH_CONTIKI */
/**
* Resets the given session_t object @p sess to its default
* values. In particular, the member rlen must be initialized to the
* available size for storing addresses.
*
* @param sess The session_t object to initialize.
*/
void dtls_session_init(session_t *sess);
/**
* Compares the given session objects. This function returns @c 0
* when @p a and @p b differ, @c 1 otherwise.
*/
int dtls_session_equals(const session_t *a, const session_t *b);
#endif /* _DTLS_SESSION_H_ */