2 * Copyright (C) 2021 Abhinay Ramesh
4 * This file is part of GNU Zebra.
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
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.
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
21 #ifndef __OSPF6_AUTH_TRAILER_H__
22 #define __OSPF6_AUTH_TRAILER_H__
24 #include "lib/keychain.h"
25 #include "ospf6_message.h"
27 #define OSPF6_AUTH_HDR_MIN_SIZE 16
28 #define OSPF6_AUTH_HDR_FULL KEYCHAIN_MAX_HASH_SIZE + OSPF6_AUTH_HDR_MIN_SIZE
30 #define OSPF6_AUTHENTICATION_NULL 0
31 #define OSPF6_AUTHENTICATION_CRYPTOGRAPHIC 1
33 /* Auth debug options */
34 extern unsigned char conf_debug_ospf6_auth
[2];
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])
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)
49 /* According to sesion 4.1 of RFC7166 defining the trailer struct */
50 struct ospf6_auth_hdr
{
57 unsigned char data
[KEYCHAIN_MAX_HASH_SIZE
];
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
68 void ospf6_auth_hdr_dump_send(struct ospf6_header
*ospfh
, uint16_t length
);
69 void ospf6_auth_hdr_dump_recv(struct ospf6_header
*ospfh
, uint16_t length
,
70 unsigned int lls_len
);
71 unsigned char *ospf6_hash_message_xor(unsigned char *mes1
, unsigned char *mes2
,
73 unsigned int ospf6_auth_len_get(struct ospf6_interface
*oi
);
74 int ospf6_auth_validate_pkt(struct ospf6_interface
*oi
, unsigned int *pkt_len
,
75 struct ospf6_header
*oh
, unsigned int *at_len
,
76 unsigned int *lls_block_len
);
77 int ospf6_auth_check_digest(struct ospf6_header
*oh
, struct ospf6_interface
*oi
,
78 struct in6_addr
*src
, unsigned int lls_len
);
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
,
82 uint32_t pkt_len
, enum keychain_hash_algo algo
);
83 void ospf6_auth_digest_send(struct in6_addr
*src
, struct ospf6_interface
*oi
,
84 struct ospf6_header
*oh
, uint16_t auth_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);
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
);
93 #endif /* __OSPF6_AUTH_TRAILER_H__ */