]>
Commit | Line | Data |
---|---|---|
b592ec5a AR |
1 | /* |
2 | * Copyright (C) 2021 Abhinay Ramesh | |
3 | * | |
4 | * This file is part of GNU Zebra. | |
5 | * | |
6 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2, or (at your option) any | |
9 | * later version. | |
10 | * | |
11 | * GNU Zebra is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License along | |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
20 | ||
21 | #ifndef __OSPF6_AUTH_TRAILER_H__ | |
22 | #define __OSPF6_AUTH_TRAILER_H__ | |
23 | ||
24 | #include "lib/keychain.h" | |
25 | #include "ospf6_message.h" | |
26 | ||
27 | #define OSPF6_AUTH_HDR_MIN_SIZE 16 | |
28 | #define OSPF6_AUTH_HDR_FULL KEYCHAIN_MAX_HASH_SIZE + OSPF6_AUTH_HDR_MIN_SIZE | |
29 | ||
6cb85350 AR |
30 | #define OSPF6_AUTHENTICATION_NULL 0 |
31 | #define OSPF6_AUTHENTICATION_CRYPTOGRAPHIC 1 | |
b592ec5a AR |
32 | |
33 | /* Auth debug options */ | |
34 | extern unsigned char conf_debug_ospf6_auth[2]; | |
6cb85350 | 35 | |
b592ec5a AR |
36 | #define OSPF6_AUTH_TX 0 |
37 | #define OSPF6_AUTH_RX 1 | |
38 | #define OSPF6_DEBUG_AUTH_TX_ON() (conf_debug_ospf6_auth[OSPF6_AUTH_TX] = 1) | |
39 | #define OSPF6_DEBUG_AUTH_TX_OFF() (conf_debug_ospf6_auth[OSPF6_AUTH_TX] = 0) | |
40 | #define OSPF6_DEBUG_AUTH_RX_ON() (conf_debug_ospf6_auth[OSPF6_AUTH_RX] = 1) | |
41 | #define OSPF6_DEBUG_AUTH_RX_OFF() (conf_debug_ospf6_auth[OSPF6_AUTH_RX] = 0) | |
42 | #define IS_OSPF6_DEBUG_AUTH_TX (conf_debug_ospf6_auth[OSPF6_AUTH_TX]) | |
43 | #define IS_OSPF6_DEBUG_AUTH_RX (conf_debug_ospf6_auth[OSPF6_AUTH_RX]) | |
44 | ||
45 | #define OSPF6_AUTH_TRAILER_KEYCHAIN (1 << 0) | |
46 | #define OSPF6_AUTH_TRAILER_MANUAL_KEY (1 << 1) | |
47 | #define OSPF6_AUTH_TRAILER_KEYCHAIN_VALID (1 << 2) | |
48 | ||
49 | /* According to sesion 4.1 of RFC7166 defining the trailer struct */ | |
50 | struct ospf6_auth_hdr { | |
51 | uint16_t type; | |
52 | uint16_t length; | |
53 | uint16_t reserved; | |
54 | uint16_t id; | |
55 | uint32_t seqnum_h; | |
56 | uint32_t seqnum_l; | |
57 | unsigned char data[KEYCHAIN_MAX_HASH_SIZE]; | |
58 | }; | |
59 | ||
6cb85350 AR |
60 | enum ospf6_auth_err { |
61 | OSPF6_AUTH_VALIDATE_SUCCESS = 0, | |
62 | OSPF6_AUTH_VALIDATE_FAILURE, | |
63 | OSPF6_AUTH_PROCESS_NORMAL, | |
64 | OSPF6_AUTH_FILE_EXIST, | |
65 | OSPF6_AUTH_FILE_DO_NOT_EXIST | |
66 | }; | |
67 | ||
b592ec5a | 68 | void ospf6_auth_hdr_dump_send(struct ospf6_header *ospfh, uint16_t length); |
6cb85350 AR |
69 | void ospf6_auth_hdr_dump_recv(struct ospf6_header *ospfh, uint16_t length, |
70 | unsigned int lls_len); | |
b592ec5a AR |
71 | unsigned char *ospf6_hash_message_xor(unsigned char *mes1, unsigned char *mes2, |
72 | uint32_t len); | |
42bfee18 | 73 | uint16_t ospf6_auth_len_get(struct ospf6_interface *oi); |
b592ec5a | 74 | int ospf6_auth_validate_pkt(struct ospf6_interface *oi, unsigned int *pkt_len, |
6cb85350 AR |
75 | struct ospf6_header *oh, unsigned int *at_len, |
76 | unsigned int *lls_block_len); | |
b592ec5a | 77 | int ospf6_auth_check_digest(struct ospf6_header *oh, struct ospf6_interface *oi, |
6cb85350 | 78 | struct in6_addr *src, unsigned int lls_len); |
b592ec5a AR |
79 | void ospf6_auth_update_digest(struct ospf6_interface *oi, |
80 | struct ospf6_header *oh, | |
81 | struct ospf6_auth_hdr *ospf6_auth, char *auth_str, | |
6cb85350 | 82 | uint32_t pkt_len, enum keychain_hash_algo algo); |
b592ec5a AR |
83 | void ospf6_auth_digest_send(struct in6_addr *src, struct ospf6_interface *oi, |
84 | struct ospf6_header *oh, uint16_t auth_len, | |
85 | uint32_t pkt_len); | |
86 | void install_element_ospf6_debug_auth(void); | |
87 | int config_write_ospf6_debug_auth(struct vty *vty); | |
88 | void install_element_ospf6_clear_intf_auth(void); | |
6cb85350 AR |
89 | enum ospf6_auth_err ospf6_auth_nvm_file_exist(void); |
90 | void ospf6_auth_seqno_nvm_update(struct ospf6 *ospf6); | |
91 | void ospf6_auth_seqno_nvm_delete(struct ospf6 *ospf6); | |
92 | void ospf6_auth_seqno_nvm_read(struct ospf6 *ospf6); | |
b592ec5a | 93 | #endif /* __OSPF6_AUTH_TRAILER_H__ */ |