forked from richardcochran/linuxptp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsa.h
96 lines (85 loc) · 3.26 KB
/
sa.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/**
* @file sa.h
* @brief Implements the various Security Association types.
* @note Copyright (C) 2019 Guillaume Mantelet <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef HAVE_SA_H
#define HAVE_SA_H
#include <sys/queue.h>
#include "ddt.h"
enum TrustState
{
UNTRUSTED,
TRUSTED,
NO_MATCHING_SA,
};
enum ChallengeState
{
IDLE,
CHALLENGING,
};
enum SATypeField
{
STATIC,
DYNAMIC,
};
struct security_association
{
LIST_ENTRY(security_association) sa_entry;
struct PortIdentity src_port;
struct PortIdentity dst_port;
Octet src_address[6];
Octet dst_address[6];
UInteger32 replay_counter;
UInteger16 lifetime_id;
UInteger16 key_id;
UInteger16 next_lifetime_id;
UInteger16 next_key_id;
Enumeration8 trust_state;
UInteger16 trust_timer;
UInteger16 trust_timeout;
Enumeration8 challenge_state;
UInteger16 challenge_timer;
UInteger16 challenge_timeout;
UInteger32 request_nonce;
UInteger32 response_nonce;
int challenge_required;
int response_required;
Enumeration8 type_field;
} PACKED;
LIST_HEAD(incoming_sa_list, security_association) incoming_sa;
LIST_HEAD(outgoing_sa_list, security_association) outgoing_sa;
int init_security_association_tables(void);
int add_incoming_sa(char *buf, struct ClockIdentity *ci);
void add_dynamic_sa(struct security_association *, struct PortIdentity *, char *, struct PortIdentity *);
int add_outgoing_sa(char *buf);
struct security_association* get_incoming_sa(struct PortIdentity*, char *, struct PortIdentity *);
struct security_association* get_outgoing_sa(struct PortIdentity*);
// LIST_INIT(&key_head);
//
// k1 = malloc(sizeof(struct key)); // Insert at the head
// LIST_INSERT_HEAD(&key_head, k1, key_entries);
//
// k2 = malloc(sizeof(struct key)); // Insert after
// LIST_INSERT_AFTER(k1, k2, key_entries);
//
// for (kp = key_head.lh_first; kp != NULL; kp = kp->key_entries.le_next) // Forward traversal
// np-> ...
//
// while (key_head.lh_first != NULL) // Delete.
// LIST_REMOVE(key_head.lh_first, key_entries);
#endif