]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
b592ec5a AR |
2 | /* |
3 | * Copyright (C) 2021 Abhinay Ramesh | |
b592ec5a AR |
4 | */ |
5 | ||
6 | #ifndef __OSPF6_AUTH_TRAILER_H__ | |
7 | #define __OSPF6_AUTH_TRAILER_H__ | |
8 | ||
9 | #include "lib/keychain.h" | |
10 | #include "ospf6_message.h" | |
11 | ||
12 | #define OSPF6_AUTH_HDR_MIN_SIZE 16 | |
13 | #define OSPF6_AUTH_HDR_FULL KEYCHAIN_MAX_HASH_SIZE + OSPF6_AUTH_HDR_MIN_SIZE | |
14 | ||
6cb85350 AR |
15 | #define OSPF6_AUTHENTICATION_NULL 0 |
16 | #define OSPF6_AUTHENTICATION_CRYPTOGRAPHIC 1 | |
b592ec5a AR |
17 | |
18 | /* Auth debug options */ | |
19 | extern unsigned char conf_debug_ospf6_auth[2]; | |
6cb85350 | 20 | |
b592ec5a AR |
21 | #define OSPF6_AUTH_TX 0 |
22 | #define OSPF6_AUTH_RX 1 | |
23 | #define OSPF6_DEBUG_AUTH_TX_ON() (conf_debug_ospf6_auth[OSPF6_AUTH_TX] = 1) | |
24 | #define OSPF6_DEBUG_AUTH_TX_OFF() (conf_debug_ospf6_auth[OSPF6_AUTH_TX] = 0) | |
25 | #define OSPF6_DEBUG_AUTH_RX_ON() (conf_debug_ospf6_auth[OSPF6_AUTH_RX] = 1) | |
26 | #define OSPF6_DEBUG_AUTH_RX_OFF() (conf_debug_ospf6_auth[OSPF6_AUTH_RX] = 0) | |
27 | #define IS_OSPF6_DEBUG_AUTH_TX (conf_debug_ospf6_auth[OSPF6_AUTH_TX]) | |
28 | #define IS_OSPF6_DEBUG_AUTH_RX (conf_debug_ospf6_auth[OSPF6_AUTH_RX]) | |
29 | ||
30 | #define OSPF6_AUTH_TRAILER_KEYCHAIN (1 << 0) | |
31 | #define OSPF6_AUTH_TRAILER_MANUAL_KEY (1 << 1) | |
32 | #define OSPF6_AUTH_TRAILER_KEYCHAIN_VALID (1 << 2) | |
33 | ||
34 | /* According to sesion 4.1 of RFC7166 defining the trailer struct */ | |
35 | struct ospf6_auth_hdr { | |
36 | uint16_t type; | |
37 | uint16_t length; | |
38 | uint16_t reserved; | |
39 | uint16_t id; | |
40 | uint32_t seqnum_h; | |
41 | uint32_t seqnum_l; | |
42 | unsigned char data[KEYCHAIN_MAX_HASH_SIZE]; | |
43 | }; | |
44 | ||
6cb85350 AR |
45 | enum ospf6_auth_err { |
46 | OSPF6_AUTH_VALIDATE_SUCCESS = 0, | |
47 | OSPF6_AUTH_VALIDATE_FAILURE, | |
48 | OSPF6_AUTH_PROCESS_NORMAL, | |
49 | OSPF6_AUTH_FILE_EXIST, | |
50 | OSPF6_AUTH_FILE_DO_NOT_EXIST | |
51 | }; | |
52 | ||
b592ec5a | 53 | void ospf6_auth_hdr_dump_send(struct ospf6_header *ospfh, uint16_t length); |
6cb85350 AR |
54 | void ospf6_auth_hdr_dump_recv(struct ospf6_header *ospfh, uint16_t length, |
55 | unsigned int lls_len); | |
b592ec5a AR |
56 | unsigned char *ospf6_hash_message_xor(unsigned char *mes1, unsigned char *mes2, |
57 | uint32_t len); | |
42bfee18 | 58 | uint16_t ospf6_auth_len_get(struct ospf6_interface *oi); |
b592ec5a | 59 | int ospf6_auth_validate_pkt(struct ospf6_interface *oi, unsigned int *pkt_len, |
6cb85350 AR |
60 | struct ospf6_header *oh, unsigned int *at_len, |
61 | unsigned int *lls_block_len); | |
b592ec5a | 62 | int ospf6_auth_check_digest(struct ospf6_header *oh, struct ospf6_interface *oi, |
6cb85350 | 63 | struct in6_addr *src, unsigned int lls_len); |
b592ec5a AR |
64 | void ospf6_auth_update_digest(struct ospf6_interface *oi, |
65 | struct ospf6_header *oh, | |
66 | struct ospf6_auth_hdr *ospf6_auth, char *auth_str, | |
6cb85350 | 67 | uint32_t pkt_len, enum keychain_hash_algo algo); |
b592ec5a AR |
68 | void ospf6_auth_digest_send(struct in6_addr *src, struct ospf6_interface *oi, |
69 | struct ospf6_header *oh, uint16_t auth_len, | |
70 | uint32_t pkt_len); | |
71 | void install_element_ospf6_debug_auth(void); | |
72 | int config_write_ospf6_debug_auth(struct vty *vty); | |
73 | void install_element_ospf6_clear_intf_auth(void); | |
6cb85350 AR |
74 | enum ospf6_auth_err ospf6_auth_nvm_file_exist(void); |
75 | void ospf6_auth_seqno_nvm_update(struct ospf6 *ospf6); | |
76 | void ospf6_auth_seqno_nvm_delete(struct ospf6 *ospf6); | |
77 | void ospf6_auth_seqno_nvm_read(struct ospf6 *ospf6); | |
b592ec5a | 78 | #endif /* __OSPF6_AUTH_TRAILER_H__ */ |