1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright (c) 1999-2001 by Sun Microsystems, Inc. 24*0Sstevel@tonic-gate * All rights reserved. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _PACKET_H 28*0Sstevel@tonic-gate #define _PACKET_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #include <sys/types.h> 33*0Sstevel@tonic-gate #include <sys/sysmacros.h> /* MIN, MAX, ... */ 34*0Sstevel@tonic-gate #include <netinet/in.h> 35*0Sstevel@tonic-gate #include <netinet/dhcp.h> 36*0Sstevel@tonic-gate #include <dhcp_impl.h> 37*0Sstevel@tonic-gate 38*0Sstevel@tonic-gate #include "agent.h" 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate /* 41*0Sstevel@tonic-gate * packet.[ch] contain routines for manipulating, setting, and 42*0Sstevel@tonic-gate * transmitting DHCP/BOOTP packets. see packet.c for descriptions on 43*0Sstevel@tonic-gate * how to use the exported functions. 44*0Sstevel@tonic-gate */ 45*0Sstevel@tonic-gate 46*0Sstevel@tonic-gate #ifdef __cplusplus 47*0Sstevel@tonic-gate extern "C" { 48*0Sstevel@tonic-gate #endif 49*0Sstevel@tonic-gate 50*0Sstevel@tonic-gate struct ifslist; /* forward declaration */ 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gate /* 53*0Sstevel@tonic-gate * data type for recv_pkt(). needed because we may want to wait for 54*0Sstevel@tonic-gate * several kinds of packets at once, and the existing enumeration of 55*0Sstevel@tonic-gate * DHCP packet types does not provide a way to do that easily. here, 56*0Sstevel@tonic-gate * we light a different bit in the enumeration for each type of packet 57*0Sstevel@tonic-gate * we want to receive. 58*0Sstevel@tonic-gate */ 59*0Sstevel@tonic-gate 60*0Sstevel@tonic-gate typedef enum { 61*0Sstevel@tonic-gate 62*0Sstevel@tonic-gate DHCP_PUNTYPED = 0x001, /* untyped (BOOTP) message */ 63*0Sstevel@tonic-gate DHCP_PDISCOVER = 0x002, 64*0Sstevel@tonic-gate DHCP_POFFER = 0x004, 65*0Sstevel@tonic-gate DHCP_PREQUEST = 0x008, 66*0Sstevel@tonic-gate DHCP_PDECLINE = 0x010, 67*0Sstevel@tonic-gate DHCP_PACK = 0x020, 68*0Sstevel@tonic-gate DHCP_PNAK = 0x040, 69*0Sstevel@tonic-gate DHCP_PRELEASE = 0x080, 70*0Sstevel@tonic-gate DHCP_PINFORM = 0x100 71*0Sstevel@tonic-gate 72*0Sstevel@tonic-gate } dhcp_message_type_t; 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate /* 75*0Sstevel@tonic-gate * a dhcp_pkt_t is (right now) what is used by the packet manipulation 76*0Sstevel@tonic-gate * functions. while the structure is not strictly necessary, it allows 77*0Sstevel@tonic-gate * a better separation of functionality since metadata about the packet 78*0Sstevel@tonic-gate * (such as its current length) is stored along with the packet. 79*0Sstevel@tonic-gate */ 80*0Sstevel@tonic-gate 81*0Sstevel@tonic-gate typedef struct dhcp_pkt { 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate PKT *pkt; /* the real underlying packet */ 84*0Sstevel@tonic-gate unsigned int pkt_max_len; /* its maximum length */ 85*0Sstevel@tonic-gate unsigned int pkt_cur_len; /* its current length */ 86*0Sstevel@tonic-gate 87*0Sstevel@tonic-gate } dhcp_pkt_t; 88*0Sstevel@tonic-gate 89*0Sstevel@tonic-gate /* 90*0Sstevel@tonic-gate * a `stop_func_t' is used by parts of dhcpagent that use the 91*0Sstevel@tonic-gate * retransmission capability of send_pkt(). this makes it so the 92*0Sstevel@tonic-gate * callers of send_pkt() decide when to stop retransmitting, which 93*0Sstevel@tonic-gate * makes more sense than hardcoding their instance-specific cases into 94*0Sstevel@tonic-gate * packet.c 95*0Sstevel@tonic-gate */ 96*0Sstevel@tonic-gate 97*0Sstevel@tonic-gate typedef boolean_t stop_func_t(struct ifslist *, unsigned int); 98*0Sstevel@tonic-gate 99*0Sstevel@tonic-gate dhcp_pkt_t *init_pkt(struct ifslist *, uchar_t); 100*0Sstevel@tonic-gate void add_pkt_opt(dhcp_pkt_t *, uchar_t, const void *, uchar_t); 101*0Sstevel@tonic-gate void add_pkt_opt16(dhcp_pkt_t *, uchar_t, uint16_t); 102*0Sstevel@tonic-gate void add_pkt_opt32(dhcp_pkt_t *, uchar_t, uint32_t); 103*0Sstevel@tonic-gate void free_pkt_list(PKT_LIST **); 104*0Sstevel@tonic-gate void remove_from_pkt_list(PKT_LIST **, PKT_LIST *); 105*0Sstevel@tonic-gate void stop_pkt_retransmission(struct ifslist *); 106*0Sstevel@tonic-gate int recv_pkt(struct ifslist *, int, dhcp_message_type_t, boolean_t); 107*0Sstevel@tonic-gate int send_pkt(struct ifslist *, dhcp_pkt_t *, in_addr_t, 108*0Sstevel@tonic-gate stop_func_t *); 109*0Sstevel@tonic-gate void get_pkt_times(PKT_LIST *, uint32_t *, uint32_t *, uint32_t *); 110*0Sstevel@tonic-gate 111*0Sstevel@tonic-gate #ifdef __cplusplus 112*0Sstevel@tonic-gate } 113*0Sstevel@tonic-gate #endif 114*0Sstevel@tonic-gate 115*0Sstevel@tonic-gate #endif /* _PACKET_H */ 116