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 _INTERFACES_H
27 #define _INTERFACES_H
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 #define DSRVR_NUM_DESC 3 /* Number of socket descriptors */
34 typedef enum {
35 DSRVR_LBCAST = 0, /* Limited broadcast recv descriptor */
36 DSRVR_DBCAST = 1, /* Directed broadcast recv descriptor */
37 DSRVR_UCAST = 2 /* Unicast send/recv descriptor */
38 } dsrvr_socktype_t;
39
40 typedef struct interfaces {
41 char nm[IFNAMSIZ]; /* Interface name */
42 unsigned int ifceno; /* Interface index */
43 short mtu; /* MTU of interface */
44 int descs[DSRVR_NUM_DESC]; /* recv/send sockets */
45 uint_t flags; /* interface flags */
46 struct in_addr bcast; /* interface broadcast */
47 struct in_addr mask; /* interface netmask */
48 struct in_addr addr; /* interface IP addr */
49 ENCODE *ecp; /* IF specific options */
50 uint_t transmit; /* # of transmitted pkts */
51 uint_t received; /* # of received pkts */
52 uint_t duplicate; /* # of duplicate pkts */
53 uint_t dropped; /* # of dropped pkts */
54 uint_t expired; /* # of expired pkts */
55 uint_t errors; /* # of protocol errors */
56 uint_t processed; /* # of processed pkts */
57 uint_t offers; /* # of pending offers */
58 thread_t if_thread; /* rcv service thread */
59 int thr_exit; /* sent when time to exit */
60 mutex_t ifp_mtx; /* mutex lock on this struct */
61 struct interfaces *next;
62 } IF;
63
64 #define DHCP_MON_SYSERRS 30 /* Max allowable interface errors */
65 #define DHCP_MON_ERRINTVL 1 /* Time interval for IF errors (secs) */
66 #define DHCP_MON_THRESHOLD 6 /* Max allowable pending pkts pcd */
67
68 /*
69 * Pause interval (mins) if IF error threshold reached.
70 */
71 #define DHCP_MON_SLEEP 5
72
73 extern IF *if_head; /* head of monitored interfaces */
74 extern mutex_t if_head_mtx; /* lock to protect interfaces list */
75 extern char *interfaces; /* list of user-requested interfaces. */
76 extern int open_interfaces(void);
77 extern int write_interface(IF *, PKT *, int, struct sockaddr_in *);
78 extern void close_interfaces(void);
79 extern void detach_plp(dsvc_clnt_t *, PKT_LIST *);
80 extern void free_pktlist(dsvc_clnt_t *);
81 extern PKT_LIST *refresh_pktlist(dsvc_clnt_t *, PKT_LIST *);
82 extern int set_arp(IF *, struct in_addr *, uchar_t *, int, uchar_t);
83
84 extern int send_reply(IF *, PKT *, int, struct in_addr *);
85 extern void disp_if_stats(IF *);
86
87 extern int relay_agent(IF *, PKT_LIST *);
88 extern void determine_network(IF *, PKT_LIST *, struct in_addr *,
89 struct in_addr *);
90 extern boolean_t is_our_address(in_addr_t);
91
92
93 #ifdef __cplusplus
94 }
95 #endif
96
97 #endif /* _INTERFACES_H */