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 40 /* All of the following are protected by ts_lock */ 41 42 time_t ts_addtime; /* Time added */ 43 time_t ts_usetime; /* Time of first use */ 44 time_t ts_lastuse; /* Time of last use */ 45 time_t ts_softexpiretime; /* First soft exp */ 46 time_t ts_hardexpiretime; /* First hard exp */ 47 48 /* Configured lifetimes */ 49 uint64_t ts_softaddlt; 50 uint64_t ts_softuselt; 51 uint64_t ts_hardaddlt; 52 uint64_t ts_harduselt; 53 54 uint64_t ts_refcnt; 55 bool ts_tombstoned; 56 uint_t ts_state; 57 } tcpsig_sa_t; 58 59 typedef struct tcpsig_db { 60 krwlock_t td_lock; 61 list_t td_salist; 62 } tcpsig_db_t; 63 64 extern void tcpsig_init(tcp_stack_t *); 65 extern void tcpsig_fini(tcp_stack_t *); 66 extern void tcpsig_sa_handler(keysock_t *, mblk_t *, sadb_msg_t *, 67 sadb_ext_t **); 68 69 extern void tcpsig_sa_rele(tcpsig_sa_t *); 70 extern bool tcpsig_sa_exists(tcp_t *, bool, tcpsig_sa_t **); 71 extern bool tcpsig_signature(mblk_t *, tcp_t *, tcpha_t *, int, uint8_t *, 72 bool); 73 extern bool tcpsig_verify(mblk_t *, tcp_t *, tcpha_t *, ip_recv_attr_t *, 74 uint8_t *); 75 76 #ifdef __cplusplus 77 } 78 #endif 79 80 #endif /* _INET_TCPSIG_H */ 81