1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _IKEDOOR_H 27 #define _IKEDOOR_H 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 #include <limits.h> 34 #include <sys/sysmacros.h> 35 #include <net/pfkeyv2.h> 36 #include <door.h> 37 38 /* 39 * This version number is intended to stop the calling process from 40 * getting confused if a structure is changed and a mismatch occurs. 41 * This should be incremented each time a structure is changed. 42 */ 43 44 /* 45 * The IKE process may be a 64-bit process, but ikeadm or any other IKE 46 * door consumer does not have to be. We need to be strict ala. PF_KEY or 47 * any on-the-wire-protocol with respect to structure fields offsets and 48 * alignment. Please make sure all structures are the same size on both 49 * 64-bit and 32-bit execution environments (or even other ones), and that 50 * apart from trivial 4-byte enums or base headers, that all structures are 51 * multiples of 8-bytes (64-bits). 52 */ 53 #define DOORVER 3 54 #define DOORNM "/var/run/ike_door" 55 56 57 typedef enum { 58 IKE_SVC_GET_DBG, 59 IKE_SVC_SET_DBG, 60 61 IKE_SVC_GET_PRIV, 62 IKE_SVC_SET_PRIV, 63 64 IKE_SVC_GET_STATS, 65 66 IKE_SVC_GET_P1, 67 IKE_SVC_DEL_P1, 68 IKE_SVC_DUMP_P1S, 69 IKE_SVC_FLUSH_P1S, 70 71 IKE_SVC_GET_RULE, 72 IKE_SVC_NEW_RULE, 73 IKE_SVC_DEL_RULE, 74 IKE_SVC_DUMP_RULES, 75 IKE_SVC_READ_RULES, 76 IKE_SVC_WRITE_RULES, 77 78 IKE_SVC_GET_PS, 79 IKE_SVC_NEW_PS, 80 IKE_SVC_DEL_PS, 81 IKE_SVC_DUMP_PS, 82 IKE_SVC_READ_PS, 83 IKE_SVC_WRITE_PS, 84 85 IKE_SVC_DBG_RBDUMP, 86 87 IKE_SVC_GET_DEFS, 88 89 IKE_SVC_SET_PIN, 90 IKE_SVC_DEL_PIN, 91 92 IKE_SVC_DUMP_CERTCACHE, 93 IKE_SVC_FLUSH_CERTCACHE, 94 95 IKE_SVC_ERROR 96 } ike_svccmd_t; 97 98 /* DPD status */ 99 100 typedef enum dpd_status { 101 DPD_NOT_INITIATED = 0, 102 DPD_IN_PROGRESS, 103 DPD_SUCCESSFUL, 104 DPD_FAILURE 105 } dpd_status_t; 106 107 #define IKE_SVC_MAX IKE_SVC_ERROR 108 109 110 /* 111 * Support structures/defines 112 */ 113 114 #define IKEDOORROUNDUP(i) P2ROUNDUP((i), sizeof (uint64_t)) 115 116 /* 117 * Debug categories. The debug level is a bitmask made up of 118 * flags indicating the desired categories; only 31 bits are 119 * available, as the highest-order bit designates an invalid 120 * setting. 121 */ 122 #define D_INVALID 0x80000000 123 124 #define D_CERT 0x00000001 /* certificate management */ 125 #define D_KEY 0x00000002 /* key management */ 126 #define D_OP 0x00000004 /* operational: config, init, mem */ 127 #define D_P1 0x00000008 /* phase 1 negotiation */ 128 #define D_P2 0x00000010 /* phase 2 negotiation */ 129 #define D_PFKEY 0x00000020 /* pf key interface */ 130 #define D_POL 0x00000040 /* policy management */ 131 #define D_PROP 0x00000080 /* proposal construction */ 132 #define D_DOOR 0x00000100 /* door server */ 133 #define D_CONFIG 0x00000200 /* config file processing */ 134 135 #define D_HIGHBIT 0x00000200 136 #define D_ALL 0x000003ff 137 138 /* 139 * Access privilege levels: define level of access to keying information. 140 * The privileges granted at each level is a superset of the privileges 141 * granted at all lower levels. 142 * 143 * The door operations which require special privileges are: 144 * 145 * - receiving keying material for SAs and preshared key entries 146 * IKE_PRIV_KEYMAT must be set for this. 147 * 148 * - get/dump/new/delete/read/write preshared keys 149 * IKE_PRIV_KEYMAT or IKE_PRIV_MODKEYS must be set to do this. 150 * If IKE_PRIV_MODKEYS is set, the information returned for a 151 * get/dump request will not include the actual key; in order 152 * to get the key itself, IKE_PRIV_KEYMAT must be set. 153 * 154 * - modifying the privilege level: the daemon's privilege level 155 * is set when the daemon is started; the level may only be 156 * lowered via the door interface. 157 * 158 * All other operations are allowed at any privilege level. 159 */ 160 #define IKE_PRIV_MINIMUM 0 161 #define IKE_PRIV_MODKEYS 1 162 #define IKE_PRIV_KEYMAT 2 163 #define IKE_PRIV_MAXIMUM 2 164 165 /* global ike stats formatting structure */ 166 typedef struct { 167 uint32_t st_init_p1_current; 168 uint32_t st_resp_p1_current; 169 uint32_t st_init_p1_total; 170 uint32_t st_resp_p1_total; 171 uint32_t st_init_p1_attempts; 172 uint32_t st_resp_p1_attempts; 173 uint32_t st_init_p1_noresp; /* failed; no response from peer */ 174 uint32_t st_init_p1_respfail; /* failed, but peer responded */ 175 uint32_t st_resp_p1_fail; 176 uint32_t st_reserved; 177 char st_pkcs11_libname[PATH_MAX]; 178 } ike_stats_t; 179 180 /* structure used to pass default values used by in.iked back to ikeadm */ 181 typedef struct { 182 uint32_t rule_p1_lifetime_secs; 183 uint32_t rule_p1_minlife; 184 uint32_t rule_p1_nonce_len; 185 uint32_t rule_p2_lifetime_secs; 186 uint32_t rule_p2_softlife_secs; 187 uint32_t rule_p2_idletime_secs; 188 uint32_t sys_p2_lifetime_secs; 189 uint32_t sys_p2_softlife_secs; 190 uint32_t sys_p2_idletime_secs; 191 uint32_t rule_p2_lifetime_kb; 192 uint32_t rule_p2_softlife_kb; 193 uint32_t sys_p2_lifetime_bytes; 194 uint32_t sys_p2_softlife_bytes; 195 uint32_t rule_p2_minlife; 196 uint32_t rule_p2_def_minlife; 197 uint32_t rule_p2_nonce_len; 198 uint32_t rule_p2_pfs; 199 uint32_t rule_p2_minsoft; 200 uint32_t rule_max_certs; 201 uint32_t rule_ike_port; 202 uint32_t rule_natt_port; 203 uint32_t defaults_reserved; /* For 64-bit alignment. */ 204 } ike_defaults_t; 205 206 /* data formatting structures for P1 SA dumps */ 207 typedef struct { 208 struct sockaddr_storage loc_addr; 209 struct sockaddr_storage rem_addr; 210 #define beg_iprange loc_addr 211 #define end_iprange rem_addr 212 } ike_addr_pr_t; 213 214 typedef struct { 215 uint64_t cky_i; 216 uint64_t cky_r; 217 } ike_cky_pr_t; 218 219 typedef struct { 220 ike_cky_pr_t p1hdr_cookies; 221 uint8_t p1hdr_major; 222 uint8_t p1hdr_minor; 223 uint8_t p1hdr_xchg; 224 uint8_t p1hdr_isinit; 225 uint32_t p1hdr_state; 226 boolean_t p1hdr_support_dpd; 227 dpd_status_t p1hdr_dpd_state; 228 uint64_t p1hdr_dpd_time; 229 } ike_p1_hdr_t; 230 231 /* values for p1hdr_xchg (aligned with RFC2408, section 3.1) */ 232 #define IKE_XCHG_NONE 0 233 #define IKE_XCHG_BASE 1 234 #define IKE_XCHG_IDENTITY_PROTECT 2 235 #define IKE_XCHG_AUTH_ONLY 3 236 #define IKE_XCHG_AGGRESSIVE 4 237 /* following not from RFC; used only for preshared key definitions */ 238 #define IKE_XCHG_IP_AND_AGGR 240 239 /* also not from RFC; used as wildcard */ 240 #define IKE_XCHG_ANY 256 241 242 /* values for p1hdr_state */ 243 #define IKE_SA_STATE_INVALID 0 244 #define IKE_SA_STATE_INIT 1 245 #define IKE_SA_STATE_SENT_SA 2 246 #define IKE_SA_STATE_SENT_KE 3 247 #define IKE_SA_STATE_SENT_LAST 4 248 #define IKE_SA_STATE_DONE 5 249 #define IKE_SA_STATE_DELETED 6 250 251 typedef struct { 252 uint16_t p1xf_dh_group; 253 uint16_t p1xf_encr_alg; 254 uint16_t p1xf_encr_low_bits; 255 uint16_t p1xf_encr_high_bits; 256 uint16_t p1xf_auth_alg; 257 uint16_t p1xf_auth_meth; 258 uint16_t p1xf_prf; 259 uint16_t p1xf_pfs; 260 uint32_t p1xf_max_secs; 261 uint32_t p1xf_max_kbytes; 262 uint32_t p1xf_max_keyuses; 263 uint32_t p1xf_reserved; /* Alignment to 64-bit. */ 264 } ike_p1_xform_t; 265 266 /* values for p1xf_dh_group (aligned with RFC2409, Appendix A) */ 267 #define IKE_GRP_DESC_MODP_768 1 268 #define IKE_GRP_DESC_MODP_1024 2 269 #define IKE_GRP_DESC_EC2N_155 3 270 #define IKE_GRP_DESC_EC2N_185 4 271 /* values for p1xf_dh_group (aligned with RFC3526) */ 272 #define IKE_GRP_DESC_MODP_1536 5 273 #define IKE_GRP_DESC_MODP_2048 14 274 #define IKE_GRP_DESC_MODP_3072 15 275 #define IKE_GRP_DESC_MODP_4096 16 276 #define IKE_GRP_DESC_MODP_6144 17 277 #define IKE_GRP_DESC_MODP_8192 18 278 279 /* values for p1xf_auth_meth (aligned with RFC2409, Appendix A) */ 280 #define IKE_AUTH_METH_PRE_SHARED_KEY 1 281 #define IKE_AUTH_METH_DSS_SIG 2 282 #define IKE_AUTH_METH_RSA_SIG 3 283 #define IKE_AUTH_METH_RSA_ENCR 4 284 #define IKE_AUTH_METH_RSA_ENCR_REVISED 5 285 286 /* values for p1xf_prf */ 287 #define IKE_PRF_NONE 0 288 #define IKE_PRF_HMAC_MD5 1 289 #define IKE_PRF_HMAC_SHA1 2 290 #define IKE_PRF_HMAC_SHA256 5 291 #define IKE_PRF_HMAC_SHA384 6 292 #define IKE_PRF_HMAC_SHA512 7 293 294 typedef struct { 295 /* 296 * NOTE: the new and del counters count the actual number of SAs, 297 * not the number of "suites", as defined in the ike monitoring 298 * mib draft; we do this because we don't have a good way of 299 * tracking the deletion of entire suites (we're notified of 300 * deleted qm sas individually). 301 */ 302 uint32_t p1stat_new_qm_sas; 303 uint32_t p1stat_del_qm_sas; 304 uint64_t p1stat_start; 305 uint32_t p1stat_kbytes; 306 uint32_t p1stat_keyuses; 307 } ike_p1_stats_t; 308 309 typedef struct { 310 uint32_t p1err_decrypt; 311 uint32_t p1err_hash; 312 uint32_t p1err_otherrx; 313 uint32_t p1err_tx; 314 } ike_p1_errors_t; 315 316 typedef struct { 317 uint32_t p1key_type; 318 uint32_t p1key_len; 319 /* 320 * followed by (len - sizeof (ike_p1_key_t)) bytes of hex data, 321 * 64-bit aligned (pad bytes are added at the end, if necessary, 322 * and NOT INCLUDED in the len value, which reflects the actual 323 * key size). 324 */ 325 } ike_p1_key_t; 326 327 /* key info types for ike_p1_key_t struct */ 328 #define IKE_KEY_PRESHARED 1 329 #define IKE_KEY_SKEYID 2 330 #define IKE_KEY_SKEYID_D 3 331 #define IKE_KEY_SKEYID_A 4 332 #define IKE_KEY_SKEYID_E 5 333 #define IKE_KEY_ENCR 6 334 #define IKE_KEY_IV 7 335 336 typedef struct { 337 ike_p1_hdr_t p1sa_hdr; 338 ike_p1_xform_t p1sa_xform; 339 ike_addr_pr_t p1sa_ipaddrs; 340 uint16_t p1sa_stat_off; 341 uint16_t p1sa_stat_len; 342 uint16_t p1sa_error_off; 343 uint16_t p1sa_error_len; 344 uint16_t p1sa_localid_off; 345 uint16_t p1sa_localid_len; 346 uint16_t p1sa_remoteid_off; 347 uint16_t p1sa_remoteid_len; 348 uint16_t p1sa_key_off; 349 uint16_t p1sa_key_len; 350 uint32_t p1sa_reserved; 351 /* 352 * variable-length structures will be included here, as 353 * indicated by offset/length fields. 354 * stats and errors will be formatted as ike_p1_stats_t and 355 * ike_p1_errors_t, respectively. 356 * key info will be formatted as a series of p1_key_t structs. 357 * local/remote ids will be formatted as sadb_ident_t structs. 358 */ 359 } ike_p1_sa_t; 360 361 362 #define MAX_LABEL_LEN 256 363 364 365 /* data formatting structure for policy (rule) dumps */ 366 367 typedef struct { 368 char rule_label[MAX_LABEL_LEN]; 369 uint32_t rule_kmcookie; 370 uint16_t rule_ike_mode; 371 uint16_t rule_local_idtype; /* SADB_IDENTTYPE_* value */ 372 uint32_t rule_p1_nonce_len; 373 uint32_t rule_p2_nonce_len; 374 uint32_t rule_p2_pfs; 375 uint32_t rule_p2_lifetime_secs; 376 uint32_t rule_p2_softlife_secs; 377 uint32_t rule_p2_idletime_secs; 378 uint32_t rule_p2_lifetime_kb; 379 uint32_t rule_p2_softlife_kb; 380 uint16_t rule_xform_cnt; 381 uint16_t rule_xform_off; 382 uint16_t rule_locip_cnt; 383 uint16_t rule_locip_off; 384 uint16_t rule_remip_cnt; 385 uint16_t rule_remip_off; 386 uint16_t rule_locid_inclcnt; 387 uint16_t rule_locid_exclcnt; 388 uint16_t rule_locid_off; 389 uint16_t rule_remid_inclcnt; 390 uint16_t rule_remid_exclcnt; 391 uint16_t rule_remid_off; 392 /* 393 * Followed by several lists of variable-length structures, described 394 * by counts and offsets: 395 * transforms ike_p1_xform_t structs 396 * ranges of local ip addrs ike_addr_pr_t structs 397 * ranges of remote ip addrs ike_addr_pr_t structs 398 * local identification strings null-terminated ascii strings 399 * remote identification strings null-terminated ascii strings 400 */ 401 } ike_rule_t; 402 403 404 /* 405 * data formatting structure for preshared keys 406 * ps_ike_mode field uses the IKE_XCHG_* defs 407 */ 408 typedef struct { 409 ike_addr_pr_t ps_ipaddrs; 410 uint16_t ps_ike_mode; 411 uint16_t ps_localid_off; 412 uint16_t ps_localid_len; 413 uint16_t ps_remoteid_off; 414 uint16_t ps_remoteid_len; 415 uint16_t ps_key_off; 416 uint16_t ps_key_len; 417 uint16_t ps_key_bits; 418 /* 419 * followed by variable-length structures, as indicated by 420 * offset/length fields. 421 * key info will be formatted as an array of bytes. 422 * local/remote ids will be formatted as sadb_ident_t structs. 423 */ 424 } ike_ps_t; 425 426 #define DN_MAX 1024 427 #define CERT_OFF_WIRE -1 428 #define CERT_NO_PRIVKEY 0 429 #define CERT_PRIVKEY_LOCKED 1 430 #define CERT_PRIVKEY_AVAIL 2 431 432 /* 433 * data formatting structure for cached certs 434 */ 435 typedef struct { 436 uint32_t cache_id; 437 uint32_t class; 438 int linkage; 439 uint32_t certcache_padding; /* For 64-bit alignment. */ 440 char subject[DN_MAX]; 441 char issuer[DN_MAX]; 442 } ike_certcache_t; 443 444 /* identification types */ 445 #define IKE_ID_IDENT_PAIR 1 446 #define IKE_ID_ADDR_PAIR 2 447 #define IKE_ID_CKY_PAIR 3 448 #define IKE_ID_LABEL 4 449 450 451 /* locations for read/write requests */ 452 #define IKE_RW_LOC_DEFAULT 1 453 #define IKE_RW_LOC_USER_SPEC 2 454 455 456 /* door interface error codes */ 457 #define IKE_ERR_NO_OBJ 1 /* nothing found to match the request */ 458 #define IKE_ERR_NO_DESC 2 /* fd was required with this request */ 459 #define IKE_ERR_ID_INVALID 3 /* invalid id info was provided */ 460 #define IKE_ERR_LOC_INVALID 4 /* invalid location info was provided */ 461 #define IKE_ERR_CMD_INVALID 5 /* invalid command was provided */ 462 #define IKE_ERR_DATA_INVALID 6 /* invalid data was provided */ 463 #define IKE_ERR_CMD_NOTSUP 7 /* unsupported command */ 464 #define IKE_ERR_REQ_INVALID 8 /* badly formatted request */ 465 #define IKE_ERR_NO_PRIV 9 /* privilege level not high enough */ 466 #define IKE_ERR_SYS_ERR 10 /* syserr occurred while processing */ 467 #define IKE_ERR_DUP_IGNORED 11 /* attempt to add a duplicate entry */ 468 #define IKE_ERR_NO_TOKEN 12 /* cannot login into pkcs#11 token */ 469 #define IKE_ERR_NO_AUTH 13 /* not authorized */ 470 #define IKE_ERR_IN_PROGRESS 14 /* operation already in progress */ 471 #define IKE_ERR_NO_MEM 15 /* insufficient memory */ 472 473 474 /* 475 * IKE_SVC_GET_DBG 476 * Used to request the current debug level. 477 * 478 * Upon request, dbg_level is 0 (don't care). 479 * 480 * Upon return, dbg_level contains the current value. 481 * 482 * 483 * IKE_SVC_SET_DBG 484 * Used to request modification of the debug level. 485 * 486 * Upon request, dbg_level contains desired level. If debug output is 487 * to be directed to a different file, the fd should be passed in the 488 * door_desc_t field of the door_arg_t param. NOTE: if the daemon is 489 * currently running in the background with no debug set, an output 490 * file MUST be given. 491 * 492 * Upon return, dbg_level contains the old debug level, and acknowledges 493 * successful completion of the request. If an error is encountered, 494 * ike_err_t is returned instead, with appropriate error value and cmd 495 * IKE_SVC_ERROR. 496 */ 497 typedef struct { 498 ike_svccmd_t cmd; 499 uint32_t dbg_level; 500 } ike_dbg_t; 501 502 /* 503 * IKE_SVC_GET_PRIV 504 * Used to request the current privilege level. 505 * 506 * Upon request, priv_level is 0 (don't care). 507 * 508 * Upon return, priv_level contains the current value. 509 * 510 * 511 * IKE_SVC_SET_PRIV 512 * Used to request modification of the privilege level. 513 * 514 * Upon request, priv_level contains the desired level. The level may 515 * only be lowered via the door interface; it cannot be raised. Thus, 516 * if in.iked is started at the lowest level, it cannot be changed. 517 * 518 * Upon return, priv_level contains the old privilege level, and 519 * acknowledges successful completion of the request. If an error is 520 * encountered, ike_err_t is returned instead, with appropriate error 521 * value and cmd IKE_SVC_ERROR. 522 */ 523 typedef struct { 524 ike_svccmd_t cmd; 525 uint32_t priv_level; 526 } ike_priv_t; 527 528 529 /* 530 * IKE_SVC_GET_STATS 531 * Used to request current statistics on Phase 1 SA creation and 532 * failures. The statistics represent all activity in in.iked. 533 * 534 * Upon request, cmd is set, and stat_len does not matter. 535 * 536 * Upon successful return, stat_len contains the total size of the 537 * returned buffer, which contains first the ike_statreq_t struct, 538 * followed by the stat data in the ike_stats_t structure. In case 539 * of an error in processing the request, ike_err_t is returned with 540 * IKE_SVC_ERROR command and appropriate error code. 541 */ 542 typedef struct { 543 ike_svccmd_t cmd; 544 uint32_t stat_len; 545 } ike_statreq_t; 546 547 /* 548 * IKE_SVC_GET_DEFS 549 * Used to request default values from in.iked. 550 * 551 * Upon request, cmd is set, and stat_len does not matter. 552 * 553 * Upon successful return, stat_len contains the total size of the 554 * returned buffer, this contains a pair of ike_defaults_t's. 555 */ 556 typedef struct { 557 ike_svccmd_t cmd; 558 uint32_t stat_len; 559 uint32_t version; 560 uint32_t defreq_reserved; /* For 64-bit alignment. */ 561 } ike_defreq_t; 562 563 /* 564 * IKE_SVC_DUMP_{P1S|RULES|PS|CERTCACHE} 565 * Used to request a table dump, and to return info for a single table 566 * item. The expectation is that all of the table data will be passed 567 * through the door, one entry at a time; an individual request must be 568 * sent for each entry, however (the door server can't send unrequested 569 * data). 570 * 571 * Upon request: cmd is set, and dump_next contains the item number 572 * requested (0 for first request). dump_len is 0; no data follows. 573 * 574 * Upon return: cmd is set, and dump_next contains the item number of 575 * the *next* item in the table (to be used in the subsequent request). 576 * dump_next = 0 indicates that this is the last item in the table. 577 * dump_len is the total length (data + struct) returned. Data is 578 * formatted as indicated by the cmd type: 579 * IKE_SVC_DUMP_P1S: ike_p1_sa_t 580 * IKE_SVC_DUMP_RULES: ike_rule_t 581 * IKE_SVC_DUMP_PS: ike_ps_t 582 * IKE_SVC_DUMP_CERTCACHE: ike_certcache_t 583 */ 584 typedef struct { 585 ike_svccmd_t cmd; 586 uint32_t dump_len; 587 union { 588 struct { 589 uint32_t dump_unext; 590 uint32_t dump_ureserved; 591 } dump_actual; 592 uint64_t dump_alignment; 593 } dump_u; 594 #define dump_next dump_u.dump_actual.dump_unext 595 #define dump_reserved dump_u.dump_actual.dump_ureserved 596 /* dump_len - sizeof (ike_dump_t) bytes of data included here */ 597 } ike_dump_t; 598 599 600 /* 601 * IKE_SVC_GET_{P1|RULE|PS} 602 * Used to request and return individual table items. 603 * 604 * Upon request: get_len is the total msg length (struct + id data); 605 * get_idtype indicates the type of identification being used. 606 * IKE_SVC_GET_P1: ike_addr_pr_t or ike_cky_pr_t 607 * IKE_SVC_GET_RULE: char string (label) 608 * IKE_SVC_GET_PS: ike_addr_pr_t or pair of sadb_ident_t 609 * 610 * Upon return: get_len is the total size (struct + data), get_idtype 611 * is unused, and the data that follows is formatted according to cmd: 612 * IKE_SVC_GET_P1: ike_p1_sa_t 613 * IKE_SVC_GET_RULE: ike_rule_t 614 * IKE_SVC_GET_PS: ike_ps_t 615 */ 616 typedef struct { 617 ike_svccmd_t cmd; 618 uint32_t get_len; 619 union { 620 struct { 621 uint32_t getu_idtype; 622 uint32_t getu_reserved; 623 } get_actual; 624 uint64_t get_alignment; 625 } get_u; 626 #define get_idtype get_u.get_actual.getu_idtype 627 #define get_reserved get_u.get_actual.getu_reserved 628 /* get_len - sizeof (ike_get_t) bytes of data included here */ 629 } ike_get_t; 630 631 632 /* 633 * IKE_SVC_NEW_{RULE|PS} 634 * Used to request and acknowledge insertion of a table item. 635 * 636 * Upon request: new_len is the total (data + struct) size passed, or 0. 637 * new_len = 0 => a door_desc_t is also included with a file descriptor 638 * for a file containing the data to be added. The file should include 639 * a single item: a rule, or a pre-shared key. For new_len != 0, the 640 * data is formatted according to the cmd type: 641 * IKE_SVC_NEW_RULE: ike_rule_t 642 * IKE_SVC_NEW_PS: ike_ps_t 643 * 644 * Upon return: new_len is 0; simply acknowledges successful insertion 645 * of the requested item. If insertion is not successful, ike_err_t is 646 * returned instead with appropriate error value. 647 */ 648 typedef struct { 649 ike_svccmd_t cmd; 650 uint32_t new_len; 651 /* new_len - sizeof (ike_new_t) bytes included here */ 652 uint64_t new_align; /* Padding for 64-bit alignment. */ 653 } ike_new_t; 654 655 656 /* 657 * IKE_SVC_DEL_{P1|RULE|PS} 658 * Used to request and acknowledge the deletion of an individual table 659 * item. 660 * 661 * Upon request: del_len is the total msg length (struct + id data); 662 * del_idtype indicates the type of identification being used. 663 * IKE_SVC_DEL_P1: ike_addr_pr_t or ike_cky_pr_t 664 * IKE_SVC_DEL_RULE: char string (label) 665 * IKE_SVC_DEL_PS: ike_addr_pr_t or pair of sadb_ident_t 666 * 667 * Upon return: acknowledges deletion of the requested item; del_len and 668 * del_idtype are unspecified. If deletion is not successful, ike_err_t 669 * is returned instead with appropriate error value. 670 */ 671 typedef struct { 672 ike_svccmd_t cmd; 673 uint32_t del_len; 674 uint32_t del_idtype; 675 uint32_t del_reserved; 676 /* del_len - sizeof (ike_del_t) bytes of data included here. */ 677 } ike_del_t; 678 679 680 /* 681 * IKE_SVC_READ_{RULES|PS} 682 * Used to ask daemon to re-read particular configuration info. 683 * 684 * Upon request: rw_loc indicates where the info should be read from: 685 * either from a user-supplied file descriptor(s), or from the default 686 * location(s). If rw_loc indicates user-supplied location, the file 687 * descriptor(s) should be passed in the door_desc_t struct. For the 688 * IKE_SVC_READ_RULES cmd, two file descriptors should be specified: 689 * first, one for the config file which contains the data to be read, 690 * and second, one for the cookie file which will be written to as 691 * in.iked process the config file. 692 * 693 * Upon return: rw_loc is unspecified; the message simply acknowledges 694 * successful completion of the request. If an error occurred, 695 * ike_err_t is returned instead with appropriate error value. 696 * 697 * 698 * IKE_SVC_WRITE_{RULES|PS} 699 * Used to ask daemon to write its current config info to files. 700 * 701 * Request and return are handled the same as for the IKE_SVC_READ_* 702 * cmds; however, the rw_loc MUST be a user-supplied location. Also, 703 * for the IKE_SVC_WRITE_RULES cmd, the cookie file fd is not required; 704 * only a single fd, for the file to which the config info should be 705 * written, should be passed in. 706 */ 707 typedef struct { 708 ike_svccmd_t cmd; 709 uint32_t rw_loc; 710 } ike_rw_t; 711 712 713 /* 714 * IKE_SVC_FLUSH_P1S 715 * IKE_SVC_FLUSH_CERTCACHE 716 * 717 * Used to request and acknowledge tear-down of all P1 SAs 718 * or to flush the certificate cache. 719 */ 720 typedef struct { 721 ike_svccmd_t cmd; 722 } ike_flush_t; 723 724 725 #ifndef PKCS11_TOKSIZE 726 #define PKCS11_TOKSIZE 32 727 #endif 728 #define MAX_PIN_LEN 256 729 /* 730 * IKE_SVC_SET_PIN 731 * IKE_SVC_DEL_PIN 732 * 733 * Used to supply a pin for a PKCS#11 tokenj object. 734 * 735 */ 736 typedef struct { 737 ike_svccmd_t cmd; 738 uint32_t pin_reserved; /* For 64-bit alignment. */ 739 char pkcs11_token[PKCS11_TOKSIZE]; 740 uchar_t token_pin[MAX_PIN_LEN]; 741 } ike_pin_t; 742 743 /* 744 * IKE_SVC_ERROR 745 * Used on return if server encountered an error while processing 746 * the request. An appropriate error code is included (as defined 747 * in this header file); in the case of IKE_ERR_SYS_ERR, a value 748 * from the UNIX errno space is included in the ike_err_unix field. 749 */ 750 typedef struct { 751 ike_svccmd_t cmd; 752 uint32_t ike_err; 753 uint32_t ike_err_unix; 754 uint32_t ike_err_reserved; 755 } ike_err_t; 756 757 /* 758 * Generic type for use when the request/reply type is unknown 759 */ 760 typedef struct { 761 ike_svccmd_t cmd; 762 } ike_cmd_t; 763 764 765 /* 766 * Union containing all possible request/return structures. 767 */ 768 typedef union { 769 ike_cmd_t svc_cmd; 770 ike_dbg_t svc_dbg; 771 ike_priv_t svc_priv; 772 ike_statreq_t svc_stats; 773 ike_dump_t svc_dump; 774 ike_get_t svc_get; 775 ike_new_t svc_new; 776 ike_del_t svc_del; 777 ike_rw_t svc_rw; 778 ike_flush_t svc_flush; 779 ike_pin_t svc_pin; 780 ike_err_t svc_err; 781 ike_defreq_t svc_defaults; 782 } ike_service_t; 783 784 #ifdef __cplusplus 785 } 786 #endif 787 788 #endif /* _IKEDOOR_H */ 789