]> git.pld-linux.org Git - packages/dhcp.git/blame - dhcp-libdhcp_control.h
- introduced -client-dirs subpackage that provides:
[packages/dhcp.git] / dhcp-libdhcp_control.h
CommitLineData
c494ae74
PZ
1/* libdhcp_control.h
2 *
3 * DHCP client control API for libdhcp, a minimal interface to the
4 * ISC dhcp IPv4 client libdhcp4client library,
5 * and to the dhcpv6 DHCPv6 client libdhcp6client library.
6 *
7 * Each DHCP client library must include this file to be controlled
8 * by libdhcp.
9 *
10 * Copyright (C) 2006 Red Hat, Inc. All rights reserved.
11 *
12 * This copyrighted material is made available to anyone wishing to use,
13 * modify, copy, or redistribute it subject to the terms and conditions of
14 * the GNU General Public License v.2, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY expressed or implied, including the implied warranties of
17 * MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU General
18 * Public License for more details. You should have received a copy of the
19 * GNU General Public License along with this program; if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
22 * source code or documentation are not subject to the GNU General Public
23 * License and may only be used or replicated with the express permission of
24 * Red Hat, Inc.
25 *
26 * Red Hat Author(s): Jason Vas Dias
27 * David Cantrell <dcantrell@redhat.com>
28 */
29
30#ifndef LIBDHCP_CONTROL_H
31#define LIBDHCP_CONTROL_H
32
33#include <stdarg.h>
34#include <stdint.h>
35
36#define LOG_FATAL 8
37
38typedef enum dhcp_state_e {
39 /* DHCPv4 client states
40 * third callback arg will be a 'struct client_state *'
41 */
42 DHC4_NBI, /* failed: no broadcast interfaces found */
43 DHC4_PREINIT, /* configuration started - bring the interface "UP" */
44 DHC4_BOUND, /* lease obtained */
45 DHC4_RENEW, /* lease renewed */
46 DHC4_REBOOT, /* have valid lease, but now obtained a different one */
47 DHC4_REBIND, /* new, different lease */
48 DHC4_STOP, /* remove old lease */
49 DHC4_MEDIUM, /* media selection begun */
50 DHC4_TIMEOUT, /* timed out contacting DHCP server */
51 DHC4_FAIL, /* all attempts to contact server timed out, sleeping */
52 DHC4_EXPIRE, /* lease has expired, renewing */
53 DHC4_RELEASE, /* releasing lease */
54
55 /* This state raised by both clients: */
56 DHC_TIMEDOUT, /* libdhcp_control timeout has been exceeded */
57
58 /* DHCPv6 client states: */
59 DHC6_BOUND, /* new lease obtained - arg is optinfo * */
60 DHC6_REBIND, /* existing expired lease rebound - arg is optinfo * */
61 DHC6_RELEASE /* existing lease expired - arg is dhcp6_iaidaddr*/
62} DHCP_State;
63
64struct libdhcp_control_s;
65
66/* ala syslog(3): LOG_EMERG=0 - LOG_DEBUG=7 (+ LOG_FATAL=8 : finished -> 1) */
67typedef int (*LIBDHCP_Error_Handler) (struct libdhcp_control_s *ctl,
68 int priority, const char *fmt,
69 va_list ap);
70
71/* The DHCP clients will call the users' callback on important state change
72 * events, with the second arg set to the client DHCP_State, and the third
73 * arg set to a client specific pointer as described below. */
74typedef int (*LIBDHCP_Callback) (struct libdhcp_control_s *control,
75 enum dhcp_state_e, void*);
76
77typedef struct libdhcp_control_s {
78 /* the DHCP clients' main loop calls this on state changes */
79 LIBDHCP_Callback callback;
80
81 /* LIBDHCP_Capability bits to enable */
82 uint16_t capability;
83
84 /* set to one to make clients exit their main loop */
85 uint8_t finished;
86
87 /* set to one to decline the lease (DHCPv4 only) */
88 uint8_t decline;
89
90 /* (timeout+now) == time after which clients MUST return */
91 time_t timeout;
92
93 /* clients set this to time(0) on entering main loop */
94 time_t now;
95
96 /* user data pointer */
97 void *arg;
98 LIBDHCP_Error_Handler eh;
99} LIBDHCP_Control;
100
101/* DHCP client "capabilities" */
102typedef enum libdhcp_capability_e {
103 /* use / do not use persistent lease database files */
104 DHCP_USE_LEASE_DATABASE = 1,
105
106 /* use / do not use pid file */
107 DHCP_USE_PID_FILE = 2,
108
109 /*
110 * DHCPv6 supports these capabilities in process,
111 * while the DHCPv4 client will fork and exec the dhclient-script to
112 * implement them if these bits are set - otherwise, if no bits are set,
113 * the callback is called and the script is not run.
114 */
115 /* configure interfaces UP/DOWN as required */
116 DHCP_CONFIGURE_INTERFACES = 4,
117
118 /* configure interface addresses as required */
119 DHCP_CONFIGURE_ADDRESSES = 8,
120
121 /* configure routes as required */
122 DHCP_CONFIGURE_ROUTES = 16,
123
124 /* configure resolv.conf as required */
125 DHCP_CONFIGURE_RESOLVER = 32,
126
127 /* DHCPv6 only: */
128 /* configure radvd.conf & restart radvd as required */
129 DHCP_CONFIGURE_RADVD = 64,
130} LIBDHCP_Capability;
131
132#endif
This page took 0.041002 seconds and 4 git commands to generate.