xref: /illumos-gate/usr/src/uts/common/inet/tcp_sig.h (revision 851677fbe21ab9cad62cea9e299167ea661fd1c8)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2024 Oxide Computer Company
14  */
15 
16 #ifndef	_INET_TCPSIG_H
17 #define	_INET_TCPSIG_H
18 
19 #include <sys/stdbool.h>
20 #include <inet/keysock.h>
21 #include <inet/sadb.h>
22 
23 #ifdef	__cplusplus
24 extern "C" {
25 #endif
26 
27 typedef struct tcpsig_sa {
28 	list_node_t			ts_link;
29 
30 	tcp_stack_t			*ts_stack;
31 
32 	sa_family_t			ts_family;
33 	struct sockaddr_storage		ts_src;
34 	struct sockaddr_storage		ts_dst;
35 
36 	ipsa_key_t			ts_key;
37 
38 	kmutex_t			ts_lock;
39 	/* Following protected by ts_lock */
40 	uint64_t			ts_refcnt;
41 	bool				ts_tombstoned;
42 } tcpsig_sa_t;
43 
44 typedef struct tcpsig_db {
45 	krwlock_t			td_lock;
46 	list_t				td_salist;
47 } tcpsig_db_t;
48 
49 extern void tcpsig_init(tcp_stack_t *);
50 extern void tcpsig_fini(tcp_stack_t *);
51 extern void tcpsig_sa_handler(keysock_t *, mblk_t *, sadb_msg_t *,
52     sadb_ext_t **);
53 
54 extern void tcpsig_sa_rele(tcpsig_sa_t *);
55 extern bool tcpsig_signature(mblk_t *, tcp_t *, tcpha_t *, int, uint8_t *,
56     bool);
57 extern bool tcpsig_verify(mblk_t *, tcp_t *, tcpha_t *, ip_recv_attr_t *,
58     uint8_t *);
59 
60 #ifdef	__cplusplus
61 }
62 #endif
63 
64 #endif /* _INET_TCPSIG_H */
65