10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 52187Smeem * Common Development and Distribution License (the "License"). 62187Smeem * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*3431Scarlsonj * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef AGENT_H 270Sstevel@tonic-gate #define AGENT_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #include <sys/types.h> 320Sstevel@tonic-gate #include <libinetutil.h> 33*3431Scarlsonj #include <dhcpagent_ipc.h> 340Sstevel@tonic-gate 350Sstevel@tonic-gate /* 360Sstevel@tonic-gate * agent.h contains general symbols that should be available to all 370Sstevel@tonic-gate * source programs that are part of the agent. in general, files 380Sstevel@tonic-gate * specific to a given collection of code (such as interface.h or 390Sstevel@tonic-gate * dhcpmsg.h) are to be preferred to this dumping ground. use only 400Sstevel@tonic-gate * when necessary. 410Sstevel@tonic-gate */ 420Sstevel@tonic-gate 430Sstevel@tonic-gate #ifdef __cplusplus 440Sstevel@tonic-gate extern "C" { 450Sstevel@tonic-gate #endif 460Sstevel@tonic-gate 470Sstevel@tonic-gate /* 480Sstevel@tonic-gate * global variables: `tq' and `eh' represent the global timer queue 490Sstevel@tonic-gate * and event handler, as described in the README. `class_id' is our 500Sstevel@tonic-gate * vendor class id set early on in main(). `inactivity_id' is the 510Sstevel@tonic-gate * timer id of the global inactivity timer, which shuts down the agent 52*3431Scarlsonj * if there are no state machines to manage for DHCP_INACTIVITY_WAIT 530Sstevel@tonic-gate * seconds. `grandparent' is the pid of the original process when in 542546Scarlsonj * adopt mode. `rtsock_fd' is the global routing socket file descriptor. 550Sstevel@tonic-gate */ 560Sstevel@tonic-gate 570Sstevel@tonic-gate extern iu_tq_t *tq; 580Sstevel@tonic-gate extern iu_eh_t *eh; 590Sstevel@tonic-gate extern char *class_id; 600Sstevel@tonic-gate extern int class_id_len; 610Sstevel@tonic-gate extern iu_timer_id_t inactivity_id; 620Sstevel@tonic-gate extern pid_t grandparent; 632546Scarlsonj extern int rtsock_fd; 640Sstevel@tonic-gate 650Sstevel@tonic-gate boolean_t drain_script(iu_eh_t *, void *); 66*3431Scarlsonj boolean_t check_cmd_allowed(DHCPSTATE, dhcp_ipc_type_t); 670Sstevel@tonic-gate 680Sstevel@tonic-gate /* 690Sstevel@tonic-gate * global tunable parameters. an `I' in the preceding comment indicates 700Sstevel@tonic-gate * an implementation artifact; a `R' in the preceding comment indicates 710Sstevel@tonic-gate * that the value was suggested (or required) by RFC2131. 720Sstevel@tonic-gate */ 730Sstevel@tonic-gate 740Sstevel@tonic-gate /* I: how many seconds to wait before restarting DHCP on an interface */ 750Sstevel@tonic-gate #define DHCP_RESTART_WAIT 10 760Sstevel@tonic-gate 770Sstevel@tonic-gate /* 780Sstevel@tonic-gate * I: the maximum number of milliseconds to wait before SELECTING on an 790Sstevel@tonic-gate * interface. RFC2131 recommends a random wait of between one and ten seconds, 800Sstevel@tonic-gate * to speed up DHCP at boot we wait between zero and two seconds. 810Sstevel@tonic-gate */ 820Sstevel@tonic-gate #define DHCP_SELECT_WAIT 2000 830Sstevel@tonic-gate 840Sstevel@tonic-gate /* R: how many seconds before lease expiration we give up trying to rebind */ 850Sstevel@tonic-gate #define DHCP_REBIND_MIN 60 860Sstevel@tonic-gate 870Sstevel@tonic-gate /* I: seconds to wait retrying dhcp_expire() if uncancellable async event */ 880Sstevel@tonic-gate #define DHCP_EXPIRE_WAIT 10 890Sstevel@tonic-gate 900Sstevel@tonic-gate /* R: approximate percentage of lease time to wait until RENEWING state */ 910Sstevel@tonic-gate #define DHCP_T1_FACT .5 920Sstevel@tonic-gate 930Sstevel@tonic-gate /* R: approximate percentage of lease time to wait until REBINDING state */ 940Sstevel@tonic-gate #define DHCP_T2_FACT .875 950Sstevel@tonic-gate 960Sstevel@tonic-gate /* I: number of REQUEST attempts before assuming something is awry */ 970Sstevel@tonic-gate #define DHCP_MAX_REQUESTS 4 980Sstevel@tonic-gate 990Sstevel@tonic-gate /* I: epsilon in seconds used to check if old and new lease times are same */ 1000Sstevel@tonic-gate #define DHCP_LEASE_EPS 30 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate /* I: if lease is not being extended, seconds left before alerting user */ 1032187Smeem #define DHCP_LEASE_ERROR_THRESH (60*60) /* one hour */ 1040Sstevel@tonic-gate 1050Sstevel@tonic-gate /* I: how many seconds before bailing out if there's no work to do */ 1060Sstevel@tonic-gate #define DHCP_INACTIVITY_WAIT (60*3) /* three minutes */ 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate /* I: the maximum amount of seconds we use an adopted lease */ 1090Sstevel@tonic-gate #define DHCP_ADOPT_LEASE_MAX (60*60) /* one hour */ 1100Sstevel@tonic-gate 1110Sstevel@tonic-gate /* I: number of seconds grandparent waits for child to finish adoption. */ 1120Sstevel@tonic-gate #define DHCP_ADOPT_SLEEP 30 1130Sstevel@tonic-gate 1140Sstevel@tonic-gate /* I: the maximum amount of milliseconds to wait for an ipc request */ 1150Sstevel@tonic-gate #define DHCP_IPC_REQUEST_WAIT (3*1000) /* three seconds */ 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate /* 118*3431Scarlsonj * DHCPv6 timer and retransmit values from RFC 3315. 119*3431Scarlsonj */ 120*3431Scarlsonj #define DHCPV6_SOL_MAX_DELAY 1000 /* Max delay of first Solicit; 1s */ 121*3431Scarlsonj #define DHCPV6_CNF_MAX_DELAY 1000 /* Max delay of first Confirm; 1s */ 122*3431Scarlsonj #define DHCPV6_INF_MAX_DELAY 1000 /* Max delay of first Info-req; 1s */ 123*3431Scarlsonj #define DHCPV6_SOL_TIMEOUT 1000 /* Initial Solicit timeout; 1s */ 124*3431Scarlsonj #define DHCPV6_REQ_TIMEOUT 1000 /* Initial Request timeout; 1s */ 125*3431Scarlsonj #define DHCPV6_CNF_TIMEOUT 1000 /* Initial Confirm timeout; 1s */ 126*3431Scarlsonj #define DHCPV6_REN_TIMEOUT 10000 /* Initial Renew timeout; 10s */ 127*3431Scarlsonj #define DHCPV6_REB_TIMEOUT 10000 /* Initial Rebind timeout; 10s */ 128*3431Scarlsonj #define DHCPV6_INF_TIMEOUT 1000 /* Initial Info-req timeout; 1s */ 129*3431Scarlsonj #define DHCPV6_REL_TIMEOUT 1000 /* Initial Release timeout; 1s */ 130*3431Scarlsonj #define DHCPV6_DEC_TIMEOUT 1000 /* Initial Decline timeout; 1s */ 131*3431Scarlsonj #define DHCPV6_SOL_MAX_RT 120000 /* Max Solicit timeout; 2m */ 132*3431Scarlsonj #define DHCPV6_REQ_MAX_RT 30000 /* Max Request timeout; 30s */ 133*3431Scarlsonj #define DHCPV6_CNF_MAX_RT 4000 /* Max Confirm timeout; 4s */ 134*3431Scarlsonj #define DHCPV6_REN_MAX_RT 600000 /* Max Renew timeout; 5m */ 135*3431Scarlsonj #define DHCPV6_REB_MAX_RT 600000 /* Max Rebind timeout; 5m */ 136*3431Scarlsonj #define DHCPV6_INF_MAX_RT 120000 /* Max Info-req timeout; 2m */ 137*3431Scarlsonj #define DHCPV6_CNF_MAX_RD 10000 /* Max Confirm duration; 10s */ 138*3431Scarlsonj #define DHCPV6_REQ_MAX_RC 10 /* Max Request attempts */ 139*3431Scarlsonj #define DHCPV6_REL_MAX_RC 5 /* Max Release attempts */ 140*3431Scarlsonj #define DHCPV6_DEC_MAX_RC 5 /* Max Decline attempts */ 141*3431Scarlsonj 142*3431Scarlsonj /* 1430Sstevel@tonic-gate * reasons for why iu_handle_events() returned 1440Sstevel@tonic-gate */ 1450Sstevel@tonic-gate enum { DHCP_REASON_INACTIVITY, DHCP_REASON_SIGNAL, DHCP_REASON_TERMINATE }; 1460Sstevel@tonic-gate 1470Sstevel@tonic-gate #ifdef __cplusplus 1480Sstevel@tonic-gate } 1490Sstevel@tonic-gate #endif 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate #endif /* AGENT_H */ 152