ReactOS  0.4.12-dev-18-gf469aca
dhcpd.h File Reference
#include <winsock2.h>
#include <iphlpapi.h>
#include "stdint.h"
#include <pshpack1.h>
#include <poppack.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "dhcp.h"
#include "tree.h"
Include dependency graph for dhcpd.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ether_header
 
struct  ip
 
struct  udphdr
 
struct  option_data
 
struct  string_list
 
struct  iaddr
 
struct  iaddrlist
 
struct  packet
 
struct  hardware
 
struct  client_lease
 
struct  client_config
 
struct  client_state
 
struct  interface_info
 
struct  timeout
 
struct  protocol
 
struct  hash_bucket
 
struct  hash_table
 

Macros

#define IFNAMSIZ   MAX_INTERFACE_NAME_LEN
 
#define ETH_ALEN   6
 
#define ETHER_ADDR_LEN   ETH_ALEN
 
#define IP_RF   0x8000 /* reserved fragment flag */
 
#define IP_DF   0x4000 /* dont fragment flag */
 
#define IP_MF   0x2000 /* more fragments flag */
 
#define IP_OFFMASK   0x1fff /* mask for fragmenting bits */
 
#define ETHERTYPE_IP   0x0800
 
#define IPTOS_LOWDELAY   0x10
 
#define ARPHRD_ETHER   1
 
#define SIZE_T_MAX   1600
 
#define USE_SOCKET_RECEIVE
 
#define USE_SOCKET_SEND
 
#define LOCAL_PORT   68
 
#define REMOTE_PORT   67
 
#define DEFAULT_HASH_SIZE   97
 
#define _PATH_DHCLIENT_CONF   "/etc/dhclient.conf"
 
#define _PATH_DHCLIENT_DB   "/var/db/dhclient.leases"
 
#define DHCPD_LOG_FACILITY   LOG_DAEMON
 
#define MAX_TIME   0x7fffffff
 
#define MIN_TIME   0
 

Enumerations

enum  dhcp_state {
  S_REBOOTING, S_INIT, S_SELECTING, S_REQUESTING,
  S_BOUND, S_RENEWING, S_REBINDING, S_STATIC
}
 

Functions

int cons_options (struct packet *, struct dhcp_packet *, int, struct tree_cache **, int, int, int, u_int8_t *, int)
 
charpretty_print_option (unsigned int, unsigned char *, int, int, int)
 
void do_packet (struct interface_info *, struct dhcp_packet *, int, unsigned int, struct iaddr, struct hardware *)
 
void error (char *,...) __attribute__((__format__(__printf__
 
void int warning (char *,...) __attribute__((__format__(__printf__
 
void int int note (char *,...) __attribute__((__format__(__printf__
 
void int int int debug (char *,...) __attribute__((__format__(__printf__
 
void int int int int parse_warn (char *,...) __attribute__((__format__(__printf__
 
void new_parse (char *)
 
int next_token (char **, FILE *)
 
int peek_token (char **, FILE *)
 
void skip_to_semi (FILE *)
 
int parse_semi (FILE *)
 
charparse_string (FILE *)
 
int parse_ip_addr (FILE *, struct iaddr *)
 
void parse_hardware_param (FILE *, struct hardware *)
 
void parse_lease_time (FILE *, time_t *)
 
unsigned charparse_numeric_aggregate (FILE *, unsigned char *, int *, int, int, int)
 
void convert_num (unsigned char *, char *, int, int)
 
time_t parse_date (FILE *)
 
pair cons (caddr_t, pair)
 
struct string_listnew_string_list (size_t size)
 
struct hash_tablenew_hash_table (int)
 
struct hash_bucketnew_hash_bucket (void)
 
void dfree (void *, char *)
 
void free_hash_bucket (struct hash_bucket *, char *)
 
int if_register_bpf (struct interface_info *)
 
void if_register_send (struct interface_info *)
 
void if_register_receive (struct interface_info *)
 
ssize_t send_packet (struct interface_info *, struct dhcp_packet *, size_t, struct in_addr, struct sockaddr_in *, struct hardware *)
 
ssize_t receive_packet (struct interface_info *, unsigned char *, size_t, struct sockaddr_in *, struct hardware *)
 
void discover_interfaces (struct interface_info *)
 
void reinitialize_interfaces (void)
 
void dispatch (HANDLE hStopEvent)
 
void got_one (struct protocol *)
 
void add_timeout (time_t, void(*)(void *), void *)
 
void cancel_timeout (void(*)(void *), void *)
 
void add_protocol (char *, int, void(*)(struct protocol *), void *)
 
void remove_protocol (struct protocol *)
 
struct protocolfind_protocol_by_adapter (struct interface_info *)
 
int interface_link_status (char *)
 
struct hash_tablenew_hash (void)
 
void add_hash (struct hash_table *, unsigned char *, int, unsigned char *)
 
unsigned charhash_lookup (struct hash_table *, unsigned char *, int)
 
void initialize_universes (void)
 
u_int32_t getULong (unsigned char *)
 
int32_t getLong (unsigned char *)
 
u_int16_t getUShort (unsigned char *)
 
int16_t getShort (unsigned char *)
 
void putULong (unsigned char *, u_int32_t)
 
void putLong (unsigned char *, int32_t)
 
void putUShort (unsigned char *, unsigned int)
 
void putShort (unsigned char *, int)
 
struct iaddr subnet_number (struct iaddr, struct iaddr)
 
struct iaddr broadcast_addr (struct iaddr, struct iaddr)
 
int addr_eq (struct iaddr, struct iaddr)
 
charpiaddr (struct iaddr)
 
void dhcpoffer (struct packet *)
 
void dhcpack (struct packet *)
 
void dhcpnak (struct packet *)
 
void send_discover (void *)
 
void send_request (void *)
 
void send_decline (void *)
 
void state_reboot (void *)
 
void state_init (void *)
 
void state_selecting (void *)
 
void state_requesting (void *)
 
void state_bound (void *)
 
void state_panic (void *)
 
void bind_lease (struct interface_info *)
 
void make_discover (struct interface_info *, struct client_lease *)
 
void make_request (struct interface_info *, struct client_lease *)
 
void make_decline (struct interface_info *, struct client_lease *)
 
void free_client_lease (struct client_lease *)
 
void rewrite_client_leases (struct interface_info *)
 
void write_client_lease (struct interface_info *, struct client_lease *, int)
 
void priv_script_init (struct interface_info *, char *, char *)
 
void priv_script_write_params (struct interface_info *, char *, struct client_lease *)
 
int priv_script_go (void)
 
void script_init (char *, struct string_list *)
 
void script_write_params (char *, struct client_lease *)
 
int script_go (void)
 
void client_envadd (struct client_state *, const char *, const char *, const char *,...)
 
void script_set_env (struct client_state *, const char *, const char *, const char *)
 
void script_flush_env (struct client_state *)
 
int dhcp_option_ev_name (char *, size_t, struct dhcp_option *)
 
struct client_leasepacket_to_lease (struct packet *)
 
void go_daemon (void)
 
void client_location_changed (void)
 
void bootp (struct packet *)
 
void dhcp (struct packet *)
 
void assemble_hw_header (struct interface_info *, unsigned char *, int *, struct hardware *)
 
void assemble_udp_ip_header (unsigned char *, int *, u_int32_t, u_int32_t, unsigned int, unsigned char *, int)
 
ssize_t decode_hw_header (unsigned char *, int, struct hardware *)
 
ssize_t decode_udp_ip_header (unsigned char *, int, struct sockaddr_in *, unsigned char *, int)
 
void assemble_ethernet_header (struct interface_info *, unsigned char *, int *, struct hardware *)
 
ssize_t decode_ethernet_header (struct interface_info *, unsigned char *, int, struct hardware *)
 
int read_client_conf (struct interface_info *)
 
void read_client_leases (void)
 
void parse_client_statement (FILE *, struct interface_info *, struct client_config *)
 
int parse_X (FILE *, u_int8_t *, int)
 
int parse_option_list (FILE *, u_int8_t *)
 
void parse_interface_declaration (FILE *, struct client_config *)
 
struct interface_infointerface_or_dummy (char *)
 
void make_client_state (struct interface_info *)
 
void make_client_config (struct interface_info *, struct client_config *)
 
void parse_client_lease_statement (FILE *, int)
 
void parse_client_lease_declaration (FILE *, struct client_lease *, struct interface_info **)
 
struct dhcp_optionparse_option_decl (FILE *, struct option_data *)
 
void parse_string_list (FILE *, struct string_list **, int)
 
void parse_reject_statement (FILE *, struct client_config *)
 
struct bufbuf_open (size_t)
 
int buf_add (struct buf *, void *, size_t)
 
int buf_close (int, struct buf *)
 
ssize_t buf_read (int, void *, size_t)
 
void dispatch_imsg (int)
 

Variables

int warnings_occurred
 
void int int int int int lexline
 
void int int int int int lexchar
 
chartoken_line
 
chartlname
 
char comments [4096]
 
int comment_index
 
int eol_token
 
void(* bootp_packet_handler )(struct interface_info *, struct dhcp_packet *, int, unsigned int, struct iaddr, struct hardware *)
 
struct dhcp_option dhcp_options [256]
 
unsigned char dhcp_option_default_priority_list []
 
int sizeof_dhcp_option_default_priority_list
 
struct hash_table universe_hash
 
struct universe dhcp_universe
 
charpath_dhclient_conf
 
charpath_dhclient_db
 
time_t cur_time
 
int log_priority
 
int log_perror
 
struct client_config top_level_config
 

Macro Definition Documentation

◆ _PATH_DHCLIENT_CONF

#define _PATH_DHCLIENT_CONF   "/etc/dhclient.conf"

Definition at line 274 of file dhcpd.h.

◆ _PATH_DHCLIENT_DB

#define _PATH_DHCLIENT_DB   "/var/db/dhclient.leases"

Definition at line 275 of file dhcpd.h.

◆ ARPHRD_ETHER

#define ARPHRD_ETHER   1

Definition at line 88 of file dhcpd.h.

◆ DEFAULT_HASH_SIZE

#define DEFAULT_HASH_SIZE   97

Definition at line 259 of file dhcpd.h.

Referenced by initialize_universes(), new_hash(), and new_hash_table().

◆ DHCPD_LOG_FACILITY

#define DHCPD_LOG_FACILITY   LOG_DAEMON

Definition at line 276 of file dhcpd.h.

◆ ETH_ALEN

#define ETH_ALEN   6

Definition at line 50 of file dhcpd.h.

◆ ETHER_ADDR_LEN

#define ETHER_ADDR_LEN   ETH_ALEN

Definition at line 51 of file dhcpd.h.

◆ ETHERTYPE_IP

#define ETHERTYPE_IP   0x0800

Definition at line 86 of file dhcpd.h.

◆ IFNAMSIZ

Definition at line 48 of file dhcpd.h.

◆ IP_DF

#define IP_DF   0x4000 /* dont fragment flag */

Definition at line 70 of file dhcpd.h.

Referenced by ip_route().

◆ IP_MF

#define IP_MF   0x2000 /* more fragments flag */

Definition at line 71 of file dhcpd.h.

Referenced by ip_input().

◆ IP_OFFMASK

#define IP_OFFMASK   0x1fff /* mask for fragmenting bits */

Definition at line 72 of file dhcpd.h.

Referenced by ip_input(), and ip_output().

◆ IP_RF

#define IP_RF   0x8000 /* reserved fragment flag */

Definition at line 69 of file dhcpd.h.

◆ IPTOS_LOWDELAY

#define IPTOS_LOWDELAY   0x10

Definition at line 87 of file dhcpd.h.

Referenced by OpenControlConnection().

◆ LOCAL_PORT

#define LOCAL_PORT   68

Definition at line 112 of file dhcpd.h.

◆ MAX_TIME

#define MAX_TIME   0x7fffffff

Definition at line 278 of file dhcpd.h.

Referenced by tree_evaluate_recurse().

◆ MIN_TIME

#define MIN_TIME   0

Definition at line 279 of file dhcpd.h.

◆ REMOTE_PORT

#define REMOTE_PORT   67

Definition at line 113 of file dhcpd.h.

Referenced by init_client(), and send_request().

◆ SIZE_T_MAX

#define SIZE_T_MAX   1600

Definition at line 91 of file dhcpd.h.

Referenced by PspSetQuotaLimits().

◆ USE_SOCKET_RECEIVE

#define USE_SOCKET_RECEIVE

Definition at line 93 of file dhcpd.h.

◆ USE_SOCKET_SEND

#define USE_SOCKET_SEND

Definition at line 94 of file dhcpd.h.

Enumeration Type Documentation

◆ dhcp_state

Enumerator
S_REBOOTING 
S_INIT 
S_SELECTING 
S_REQUESTING 
S_BOUND 
S_RENEWING 
S_REBINDING 
S_STATIC 

Definition at line 170 of file dhcpd.h.

170  {
171  S_REBOOTING,
172  S_INIT,
173  S_SELECTING,
174  S_REQUESTING,
175  S_BOUND,
176  S_RENEWING,
177  S_REBINDING,
178  S_STATIC
179 };
Definition: dhcpd.h:175
Definition: dhcpd.h:172

Function Documentation

◆ add_hash()

void add_hash ( struct hash_table ,
unsigned char ,
int  ,
unsigned char  
)

Definition at line 82 of file hash.c.

Referenced by assign_file_addresses(), assign_inodes(), compute_linkcount(), endpad_write(), initialize_universes(), and root_gen().

87 {
88  int hashno;
89  struct hash_bucket *bp;
90 
91  if (!table)
92  return;
93  if (!len)
94  len = strlen ((char *)name);
95 
96  hashno = do_hash (name, len, table -> hash_count);
97  bp = new_hash_bucket ();
98 
99  if (!bp) {
100  warn ("Can't add %s to hash table.", name);
101  return;
102  }
103  bp -> name = name;
104  bp -> value = pointer;
105  bp -> next = table -> buckets [hashno];
106  bp -> len = len;
107  table -> buckets [hashno] = bp;
108 }
Definition: get.c:139
#define warn(...)
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLsizei const GLvoid * pointer
Definition: glext.h:5848
static __inline int do_hash(unsigned char *name, int len, int size)
Definition: hash.c:63
GLenum GLsizei len
Definition: glext.h:6722
static unsigned __int64 next
Definition: rand_nt.c:6
Definition: name.c:36
struct hash_bucket * new_hash_bucket(void)
Definition: alloc.c:71
GLuint const GLchar * name
Definition: glext.h:6031

◆ add_protocol()

void add_protocol ( char ,
int  ,
void(*)(struct protocol *)  ,
void  
)

Definition at line 343 of file dispatch.c.

Referenced by AdapterDiscoveryThread(), DSLeaseIpAddress(), and DSRenewIpAddressLease().

345 {
346  struct protocol *p;
347 
348  p = malloc(sizeof(*p));
349  if (!p)
350  error("can't allocate protocol struct for %s", name);
351 
352  p->fd = fd;
353  p->handler = handler;
354  p->local = local;
355  p->next = protocols;
356  protocols = p;
357 }
#define error(str)
Definition: mkdosfs.c:1605
int fd
Definition: dhcpd.h:254
static int fd
Definition: io.c:51
void * local
Definition: dhcpd.h:256
#define local
Definition: zutil.h:30
struct protocol * protocols
Definition: dispatch.c:52
struct protocol * next
Definition: dhcpd.h:253
Definition: name.c:36
void(* handler)(struct protocol *)
Definition: dhcpd.h:255
#define malloc
Definition: debug_ros.c:4
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7782
GLfloat GLfloat p
Definition: glext.h:8902

◆ add_timeout()

void add_timeout ( time_t  ,
void(*)(void *)  ,
void  
)

Definition at line 254 of file dispatch.c.

Referenced by bind_lease(), dhcpoffer(), send_discover(), and send_request().

255 {
256  struct timeout *t, *q;
257 
258  DH_DbgPrint(MID_TRACE,("Adding timeout %x %p %x\n", when, where, what));
259  /* See if this timeout supersedes an existing timeout. */
260  t = NULL;
261  for (q = timeouts; q; q = q->next) {
262  if (q->func == where && q->what == what) {
263  if (t)
264  t->next = q->next;
265  else
266  timeouts = q->next;
267  break;
268  }
269  t = q;
270  }
271 
272  /* If we didn't supersede a timeout, allocate a timeout
273  structure now. */
274  if (!q) {
275  if (free_timeouts) {
276  q = free_timeouts;
277  free_timeouts = q->next;
278  q->func = where;
279  q->what = what;
280  } else {
281  q = malloc(sizeof(struct timeout));
282  if (!q) {
283  error("Can't allocate timeout structure!");
284  return;
285  }
286  q->func = where;
287  q->what = what;
288  }
289  }
290 
291  q->when = when;
292 
293  /* Now sort this timeout into the timeout list. */
294 
295  /* Beginning of list? */
296  if (!timeouts || timeouts->when > q->when) {
297  q->next = timeouts;
298  timeouts = q;
299  return;
300  }
301 
302  /* Middle of list? */
303  for (t = timeouts; t->next; t = t->next) {
304  if (t->next->when > q->when) {
305  q->next = t->next;
306  t->next = q;
307  return;
308  }
309  }
310 
311  /* End of list. */
312  t->next = q;
313  q->next = NULL;
314 }
#define MID_TRACE
Definition: debug.h:15
#define error(str)
Definition: mkdosfs.c:1605
void(* func)(void *)
Definition: dhcpd.h:248
GLdouble GLdouble t
Definition: gl.h:2047
Definition: dhcpd.h:245
smooth NULL
Definition: ftsmooth.c:416
#define DH_DbgPrint(_t_, _x_)
Definition: debug.h:49
time_t when
Definition: dhcpd.h:247
static struct timeout * free_timeouts
Definition: dispatch.c:54
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
struct timeout * next
Definition: dhcpd.h:246
#define malloc
Definition: debug_ros.c:4
void * what
Definition: dhcpd.h:249
struct timeout * timeouts
Definition: dispatch.c:53

◆ addr_eq()

int addr_eq ( struct iaddr  ,
struct iaddr   
)

Definition at line 100 of file util.c.

Referenced by bootp(), and dhcp().

100  {
101  return a.len == b.len && !memcmp( a.iabuf, b.iabuf, a.len );
102 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ assemble_ethernet_header()

void assemble_ethernet_header ( struct interface_info ,
unsigned char ,
int ,
struct hardware  
)

◆ assemble_hw_header()

void assemble_hw_header ( struct interface_info ,
unsigned char ,
int ,
struct hardware  
)

◆ assemble_udp_ip_header()

void assemble_udp_ip_header ( unsigned char ,
int ,
u_int32_t  ,
u_int32_t  ,
unsigned  int,
unsigned char ,
int   
)

◆ bind_lease()

void bind_lease ( struct interface_info )

Definition at line 588 of file dhclient.c.

Referenced by dhcpack(), and state_selecting().

589 {
590  PDHCP_ADAPTER Adapter;
591  struct client_lease *new_lease = ip->client->new;
593 
594  time(&cur_time);
595 
596  /* Remember the medium. */
597  ip->client->new->medium = ip->client->medium;
598 
599  /* Replace the old active lease with the new one. */
600  if (ip->client->active)
601  free_client_lease(ip->client->active);
602  ip->client->active = ip->client->new;
603  ip->client->new = NULL;
604 
605  /* Set up a timeout to start the renewal process. */
606  /* Timeout of zero means no timeout (some implementations seem to use
607  * one day).
608  */
609  if( ip->client->active->renewal - cur_time )
610  add_timeout(ip->client->active->renewal, state_bound, ip);
611 
612  note("bound to %s -- renewal in %ld seconds.",
613  piaddr(ip->client->active->address),
614  (long int)(ip->client->active->renewal - cur_time));
615 
616  ip->client->state = S_BOUND;
617 
618  Adapter = AdapterFindInfo( ip );
619 
620  if( Adapter ) setup_adapter( Adapter, new_lease );
621  else {
622  warning("Could not find adapter for info %p\n", ip);
623  return;
624  }
625  set_name_servers( Adapter, new_lease );
626  set_domain( Adapter, new_lease );
627 }
Definition: dhcpd.h:175
time_t cur_time
void setup_adapter(PDHCP_ADAPTER Adapter, struct client_lease *new_lease)
Definition: dhclient.c:500
void state_bound(void *ipp)
Definition: dhclient.c:636
__u16 time
Definition: mkdosfs.c:366
int note(char *format,...)
Definition: util.c:12
smooth NULL
Definition: ftsmooth.c:416
PDHCP_ADAPTER AdapterFindInfo(struct interface_info *ip)
Definition: adapter.c:541
void set_name_servers(PDHCP_ADAPTER Adapter, struct client_lease *new_lease)
Definition: dhclient.c:406
Definition: dhcpd.h:61
__kernel_time_t time_t
Definition: linux.h:252
char * piaddr(struct iaddr addr)
Definition: util.c:6
void add_timeout(time_t when, void(*where)(void *), void *what)
Definition: dispatch.c:254
void set_domain(PDHCP_ADAPTER Adapter, struct client_lease *new_lease)
Definition: dhclient.c:451
void free_client_lease(struct client_lease *lease)
Definition: dhclient.c:1493
#define warning(s)
Definition: debug.h:71

◆ bootp()

void bootp ( struct packet )

Definition at line 662 of file dhclient.c.

Referenced by do_packet().

663 {
664  struct iaddrlist *ap;
665 
666  if (packet->raw->op != BOOTREPLY)
667  return;
668 
669  /* If there's a reject list, make sure this packet's sender isn't
670  on it. */
671  for (ap = packet->interface->client->config->reject_list;
672  ap; ap = ap->next) {
673  if (addr_eq(packet->client_addr, ap->addr)) {
674  note("BOOTREPLY from %s rejected.", piaddr(ap->addr));
675  return;
676  }
677  }
678  dhcpoffer(packet);
679 }
struct iaddrlist * next
Definition: dhcpd.h:131
int addr_eq(struct iaddr a, struct iaddr b)
Definition: util.c:100
void dhcpoffer(struct packet *packet)
Definition: dhclient.c:718
struct dhcp_packet * raw
Definition: dhcpd.h:136
int note(char *format,...)
Definition: util.c:12
struct iaddr addr
Definition: dhcpd.h:132
struct interface_info * interface
Definition: dhcpd.h:142
Definition: dhcpd.h:135
#define BOOTREPLY
Definition: dhcp.h:79
char * piaddr(struct iaddr addr)
Definition: util.c:6
struct iaddr client_addr
Definition: dhcpd.h:141
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32

◆ broadcast_addr()

struct iaddr broadcast_addr ( struct iaddr  ,
struct iaddr   
)

Definition at line 167 of file util.c.

Referenced by priv_script_write_params().

167  {
168  struct iaddr bcast = { 0 };
169  return bcast;
170 }
Definition: dhcpd.h:125

◆ buf_add()

int buf_add ( struct buf ,
void ,
size_t   
)

◆ buf_close()

int buf_close ( int  ,
struct buf  
)

◆ buf_open()

struct buf* buf_open ( size_t  )

◆ buf_read()

ssize_t buf_read ( int  ,
void ,
size_t   
)

◆ cancel_timeout()

void cancel_timeout ( void(*)(void *)  ,
void  
)

Definition at line 317 of file dispatch.c.

Referenced by dhcpack(), dhcpnak(), dhcpoffer(), send_request(), and state_selecting().

318 {
319  struct timeout *t, *q;
320 
321  /* Look for this timeout on the list, and unlink it if we find it. */
322  t = NULL;
323  for (q = timeouts; q; q = q->next) {
324  if (q->func == where && q->what == what) {
325  if (t)
326  t->next = q->next;
327  else
328  timeouts = q->next;
329  break;
330  }
331  t = q;
332  }
333 
334  /* If we found the timeout, put it on the free list. */
335  if (q) {
336  q->next = free_timeouts;
337  free_timeouts = q;
338  }
339 }
void(* func)(void *)
Definition: dhcpd.h:248
GLdouble GLdouble t
Definition: gl.h:2047
Definition: dhcpd.h:245
smooth NULL
Definition: ftsmooth.c:416
static struct timeout * free_timeouts
Definition: dispatch.c:54
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
struct timeout * next
Definition: dhcpd.h:246
void * what
Definition: dhcpd.h:249
struct timeout * timeouts
Definition: dispatch.c:53

◆ client_envadd()

void client_envadd ( struct client_state ,
const char ,
const char ,
const char ,
  ... 
)

◆ client_location_changed()

void client_location_changed ( void  )

◆ cons()

pair cons ( caddr_t  ,
pair   
)

Definition at line 57 of file tree.c.

Referenced by xmlIOErrMemory(), xmlParseConditionalSections(), xmlParseContent(), xmlParseExternalSubset(), xmlParseExtParsedEnt(), xmlParseInternalSubset(), and xmlParseStartTag2().

60 {
61  pair foo = (pair)dmalloc (sizeof *foo, "cons");
62  if (!foo)
63  error ("no memory for cons.");
64  foo -> car = car;
65  foo -> cdr = cdr;
66  return foo;
67 }
#define error(str)
Definition: mkdosfs.c:1605
int foo()
struct _pair * pair
Definition: _pair.h:47
void * dmalloc(int size, char *name)
Definition: util.c:104

◆ cons_options()

int cons_options ( struct packet ,
struct dhcp_packet ,
int  ,
struct tree_cache **  ,
int  ,
int  ,
int  ,
u_int8_t ,
int   
)

Definition at line 199 of file options.c.

Referenced by make_decline(), make_discover(), and make_request().

203 {
204  unsigned char priority_list[300], buffer[4096];
205  int priority_len, main_buffer_size, mainbufix, bufix;
206  int option_size, length;
207 
208  /*
209  * If the client has provided a maximum DHCP message size, use
210  * that; otherwise, if it's BOOTP, only 64 bytes; otherwise use
211  * up to the minimum IP MTU size (576 bytes).
212  *
213  * XXX if a BOOTP client specifies a max message size, we will
214  * honor it.
215  */
216  if (!mms &&
217  inpacket &&
218  inpacket->options[DHO_DHCP_MAX_MESSAGE_SIZE].data &&
219  (inpacket->options[DHO_DHCP_MAX_MESSAGE_SIZE].len >=
220  sizeof(u_int16_t)))
221  mms = getUShort(
222  inpacket->options[DHO_DHCP_MAX_MESSAGE_SIZE].data);
223 
224  if (mms)
225  main_buffer_size = mms - DHCP_FIXED_LEN;
226  else if (bootpp)
227  main_buffer_size = 64;
228  else
229  main_buffer_size = 576 - DHCP_FIXED_LEN;
230 
231  if (main_buffer_size > sizeof(buffer))
232  main_buffer_size = sizeof(buffer);
233 
234  /* Preload the option priority list with mandatory options. */
235  priority_len = 0;
236  priority_list[priority_len++] = DHO_DHCP_MESSAGE_TYPE;
237  priority_list[priority_len++] = DHO_DHCP_SERVER_IDENTIFIER;
238  priority_list[priority_len++] = DHO_DHCP_LEASE_TIME;
239  priority_list[priority_len++] = DHO_DHCP_MESSAGE;
240 
241  /*
242  * If the client has provided a list of options that it wishes
243  * returned, use it to prioritize. Otherwise, prioritize based
244  * on the default priority list.
245  */
246  if (inpacket &&
247  inpacket->options[DHO_DHCP_PARAMETER_REQUEST_LIST].data) {
248  int prlen =
249  inpacket->options[DHO_DHCP_PARAMETER_REQUEST_LIST].len;
250  if (prlen + priority_len > sizeof(priority_list))
251  prlen = sizeof(priority_list) - priority_len;
252 
253  memcpy(&priority_list[priority_len],
254  inpacket->options[DHO_DHCP_PARAMETER_REQUEST_LIST].data,
255  prlen);
256  priority_len += prlen;
257  prl = priority_list;
258  } else if (prl) {
259  if (prl_len + priority_len > sizeof(priority_list))
260  prl_len = sizeof(priority_list) - priority_len;
261 
262  memcpy(&priority_list[priority_len], prl, prl_len);
263  priority_len += prl_len;
264  prl = priority_list;
265  } else {
266  memcpy(&priority_list[priority_len],
270  }
271 
272  /* Copy the options into the big buffer... */
273  option_size = store_options(
274  buffer,
275  (main_buffer_size - 7 + ((overload & 1) ? DHCP_FILE_LEN : 0) +
276  ((overload & 2) ? DHCP_SNAME_LEN : 0)),
277  options, priority_list, priority_len, main_buffer_size,
278  (main_buffer_size + ((overload & 1) ? DHCP_FILE_LEN : 0)),
279  terminate);
280 
281  /* Put the cookie up front... */
282  memcpy(outpacket->options, DHCP_OPTIONS_COOKIE, 4);
283  mainbufix = 4;
284 
285  /*
286  * If we're going to have to overload, store the overload option
287  * at the beginning. If we can, though, just store the whole
288  * thing in the packet's option buffer and leave it at that.
289  */
290  if (option_size <= main_buffer_size - mainbufix) {
291  memcpy(&outpacket->options[mainbufix],
292  buffer, option_size);
293  mainbufix += option_size;
294  if (mainbufix < main_buffer_size)
295  outpacket->options[mainbufix++] = DHO_END;
296  length = DHCP_FIXED_NON_UDP + mainbufix;
297  } else {
298  outpacket->options[mainbufix++] = DHO_DHCP_OPTION_OVERLOAD;
299  outpacket->options[mainbufix++] = 1;
300  if (option_size >
301  main_buffer_size - mainbufix + DHCP_FILE_LEN)
302  outpacket->options[mainbufix++] = 3;
303  else
304  outpacket->options[mainbufix++] = 1;
305 
306  memcpy(&outpacket->options[mainbufix],
307  buffer, main_buffer_size - mainbufix);
308  bufix = main_buffer_size - mainbufix;
309  length = DHCP_FIXED_NON_UDP + mainbufix;
310  if (overload & 1) {
311  if (option_size - bufix <= DHCP_FILE_LEN) {
312  memcpy(outpacket->file,
313  &buffer[bufix], option_size - bufix);
314  mainbufix = option_size - bufix;
315  if (mainbufix < DHCP_FILE_LEN)
316  outpacket->file[mainbufix++] = (char)DHO_END;
317  while (mainbufix < DHCP_FILE_LEN)
318  outpacket->file[mainbufix++] = (char)DHO_PAD;
319  } else {
320  memcpy(outpacket->file,
321  &buffer[bufix], DHCP_FILE_LEN);
322  bufix += DHCP_FILE_LEN;
323  }
324  }
325  if ((overload & 2) && option_size < bufix) {
326  memcpy(outpacket->sname,
327  &buffer[bufix], option_size - bufix);
328 
329  mainbufix = option_size - bufix;
330  if (mainbufix < DHCP_SNAME_LEN)
331  outpacket->file[mainbufix++] = (char)DHO_END;
332  while (mainbufix < DHCP_SNAME_LEN)
333  outpacket->file[mainbufix++] = (char)DHO_PAD;
334  }
335  }
336  return (length);
337 }
#define DHO_DHCP_MESSAGE
Definition: dhcp.h:152
#define DHO_END
Definition: dhcp.h:159
#define DHO_DHCP_LEASE_TIME
Definition: dhcp.h:147
#define DHCP_FIXED_NON_UDP
Definition: dhcp.h:48
#define DHO_DHCP_MESSAGE_TYPE
Definition: dhcp.h:149
#define DHO_PAD
Definition: dhcp.h:96
GLuint buffer
Definition: glext.h:5915
#define DHO_DHCP_PARAMETER_REQUEST_LIST
Definition: dhcp.h:151
u_int16_t getUShort(unsigned char *data)
Definition: util.c:88
#define DHCP_FILE_LEN
Definition: dhcp.h:47
#define DHCP_OPTIONS_COOKIE
Definition: dhcp.h:91
unsigned char
Definition: typeof.h:27
void MSVCRT() terminate()
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define DHO_DHCP_OPTION_OVERLOAD
Definition: dhcp.h:148
#define DHCP_FIXED_LEN
Definition: dhcp.h:49
unsigned short u_int16_t
Definition: rosdhcp.h:34
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
int sizeof_dhcp_option_default_priority_list
Definition: tables.c:408
#define DHO_DHCP_SERVER_IDENTIFIER
Definition: dhcp.h:150
unsigned char dhcp_option_default_priority_list[]
Definition: tables.c:329
#define DHO_DHCP_MAX_MESSAGE_SIZE
Definition: dhcp.h:153
int store_options(unsigned char *, int, struct tree_cache **, unsigned char *, int, int, int, int)
Definition: options.c:343
#define DHCP_SNAME_LEN
Definition: dhcp.h:46

◆ convert_num()

void convert_num ( unsigned char ,
char ,
int  ,
int   
)

◆ debug()

void int int int debug ( char ,
  ... 
)

◆ decode_ethernet_header()

ssize_t decode_ethernet_header ( struct interface_info ,
unsigned char ,
int  ,
struct hardware  
)

◆ decode_hw_header()

ssize_t decode_hw_header ( unsigned char ,
int  ,
struct hardware  
)

◆ decode_udp_ip_header()

ssize_t decode_udp_ip_header ( unsigned char ,
int  ,
struct sockaddr_in ,
unsigned char ,
int   
)

◆ dfree()

void dfree ( void ,
char  
)

Definition at line 79 of file alloc.c.

Referenced by do_host_lookup(), free_hash_bucket(), tree_concat(), and tree_evaluate().

80 {
81  if (!ptr) {
82  warning("dfree %s: free on null pointer.", name);
83  return;
84  }
85  free(ptr);
86 }
#define free
Definition: debug_ros.c:5
static PVOID ptr
Definition: dispmode.c:27
Definition: name.c:36
#define warning(s)
Definition: debug.h:71

◆ dhcp()

void dhcp ( struct packet )

Definition at line 682 of file dhclient.c.

Referenced by do_packet().

683 {
684  struct iaddrlist *ap;
685  void (*handler)(struct packet *);
686  char *type;
687 
688  switch (packet->packet_type) {
689  case DHCPOFFER:
690  handler = dhcpoffer;
691  type = "DHCPOFFER";
692  break;
693  case DHCPNAK:
694  handler = dhcpnak;
695  type = "DHCPNACK";
696  break;
697  case DHCPACK:
698  handler = dhcpack;
699  type = "DHCPACK";
700  break;
701  default:
702  return;
703  }
704 
705  /* If there's a reject list, make sure this packet's sender isn't
706  on it. */
707  for (ap = packet->interface->client->config->reject_list;
708  ap; ap = ap->next) {
709  if (addr_eq(packet->client_addr, ap->addr)) {
710  note("%s from %s rejected.", type, piaddr(ap->addr));
711  return;
712  }
713  }
714  (*handler)(packet);
715 }
struct iaddrlist * next
Definition: dhcpd.h:131
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
int addr_eq(struct iaddr a, struct iaddr b)
Definition: util.c:100
void dhcpoffer(struct packet *packet)
Definition: dhclient.c:718
UCHAR packet[_PAGE_SIZE]
Definition: serial.c:53
void dhcpnak(struct packet *packet)
Definition: dhclient.c:923
#define DHCPOFFER
Definition: dhcp.h:163
#define DHCPACK
Definition: dhcp.h:166
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
void dhcpack(struct packet *packet)
Definition: dhclient.c:324
int note(char *format,...)
Definition: util.c:12
struct iaddr addr
Definition: dhcpd.h:132
struct interface_info * interface
Definition: dhcpd.h:142
Definition: dhcpd.h:135
int packet_type
Definition: dhcpd.h:138
#define DHCPNAK
Definition: dhcp.h:167
char * piaddr(struct iaddr addr)
Definition: util.c:6
struct iaddr client_addr
Definition: dhcpd.h:141
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7782

◆ dhcp_option_ev_name()

int dhcp_option_ev_name ( char ,
size_t  ,
struct dhcp_option  
)

Definition at line 1745 of file dhclient.c.

Referenced by priv_script_write_params().

1746 {
1747  int i;
1748 
1749  for (i = 0; option->name[i]; i++) {
1750  if (i + 1 == buflen)
1751  return 0;
1752  if (option->name[i] == '-')
1753  buf[i] = '_';
1754  else
1755  buf[i] = option->name[i];
1756  }
1757 
1758  buf[i] = 0;
1759  return 1;
1760 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLclampf GLint i
Definition: glfuncs.h:14
WCHAR * name
Definition: getopt.h:110
Definition: getopt.h:108

◆ dhcpack()

void dhcpack ( struct packet )

Definition at line 324 of file dhclient.c.

Referenced by dhcp().

325 {
326  struct interface_info *ip = packet->interface;
327  struct client_lease *lease;
329 
330  time(&cur_time);
331 
332  /* If we're not receptive to an offer right now, or if the offer
333  has an unrecognizable transaction id, then just drop it. */
334  if (packet->interface->client->xid != packet->raw->xid ||
335  (packet->interface->hw_address.hlen != packet->raw->hlen) ||
336  (memcmp(packet->interface->hw_address.haddr,
337  packet->raw->chaddr, packet->raw->hlen)))
338  return;
339 
340  if (ip->client->state != S_REBOOTING &&
341  ip->client->state != S_REQUESTING &&
342  ip->client->state != S_RENEWING &&
343  ip->client->state != S_REBINDING)
344  return;
345 
346  note("DHCPACK from %s", piaddr(packet->client_addr));
347 
348  lease = packet_to_lease(packet);
349  if (!lease) {
350  note("packet_to_lease failed.");
351  return;
352  }
353 
354  ip->client->new = lease;
355 
356  /* Stop resending DHCPREQUEST. */
358 
359  /* Figure out the lease time. */
360  if (ip->client->new->options[DHO_DHCP_LEASE_TIME].data)
361  ip->client->new->expiry = getULong(
362  ip->client->new->options[DHO_DHCP_LEASE_TIME].data);
363  else
364  ip->client->new->expiry = DHCP_DEFAULT_LEASE_TIME;
365  /* A number that looks negative here is really just very large,
366  because the lease expiry offset is unsigned. */
367  if (ip->client->new->expiry < 0)
368  ip->client->new->expiry = TIME_MAX;
369  /* XXX should be fixed by resetting the client state */
370  if (ip->client->new->expiry < 60)
371  ip->client->new->expiry = 60;
372 
373  /* Take the server-provided renewal time if there is one;
374  otherwise figure it out according to the spec. */
375  if (ip->client->new->options[DHO_DHCP_RENEWAL_TIME].len)
376  ip->client->new->renewal = getULong(
377  ip->client->new->options[DHO_DHCP_RENEWAL_TIME].data);
378  else
379  ip->client->new->renewal = ip->client->new->expiry / 2;
380 
381  /* Same deal with the rebind time. */
382  if (ip->client->new->options[DHO_DHCP_REBINDING_TIME].len)
383  ip->client->new->rebind = getULong(
384  ip->client->new->options[DHO_DHCP_REBINDING_TIME].data);
385  else
386  ip->client->new->rebind = ip->client->new->renewal +
387  ip->client->new->renewal / 2 + ip->client->new->renewal / 4;
388 
389 #ifdef __REACTOS__
390  ip->client->new->obtained = cur_time;
391 #endif
392  ip->client->new->expiry += cur_time;
393  /* Lease lengths can never be negative. */
394  if (ip->client->new->expiry < cur_time)
395  ip->client->new->expiry = TIME_MAX;
396  ip->client->new->renewal += cur_time;
397  if (ip->client->new->renewal < cur_time)
398  ip->client->new->renewal = TIME_MAX;
399  ip->client->new->rebind += cur_time;
400  if (ip->client->new->rebind < cur_time)
401  ip->client->new->rebind = TIME_MAX;
402 
403  bind_lease(ip);
404 }
void send_request(void *ipp)
Definition: dhclient.c:1091
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define DHO_DHCP_LEASE_TIME
Definition: dhcp.h:147
struct client_state * client
Definition: dhcpd.h:238
time_t cur_time
__u16 time
Definition: mkdosfs.c:366
void cancel_timeout(void(*where)(void *), void *what)
Definition: dispatch.c:317
struct dhcp_packet * raw
Definition: dhcpd.h:136
void bind_lease(struct interface_info *ip)
Definition: dhclient.c:588
int note(char *format,...)
Definition: util.c:12
#define TIME_MAX
Definition: dhclient.c:90
struct interface_info * interface
Definition: dhcpd.h:142
Definition: dhcpd.h:135
Definition: dhcpd.h:61
#define DHO_DHCP_RENEWAL_TIME
Definition: dhcp.h:154
#define DHO_DHCP_REBINDING_TIME
Definition: dhcp.h:155
struct client_lease * packet_to_lease(struct packet *packet)
Definition: dhclient.c:837
__kernel_time_t time_t
Definition: linux.h:252
char * piaddr(struct iaddr addr)
Definition: util.c:6
u_int32_t getULong(unsigned char *data)
Definition: util.c:96
struct iaddr client_addr
Definition: dhcpd.h:141
#define DHCP_DEFAULT_LEASE_TIME
Definition: rosdhcp.h:30

◆ dhcpnak()

void dhcpnak ( struct packet )

Definition at line 923 of file dhclient.c.

Referenced by dhcp().

924 {
925  struct interface_info *ip = packet->interface;
926 
927  /* If we're not receptive to an offer right now, or if the offer
928  has an unrecognizable transaction id, then just drop it. */
929  if (packet->interface->client->xid != packet->raw->xid ||
930  (packet->interface->hw_address.hlen != packet->raw->hlen) ||
931  (memcmp(packet->interface->hw_address.haddr,
932  packet->raw->chaddr, packet->raw->hlen)))
933  return;
934 
935  if (ip->client->state != S_REBOOTING &&
936  ip->client->state != S_REQUESTING &&
937  ip->client->state != S_RENEWING &&
938  ip->client->state != S_REBINDING)
939  return;
940 
941  note("DHCPNAK from %s", piaddr(packet->client_addr));
942 
943  if (!ip->client->active) {
944  note("DHCPNAK with no active lease.\n");
945  return;
946  }
947 
948  free_client_lease(ip->client->active);
949  ip->client->active = NULL;
950 
951  /* Stop sending DHCPREQUEST packets... */
953 
954  ip->client->state = S_INIT;
955  state_init(ip);
956 }
void send_request(void *ipp)
Definition: dhclient.c:1091
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
Definition: dhcpd.h:172
struct client_state * client
Definition: dhcpd.h:238
void cancel_timeout(void(*where)(void *), void *what)
Definition: dispatch.c:317
struct dhcp_packet * raw
Definition: dhcpd.h:136
int note(char *format,...)
Definition: util.c:12
smooth NULL
Definition: ftsmooth.c:416
struct interface_info * interface
Definition: dhcpd.h:142
Definition: dhcpd.h:135
Definition: dhcpd.h:61
char * piaddr(struct iaddr addr)
Definition: util.c:6
struct iaddr client_addr
Definition: dhcpd.h:141
void state_init(void *ipp)
Definition: dhclient.c:218
void free_client_lease(struct client_lease *lease)
Definition: dhclient.c:1493

◆ dhcpoffer()

void dhcpoffer ( struct packet )

Definition at line 718 of file dhclient.c.

Referenced by bootp(), and dhcp().

719 {
720  struct interface_info *ip = packet->interface;
721  struct client_lease *lease, *lp;
722  int i;
723  int arp_timeout_needed = 0, stop_selecting;
724  char *name = packet->options[DHO_DHCP_MESSAGE_TYPE].len ?
725  "DHCPOFFER" : "BOOTREPLY";
727 
728  time(&cur_time);
729 
730  /* If we're not receptive to an offer right now, or if the offer
731  has an unrecognizable transaction id, then just drop it. */
732  if (ip->client->state != S_SELECTING ||
733  packet->interface->client->xid != packet->raw->xid ||
734  (packet->interface->hw_address.hlen != packet->raw->hlen) ||
735  (memcmp(packet->interface->hw_address.haddr,
736  packet->raw->chaddr, packet->raw->hlen)))
737  return;
738 
739  note("%s from %s", name, piaddr(packet->client_addr));
740 
741 
742  /* If this lease doesn't supply the minimum required parameters,
743  blow it off. */
744  for (i = 0; ip->client->config->required_options[i]; i++) {
745  if (!packet->options[ip->client->config->
746  required_options[i]].len) {
747  note("%s isn't satisfactory.", name);
748  return;
749  }
750  }
751 
752  /* If we've already seen this lease, don't record it again. */
753  for (lease = ip->client->offered_leases;
754  lease; lease = lease->next) {
755  if (lease->address.len == sizeof(packet->raw->yiaddr) &&
756  !memcmp(lease->address.iabuf,
757  &packet->raw->yiaddr, lease->address.len)) {
758  debug("%s already seen.", name);
759  return;
760  }
761  }
762 
763  lease = packet_to_lease(packet);
764  if (!lease) {
765  note("packet_to_lease failed.");
766  return;
767  }
768 
769  /* If this lease was acquired through a BOOTREPLY, record that
770  fact. */
772  lease->is_bootp = 1;
773 
774  /* Record the medium under which this lease was offered. */
775  lease->medium = ip->client->medium;
776 
777  /* Send out an ARP Request for the offered IP address. */
778  if( !check_arp( ip, lease ) ) {
779  note("Arp check failed\n");
780  return;
781  }
782 
783  /* Figure out when we're supposed to stop selecting. */
784  stop_selecting =
785  ip->client->first_sending + ip->client->config->select_interval;
786 
787  /* If this is the lease we asked for, put it at the head of the
788  list, and don't mess with the arp request timeout. */
789  if (lease->address.len == ip->client->requested_address.len &&
790  !memcmp(lease->address.iabuf,
791  ip->client->requested_address.iabuf,
792  ip->client->requested_address.len)) {
793  lease->next = ip->client->offered_leases;
794  ip->client->offered_leases = lease;
795  } else {
796  /* If we already have an offer, and arping for this
797  offer would take us past the selection timeout,
798  then don't extend the timeout - just hope for the
799  best. */
800  if (ip->client->offered_leases &&
801  (cur_time + arp_timeout_needed) > stop_selecting)
802  arp_timeout_needed = 0;
803 
804  /* Put the lease at the end of the list. */
805  lease->next = NULL;
806  if (!ip->client->offered_leases)
807  ip->client->offered_leases = lease;
808  else {
809  for (lp = ip->client->offered_leases; lp->next;
810  lp = lp->next)
811  ; /* nothing */
812  lp->next = lease;
813  }
814  }
815 
816  /* If we're supposed to stop selecting before we've had time
817  to wait for the ARPREPLY, add some delay to wait for
818  the ARPREPLY. */
819  if (stop_selecting - cur_time < arp_timeout_needed)
820  stop_selecting = cur_time + arp_timeout_needed;
821 
822  /* If the selecting interval has expired, go immediately to
823  state_selecting(). Otherwise, time out into
824  state_selecting at the select interval. */
825  if (stop_selecting <= 0)
826  state_selecting(ip);
827  else {
828  add_timeout(stop_selecting, state_selecting, ip);
830  }
831 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define DHO_DHCP_MESSAGE_TYPE
Definition: dhcp.h:149
struct client_state * client
Definition: dhcpd.h:238
time_t cur_time
__u16 time
Definition: mkdosfs.c:366
GLenum GLclampf GLint i
Definition: glfuncs.h:14
void cancel_timeout(void(*where)(void *), void *what)
Definition: dispatch.c:317
struct dhcp_packet * raw
Definition: dhcpd.h:136
int check_arp(struct interface_info *ip, struct client_lease *lp)
Definition: dhclient.c:145
int note(char *format,...)
Definition: util.c:12
smooth NULL
Definition: ftsmooth.c:416
struct interface_info * interface
Definition: dhcpd.h:142
Definition: dhcpd.h:135
Definition: dhcpd.h:61
struct client_lease * next
Definition: dhcpd.h:154
struct option_data options[256]
Definition: dhcpd.h:144
void send_discover(void *ipp)
Definition: dhclient.c:963
void state_selecting(void *ipp)
Definition: dhclient.c:243
struct client_lease * packet_to_lease(struct packet *packet)
Definition: dhclient.c:837
__kernel_time_t time_t
Definition: linux.h:252
char * piaddr(struct iaddr addr)
Definition: util.c:6
struct string_list * medium
Definition: dhcpd.h:163
void add_timeout(time_t when, void(*where)(void *), void *what)
Definition: dispatch.c:254
struct iaddr client_addr
Definition: dhcpd.h:141
Definition: name.c:36
struct iaddr address
Definition: dhcpd.h:156
unsigned int is_bootp
Definition: dhcpd.h:165
#define debug(msg)
Definition: key_call.c:71

◆ discover_interfaces()

void discover_interfaces ( struct interface_info )

◆ dispatch()

void dispatch ( HANDLE  hStopEvent)

Definition at line 66 of file dispatch.c.

Referenced by database_invoke(), ICreateTypeInfo2_fnSetTypeFlags(), InstallerImpl_OpenDatabase(), InstallerImpl_OpenPackage(), InstallerImpl_Products(), InstallerImpl_RelatedProducts(), InstallerImpl_SummaryInformation(), main(), run_script(), ServiceMain(), session_invoke(), svc_create(), svc_reg(), svc_tp_create(), svc_unreg(), test_CreateTypeLib(), test_IConnectionPoint(), test_IWinHttpRequest_Invoke(), test_ParseDisplayName(), test_recinfo(), test_VarCat(), and test_VarUI1FromDisp().

67 {
68  int count, to_msec;
69  struct protocol *l;
70  time_t howlong, cur_time;
71  HANDLE Events[3];
72  int EventCount = 2;
73 
74  Events[0] = StartAdapterDiscovery();
75  if (!Events[0])
76  return;
77 
78  AdapterStateChangedEvent = Events[0];
79 
80  Events[1] = hStopEvent;
81  Events[2] = WSA_INVALID_EVENT;
82 
83  ApiLock();
84 
85  do {
86  /*
87  * Call any expired timeouts, and then if there's still
88  * a timeout registered, time out the select call then.
89  */
90  time(&cur_time);
91 
92  if (timeouts)
93  {
94  struct timeout *t;
95 
96  if (timeouts->when <= cur_time) {
97  t = timeouts;
98  timeouts = timeouts->next;
99  (*(t->func))(t->what);
100  t->next = free_timeouts;
101  free_timeouts = t;
102  continue;
103  }
104 
105  /*
106  * Figure timeout in milliseconds, and check for
107  * potential overflow, so we can cram into an
108  * int for poll, while not polling with a
109  * negative timeout and blocking indefinitely.
110  */
111  howlong = timeouts->when - cur_time;
112  if (howlong > INT_MAX / 1000)
113  howlong = INT_MAX / 1000;
114  to_msec = howlong * 1000;
115  }
116  else
117  {
118  to_msec = INFINITE;
119  }
120 
121  if (Events[2] == WSA_INVALID_EVENT && DhcpSocket != INVALID_SOCKET)
122  {
123  Events[2] = WSACreateEvent();
124  if (Events[2] != WSA_INVALID_EVENT)
125  {
126  count = WSAEventSelect(DhcpSocket, Events[2], FD_READ | FD_CLOSE);
127  if (count != NO_ERROR)
128  {
129  WSACloseEvent(Events[2]);
130  Events[2] = WSA_INVALID_EVENT;
131  }
132  else
133  {
134  EventCount = 3;
135  }
136  }
137  }
138  else if (Events[2] != WSA_INVALID_EVENT && DhcpSocket == INVALID_SOCKET)
139  {
140  WSACloseEvent(Events[2]);
141  Events[2] = WSA_INVALID_EVENT;
142 
143  EventCount = 2;
144  }
145 
146  ApiUnlock();
147  count = WaitForMultipleObjects(EventCount,
148  Events,
149  FALSE,
150  to_msec);
151  ApiLock();
152  if (count == WAIT_OBJECT_0)
153  {
154  /* Adapter state change */
155  continue;
156  }
157  else if (count == WAIT_OBJECT_0 + 1)
158  {
159  /* Stop event signalled */
160  break;
161  }
162  else if (count == WAIT_OBJECT_0 + 2)
163  {
164  /* Packet received */
165 
166  /* WSA events are manual reset events */
167  WSAResetEvent(Events[2]);
168  }
169  else
170  {
171  /* Timeout */
172  continue;
173  }
174 
175  for (l = protocols; l; l = l->next) {
176  struct interface_info *ip;
177  ip = l->local;
178  if (ip && (l->handler != got_one ||
179  !ip->dead)) {
180  DH_DbgPrint(MID_TRACE,("Handling %x\n", l));
181  (*(l->handler))(l);
182  }
183  }
184  } while (1);
185 
187  CloseHandle(Events[0]);
188  CloseHandle(Events[1]);
189  WSACloseEvent(Events[2]);
190 
191  ApiUnlock();
192 }
#define CloseHandle
Definition: compat.h:398
#define MID_TRACE
Definition: debug.h:15
#define INT_MAX
Definition: limits.h:40
HANDLE AdapterStateChangedEvent
Definition: dispatch.c:51
GLuint GLuint GLsizei count
Definition: gl.h:1545
void(* func)(void *)
Definition: dhcpd.h:248
time_t cur_time
GLdouble GLdouble t
Definition: gl.h:2047
void got_one(struct protocol *l)
Definition: dispatch.c:195
#define FD_READ
Definition: winsock.h:405
Definition: dhcpd.h:245
__u16 time
Definition: mkdosfs.c:366
#define NO_ERROR
Definition: dderror.h:5
DWORD WINAPI WaitForMultipleObjects(IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds)
Definition: synch.c:151
void * local
Definition: dhcpd.h:256
BOOL WSAAPI WSAResetEvent(IN WSAEVENT hEvent)
Definition: event.c:53
#define WSA_INVALID_EVENT
Definition: winsock2.h:595
HANDLE hStopEvent
Definition: dhcpcsvc.c:19
int ip[4]
Definition: rtl.c:1176
INT WSAAPI WSAEventSelect(IN SOCKET s, IN WSAEVENT hEventObject, IN LONG lNetworkEvents)
Definition: select.c:182
BOOL WSAAPI WSACloseEvent(IN WSAEVENT hEvent)
Definition: event.c:23
smooth NULL
Definition: ftsmooth.c:416
#define DH_DbgPrint(_t_, _x_)
Definition: debug.h:49
r l[0]
Definition: byte_order.h:167
#define WAIT_OBJECT_0
Definition: winbase.h:387
#define FD_CLOSE
Definition: winsock.h:410
#define INVALID_SOCKET
Definition: winsock.h:332
HANDLE StartAdapterDiscovery(VOID)
Definition: adapter.c:471
static struct timeout * free_timeouts
Definition: dispatch.c:54
struct timeout * next
Definition: dhcpd.h:246
SOCKET DhcpSocket
Definition: adapter.c:3
WSAEVENT WSAAPI WSACreateEvent(VOID)
Definition: event.c:42
HANDLE Events[2]
Definition: schedsvc.c:40
__kernel_time_t time_t
Definition: linux.h:252
struct protocol * protocols
Definition: dispatch.c:52
struct protocol * next
Definition: dhcpd.h:253
void(* handler)(struct protocol *)
Definition: dhcpd.h:255
VOID ApiUnlock()
Definition: api.c:26
void * what
Definition: dhcpd.h:249
struct timeout * timeouts
Definition: dispatch.c:53
#define INFINITE
Definition: serial.h:102
VOID ApiLock()
Definition: api.c:22

◆ dispatch_imsg()

void dispatch_imsg ( int  )

◆ do_packet()

void do_packet ( struct interface_info ,
struct dhcp_packet ,
int  ,
unsigned  int,
struct iaddr  ,
struct hardware  
)

Definition at line 687 of file options.c.

Referenced by init_client().

689 {
690  struct packet tp;
691  int i;
692 
693  if (packet->hlen > sizeof(packet->chaddr)) {
694  note("Discarding packet with invalid hlen.");
695  return;
696  }
697 
698  memset(&tp, 0, sizeof(tp));
699  tp.raw = packet;
700  tp.packet_length = len;
701  tp.client_port = from_port;
702  tp.client_addr = from;
703  tp.interface = interface;
704  tp.haddr = hfrom;
705 
706  parse_options(&tp);
707  if (tp.options_valid &&
708  tp.options[DHO_DHCP_MESSAGE_TYPE].data)
709  tp.packet_type = tp.options[DHO_DHCP_MESSAGE_TYPE].data[0];
710  if (tp.packet_type)
711  dhcp(&tp);
712  else
713  bootp(&tp);
714 
715  /* Free the data associated with the options. */
716  for (i = 0; i < 256; i++)
717  if (tp.options[i].len && tp.options[i].data)
718  free(tp.options[i].data);
719 }
UCHAR packet[_PAGE_SIZE]
Definition: serial.c:53
#define free
Definition: debug_ros.c:5
#define DHO_DHCP_MESSAGE_TYPE
Definition: dhcp.h:149
void bootp(struct packet *packet)
Definition: dhclient.c:662
_In_ UINT64 _In_ UINT64 _In_ UINT64 _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2630
GLenum GLclampf GLint i
Definition: glfuncs.h:14
int note(char *format,...)
Definition: util.c:12
Definition: dhcpd.h:135
GLenum GLsizei len
Definition: glext.h:6722
#define interface
Definition: basetyps.h:61
void dhcp(struct packet *packet)
Definition: dhclient.c:682
void parse_options(struct packet *)
Definition: options.c:59
CardRegion * from
Definition: spigame.cpp:19
#define memset(x, y, z)
Definition: compat.h:39

◆ error()

void error ( char ,
  ... 
)

Definition at line 817 of file uimain.c.

818 {
819  va_list ap;
820  char text[512];
821  char text1[512];
822 
823  sprintf(text1, "ERROR: ");
824  va_start(ap, format);
825  vsprintf(text, format, ap);
826  va_end(ap);
827  strcat(text1, text);
828  mi_error(text1);
829 }
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
const WCHAR * text
Definition: package.c:1827
void mi_error(char *msg)
Definition: win32.c:131
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
int __cdecl vsprintf(char *_Dest, const char *_Format, va_list _Args)
Definition: sprintf.c:733
#define va_start(ap, A)
Definition: acmsvcex.h:91
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32

◆ find_protocol_by_adapter()

struct protocol* find_protocol_by_adapter ( struct interface_info )

Definition at line 413 of file dispatch.c.

Referenced by AdapterDiscoveryThread(), DSLeaseIpAddress(), DSReleaseIpAddressLease(), DSRenewIpAddressLease(), DSStaticRefreshParams(), and IsReconnectHackNeeded().

414 {
415  struct protocol *p;
416 
417  for( p = protocols; p; p = p->next ) {
418  if( p->local == (void *)info ) return p;
419  }
420 
421  return NULL;
422 }
void * local
Definition: dhcpd.h:256
smooth NULL
Definition: ftsmooth.c:416
struct protocol * protocols
Definition: dispatch.c:52
struct protocol * next
Definition: dhcpd.h:253
GLfloat GLfloat p
Definition: glext.h:8902

◆ free_client_lease()

void free_client_lease ( struct client_lease )

Definition at line 1493 of file dhclient.c.

Referenced by bind_lease(), dhcpnak(), packet_to_lease(), and state_selecting().

1494 {
1495  int i;
1496 
1497  if (lease->server_name)
1498  free(lease->server_name);
1499  if (lease->filename)
1500  free(lease->filename);
1501  for (i = 0; i < 256; i++) {
1502  if (lease->options[i].len)
1503  free(lease->options[i].data);
1504  }
1505  free(lease);
1506 }
#define free
Definition: debug_ros.c:5
GLenum GLclampf GLint i
Definition: glfuncs.h:14

◆ free_hash_bucket()

void free_hash_bucket ( struct hash_bucket ,
char  
)

Definition at line 89 of file alloc.c.

Referenced by delete_hash_entry().

90 {
91  dfree(ptr, name);
92 }
void dfree(void *ptr, char *name)
Definition: alloc.c:79
static PVOID ptr
Definition: dispmode.c:27
Definition: name.c:36

◆ getLong()

int32_t getLong ( unsigned char )

Definition at line 92 of file util.c.

Referenced by pretty_print_option().

92  {
93  return (int32_t) ntohl(*(u_int32_t*) data);
94 }
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
unsigned int u_int32_t
Definition: rosdhcp.h:35
INT32 int32_t
Definition: types.h:71
#define ntohl(x)
Definition: module.h:203

◆ getShort()

int16_t getShort ( unsigned char )

Definition at line 84 of file util.c.

Referenced by pretty_print_option().

84  {
85  return (int16_t) ntohs(*(int16_t*) data);
86 }
#define ntohs(x)
Definition: module.h:208
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
INT16 int16_t
Definition: types.h:70

◆ getULong()

u_int32_t getULong ( unsigned char )

Definition at line 96 of file util.c.

Referenced by dhcpack(), and pretty_print_option().

96  {
97  return ntohl(*(u_int32_t*)data);
98 }
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
unsigned int u_int32_t
Definition: rosdhcp.h:35
#define ntohl(x)
Definition: module.h:203

◆ getUShort()

u_int16_t getUShort ( unsigned char )

Definition at line 88 of file util.c.

Referenced by cons_options(), and pretty_print_option().

88  {
89  return (u_int16_t) ntohs(*(u_int16_t*) data);
90 }
#define ntohs(x)
Definition: module.h:208
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
unsigned short u_int16_t
Definition: rosdhcp.h:34

◆ go_daemon()

void go_daemon ( void  )

Referenced by dhcp_option_ev_name().

◆ got_one()

void got_one ( struct protocol )

Definition at line 195 of file dispatch.c.

Referenced by AdapterDiscoveryThread(), dispatch(), DSLeaseIpAddress(), DSRenewIpAddressLease(), and slurpstring().

196 {
197  struct sockaddr_in from;
198  struct hardware hfrom;
199  struct iaddr ifrom;
200  ssize_t result;
201  union {
202  /*
203  * Packet input buffer. Must be as large as largest
204  * possible MTU.
205  */
206  unsigned char packbuf[4095];
207  struct dhcp_packet packet;
208  } u;
209  struct interface_info *ip = l->local;
210  PDHCP_ADAPTER adapter;
211 
212  if ((result = receive_packet(ip, u.packbuf, sizeof(u), &from,
213  &hfrom)) == -1) {
214  warning("receive_packet failed on %s: %d", ip->name,
215  WSAGetLastError());
216  ip->errors++;
217  if (ip->errors > 20) {
218  /* our interface has gone away. */
219  warning("Interface %s no longer appears valid.",
220  ip->name);
221  ip->dead = 1;
222  closesocket(l->fd);
224  adapter = AdapterFindInfo(ip);
225  if (adapter) {
226  RemoveEntryList(&adapter->ListEntry);
227  free(adapter);
228  }
229  }
230  return;
231  }
232  if (result == 0)
233  return;
234 
235  if (bootp_packet_handler) {
236  ifrom.len = 4;
237  memcpy(ifrom.iabuf, &from.sin_addr, ifrom.len);
238 
239 
240  adapter = AdapterFindByHardwareAddress(u.packet.chaddr,
241  u.packet.hlen);
242 
243  if (!adapter) {
244  warning("Discarding packet with a non-matching target physical address\n");
245  return;
246  }
247 
248  (*bootp_packet_handler)(&adapter->DhclientInfo, &u.packet, result,
249  from.sin_port, ifrom, &hfrom);
250  }
251 }
char name[IFNAMSIZ]
Definition: dhcpd.h:231
#define free
Definition: debug_ros.c:5
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble * u
Definition: glfuncs.h:88
void remove_protocol(struct protocol *proto)
Definition: dispatch.c:360
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
#define closesocket
Definition: main.c:39
PDHCP_ADAPTER AdapterFindInfo(struct interface_info *ip)
Definition: adapter.c:541
r l[0]
Definition: byte_order.h:167
Definition: dhcpd.h:135
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
Definition: dhcpd.h:61
int errors
Definition: dhcpd.h:240
void(* bootp_packet_handler)(struct interface_info *, struct dhcp_packet *, int, unsigned int, struct iaddr, struct hardware *)
Definition: dispatch.c:55
Definition: dhcpd.h:125
struct interface_info DhclientInfo
Definition: rosdhcp.h:71
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
int ssize_t
Definition: rosdhcp.h:48
PDHCP_ADAPTER AdapterFindByHardwareAddress(u_int8_t haddr[16], u_int8_t hlen)
Definition: adapter.c:555
LIST_ENTRY ListEntry
Definition: rosdhcp.h:65
ssize_t receive_packet(struct interface_info *ip, unsigned char *packet_data, size_t packet_len, struct sockaddr_in *dest, struct hardware *hardware)
Definition: socket.c:29
CardRegion * from
Definition: spigame.cpp:19
GLuint64EXT * result
Definition: glext.h:11304
#define warning(s)
Definition: debug.h:71

◆ hash_lookup()

unsigned char* hash_lookup ( struct hash_table ,
unsigned char ,
int   
)

Definition at line 144 of file hash.c.

148 {
149  int hashno;
150  struct hash_bucket *bp;
151 
152  if (!table)
153  return (unsigned char *)0;
154 
155  if (!len)
156  len = strlen ((char *)name);
157 
158  hashno = do_hash (name, len, table -> hash_count);
159 
160  for (bp = table -> buckets [hashno]; bp; bp = bp -> next) {
161  if (len == bp -> len && !memcmp (bp -> name, name, len))
162  return bp -> value;
163  }
164  return (unsigned char *)0;
165 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static __inline int do_hash(unsigned char *name, int len, int size)
Definition: hash.c:63
GLenum GLsizei len
Definition: glext.h:6722
GLsizei const GLfloat * value
Definition: glext.h:6069
static unsigned __int64 next
Definition: rand_nt.c:6
Definition: name.c:36

◆ if_register_bpf()

int if_register_bpf ( struct interface_info )

◆ if_register_receive()

void if_register_receive ( struct interface_info )

Definition at line 590 of file adapter.c.

590  {
591 }

◆ if_register_send()

void if_register_send ( struct interface_info )

Definition at line 586 of file adapter.c.

586  {
587 
588 }

◆ initialize_universes()

void initialize_universes ( void  )

Definition at line 674 of file tables.c.

675 {
676  int i;
677 
678  dhcp_universe.name = "dhcp";
679  dhcp_universe.hash = new_hash ();
680  if (!dhcp_universe.hash)
681  error ("Can't allocate dhcp option hash table.");
682  for (i = 0; i < 256; i++) {
683  dhcp_universe.options [i] = &dhcp_options [i];
684  add_hash (dhcp_universe.hash,
685  (unsigned char *)dhcp_options [i].name, 0,
686  (unsigned char *)&dhcp_options [i]);
687  }
688  universe_hash.hash_count = DEFAULT_HASH_SIZE;
690  (unsigned char *)dhcp_universe.name, 0,
691  (unsigned char *)&dhcp_universe);
692 }
#define error(str)
Definition: mkdosfs.c:1605
struct hash_table * new_hash()
Definition: hash.c:53
#define DEFAULT_HASH_SIZE
Definition: dhcpd.h:259
struct dhcp_option dhcp_options[256]
Definition: tables.c:68
GLenum GLclampf GLint i
Definition: glfuncs.h:14
struct hash_table universe_hash
Definition: tables.c:672
struct universe dhcp_universe
Definition: tables.c:67
void add_hash(struct hash_table *table, unsigned char *name, int len, unsigned char *pointer)
Definition: hash.c:82

◆ interface_link_status()

int interface_link_status ( char )

Definition at line 425 of file dispatch.c.

426 {
427  return (1);
428 }

◆ interface_or_dummy()

struct interface_info* interface_or_dummy ( char )

◆ make_client_config()

void make_client_config ( struct interface_info ,
struct client_config  
)

◆ make_client_state()

void make_client_state ( struct interface_info )

◆ make_decline()

void make_decline ( struct interface_info ,
struct client_lease  
)

Definition at line 1419 of file dhclient.c.

1420 {
1421  struct tree_cache *options[256], message_type_tree;
1422  struct tree_cache requested_address_tree;
1423  struct tree_cache server_id_tree, client_id_tree;
1424  unsigned char decline = DHCPDECLINE;
1425  int i;
1426 
1427  memset(options, 0, sizeof(options));
1428  memset(&ip->client->packet, 0, sizeof(ip->client->packet));
1429 
1430  /* Set DHCP_MESSAGE_TYPE to DHCPDECLINE */
1432  options[i] = &message_type_tree;
1433  options[i]->value = &decline;
1434  options[i]->len = sizeof(decline);
1435  options[i]->buf_size = sizeof(decline);
1436  options[i]->timeout = 0xFFFFFFFF;
1437 
1438  /* Send back the server identifier... */
1440  options[i] = &server_id_tree;
1441  options[i]->value = lease->options[i].data;
1442  options[i]->len = lease->options[i].len;
1443  options[i]->buf_size = lease->options[i].len;
1444  options[i]->timeout = 0xFFFFFFFF;
1445 
1446  /* Send back the address we're declining. */
1448  options[i] = &requested_address_tree;
1449  options[i]->value = lease->address.iabuf;
1450  options[i]->len = lease->address.len;
1451  options[i]->buf_size = lease->address.len;
1452  options[i]->timeout = 0xFFFFFFFF;
1453 
1454  /* Send the uid if the user supplied one. */
1456  if (ip->client->config->send_options[i].len) {
1457  options[i] = &client_id_tree;
1458  options[i]->value = ip->client->config->send_options[i].data;
1459  options[i]->len = ip->client->config->send_options[i].len;
1460  options[i]->buf_size = ip->client->config->send_options[i].len;
1461  options[i]->timeout = 0xFFFFFFFF;
1462  }
1463 
1464 
1465  /* Set up the option buffer... */
1466  ip->client->packet_length = cons_options(NULL, &ip->client->packet, 0,
1467  options, 0, 0, 0, NULL, 0);
1468  if (ip->client->packet_length < BOOTP_MIN_LEN)
1469  ip->client->packet_length = BOOTP_MIN_LEN;
1470 
1471  ip->client->packet.op = BOOTREQUEST;
1472  ip->client->packet.htype = ip->hw_address.htype;
1473  ip->client->packet.hlen = ip->hw_address.hlen;
1474  ip->client->packet.hops = 0;
1475  ip->client->packet.xid = ip->client->xid;
1476  ip->client->packet.secs = 0; /* Filled in by send_request. */
1477  ip->client->packet.flags = 0;
1478 
1479  /* ciaddr must always be zero. */
1480  memset(&ip->client->packet.ciaddr, 0,
1481  sizeof(ip->client->packet.ciaddr));
1482  memset(&ip->client->packet.yiaddr, 0,
1483  sizeof(ip->client->packet.yiaddr));
1484  memset(&ip->client->packet.siaddr, 0,
1485  sizeof(ip->client->packet.siaddr));
1486  memset(&ip->client->packet.giaddr, 0,
1487  sizeof(ip->client->packet.giaddr));
1488  memcpy(ip->client->packet.chaddr,
1489  ip->hw_address.haddr, ip->hw_address.hlen);
1490 }
#define DHO_DHCP_MESSAGE_TYPE
Definition: dhcp.h:149
int cons_options(struct packet *inpacket, struct dhcp_packet *outpacket, int mms, struct tree_cache **options, int overload, int terminate, int bootpp, u_int8_t *prl, int prl_len)
Definition: options.c:199
#define BOOTP_MIN_LEN
Definition: dhcp.h:54
int len
Definition: tree.h:50
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define DHO_DHCP_CLIENT_IDENTIFIER
Definition: dhcp.h:157
smooth NULL
Definition: ftsmooth.c:416
Definition: dhcpd.h:61
#define BOOTREQUEST
Definition: dhcp.h:78
#define DHCPDECLINE
Definition: dhcp.h:165
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
int buf_size
Definition: tree.h:51
unsigned char * value
Definition: tree.h:49
#define DHO_DHCP_SERVER_IDENTIFIER
Definition: dhcp.h:150
#define DHO_DHCP_REQUESTED_ADDRESS
Definition: dhcp.h:146
#define memset(x, y, z)
Definition: compat.h:39
time_t timeout
Definition: tree.h:52

◆ make_discover()

void make_discover ( struct interface_info ,
struct client_lease  
)

Definition at line 1234 of file dhclient.c.

Referenced by state_init().

1235 {
1236  unsigned char discover = DHCPDISCOVER;
1237  struct tree_cache *options[256];
1238  struct tree_cache option_elements[256];
1239  int i;
1240  ULONG foo = (ULONG) GetTickCount();
1241 
1242  memset(option_elements, 0, sizeof(option_elements));
1243  memset(options, 0, sizeof(options));
1244  memset(&ip->client->packet, 0, sizeof(ip->client->packet));
1245 
1246  /* Set DHCP_MESSAGE_TYPE to DHCPDISCOVER */
1248  options[i] = &option_elements[i];
1249  options[i]->value = &discover;
1250  options[i]->len = sizeof(discover);
1251  options[i]->buf_size = sizeof(discover);
1252  options[i]->timeout = 0xFFFFFFFF;
1253 
1254  /* Request the options we want */
1256  options[i] = &option_elements[i];
1257  options[i]->value = ip->client->config->requested_options;
1258  options[i]->len = ip->client->config->requested_option_count;
1259  options[i]->buf_size =
1260  ip->client->config->requested_option_count;
1261  options[i]->timeout = 0xFFFFFFFF;
1262 
1263  /* If we had an address, try to get it again. */
1264  if (lease) {
1265  ip->client->requested_address = lease->address;
1267  options[i] = &option_elements[i];
1268  options[i]->value = lease->address.iabuf;
1269  options[i]->len = lease->address.len;
1270  options[i]->buf_size = lease->address.len;
1271  options[i]->timeout = 0xFFFFFFFF;
1272  } else
1273  ip->client->requested_address.len = 0;
1274 
1275  /* Send any options requested in the config file. */
1276  for (i = 0; i < 256; i++)
1277  if (!options[i] &&
1278  ip->client->config->send_options[i].data) {
1279  options[i] = &option_elements[i];
1280  options[i]->value =
1281  ip->client->config->send_options[i].data;
1282  options[i]->len =
1283  ip->client->config->send_options[i].len;
1284  options[i]->buf_size =
1285  ip->client->config->send_options[i].len;
1286  options[i]->timeout = 0xFFFFFFFF;
1287  }
1288 
1289  /* Set up the option buffer... */
1290  ip->client->packet_length = cons_options(NULL, &ip->client->packet, 0,
1291  options, 0, 0, 0, NULL, 0);
1292  if (ip->client->packet_length < BOOTP_MIN_LEN)
1293  ip->client->packet_length = BOOTP_MIN_LEN;
1294 
1295  ip->client->packet.op = BOOTREQUEST;
1296  ip->client->packet.htype = ip->hw_address.htype;
1297  ip->client->packet.hlen = ip->hw_address.hlen;
1298  ip->client->packet.hops = 0;
1299  ip->client->packet.xid = RtlRandom(&foo);
1300  ip->client->packet.secs = 0; /* filled in by send_discover. */
1301  ip->client->packet.flags = 0;
1302 
1303  memset(&(ip->client->packet.ciaddr),
1304  0, sizeof(ip->client->packet.ciaddr));
1305  memset(&(ip->client->packet.yiaddr),
1306  0, sizeof(ip->client->packet.yiaddr));
1307  memset(&(ip->client->packet.siaddr),
1308  0, sizeof(ip->client->packet.siaddr));
1309  memset(&(ip->client->packet.giaddr),
1310  0, sizeof(ip->client->packet.giaddr));
1311  memcpy(ip->client->packet.chaddr,
1312  ip->hw_address.haddr, ip->hw_address.hlen);
1313 }
NTSYSAPI ULONG NTAPI RtlRandom(_Inout_ PULONG Seed)
#define DHO_DHCP_MESSAGE_TYPE
Definition: dhcp.h:149
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
int cons_options(struct packet *inpacket, struct dhcp_packet *outpacket, int mms, struct tree_cache **options, int overload, int terminate, int bootpp, u_int8_t *prl, int prl_len)
Definition: options.c:199
#define DHO_DHCP_PARAMETER_REQUEST_LIST
Definition: dhcp.h:151
#define BOOTP_MIN_LEN
Definition: dhcp.h:54
int len
Definition: tree.h:50
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define DHCPDISCOVER
Definition: dhcp.h:162
smooth NULL
Definition: ftsmooth.c:416
Definition: dhcpd.h:61
#define BOOTREQUEST
Definition: dhcp.h:78
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
int buf_size
Definition: tree.h:51
unsigned char * value
Definition: tree.h:49
#define DHO_DHCP_REQUESTED_ADDRESS
Definition: dhcp.h:146
unsigned int ULONG
Definition: retypes.h:1
#define memset(x, y, z)
Definition: compat.h:39
time_t timeout
Definition: tree.h:52

◆ make_request()

void make_request ( struct interface_info ,
struct client_lease  
)

Definition at line 1317 of file dhclient.c.

Referenced by state_bound(), state_reboot(), and state_selecting().

1318 {
1319  unsigned char request = DHCPREQUEST;
1320  struct tree_cache *options[256];
1321  struct tree_cache option_elements[256];
1322  int i;
1323 
1324  memset(options, 0, sizeof(options));
1325  memset(&ip->client->packet, 0, sizeof(ip->client->packet));
1326 
1327  /* Set DHCP_MESSAGE_TYPE to DHCPREQUEST */
1329  options[i] = &option_elements[i];
1330  options[i]->value = &request;
1331  options[i]->len = sizeof(request);
1332  options[i]->buf_size = sizeof(request);
1333  options[i]->timeout = 0xFFFFFFFF;
1334 
1335  /* Request the options we want */
1337  options[i] = &option_elements[i];
1338  options[i]->value = ip->client->config->requested_options;
1339  options[i]->len = ip->client->config->requested_option_count;
1340  options[i]->buf_size =
1341  ip->client->config->requested_option_count;
1342  options[i]->timeout = 0xFFFFFFFF;
1343 
1344  /* If we are requesting an address that hasn't yet been assigned
1345  to us, use the DHCP Requested Address option. */
1346  if (ip->client->state == S_REQUESTING) {
1347  /* Send back the server identifier... */
1349  options[i] = &option_elements[i];
1350  options[i]->value = lease->options[i].data;
1351  options[i]->len = lease->options[i].len;
1352  options[i]->buf_size = lease->options[i].len;
1353  options[i]->timeout = 0xFFFFFFFF;
1354  }
1355  if (ip->client->state == S_REQUESTING ||
1356  ip->client->state == S_REBOOTING) {
1357  ip->client->requested_address = lease->address;
1359  options[i] = &option_elements[i];
1360  options[i]->value = lease->address.iabuf;
1361  options[i]->len = lease->address.len;
1362  options[i]->buf_size = lease->address.len;
1363  options[i]->timeout = 0xFFFFFFFF;
1364  } else
1365  ip->client->requested_address.len = 0;
1366 
1367  /* Send any options requested in the config file. */
1368  for (i = 0; i < 256; i++)
1369  if (!options[i] &&
1370  ip->client->config->send_options[i].data) {
1371  options[i] = &option_elements[i];
1372  options[i]->value =
1373  ip->client->config->send_options[i].data;
1374  options[i]->len =
1375  ip->client->config->send_options[i].len;
1376  options[i]->buf_size =
1377  ip->client->config->send_options[i].len;
1378  options[i]->timeout = 0xFFFFFFFF;
1379  }
1380 
1381  /* Set up the option buffer... */
1382  ip->client->packet_length = cons_options(NULL, &ip->client->packet, 0,
1383  options, 0, 0, 0, NULL, 0);
1384  if (ip->client->packet_length < BOOTP_MIN_LEN)
1385  ip->client->packet_length = BOOTP_MIN_LEN;
1386 
1387  ip->client->packet.op = BOOTREQUEST;
1388  ip->client->packet.htype = ip->hw_address.htype;
1389  ip->client->packet.hlen = ip->hw_address.hlen;
1390  ip->client->packet.hops = 0;
1391  ip->client->packet.xid = ip->client->xid;
1392  ip->client->packet.secs = 0; /* Filled in by send_request. */
1393 
1394  /* If we own the address we're requesting, put it in ciaddr;
1395  otherwise set ciaddr to zero. */
1396  if (ip->client->state == S_BOUND ||
1397  ip->client->state == S_RENEWING ||
1398  ip->client->state == S_REBINDING) {
1399  memcpy(&ip->client->packet.ciaddr,
1400  lease->address.iabuf, lease->address.len);
1401  ip->client->packet.flags = 0;
1402  } else {
1403  memset(&ip->client->packet.ciaddr, 0,
1404  sizeof(ip->client->packet.ciaddr));
1405  ip->client->packet.flags = 0;
1406  }
1407 
1408  memset(&ip->client->packet.yiaddr, 0,
1409  sizeof(ip->client->packet.yiaddr));
1410  memset(&ip->client->packet.siaddr, 0,
1411  sizeof(ip->client->packet.siaddr));
1412  memset(&ip->client->packet.giaddr, 0,
1413  sizeof(ip->client->packet.giaddr));
1414  memcpy(ip->client->packet.chaddr,
1415  ip->hw_address.haddr, ip->hw_address.hlen);
1416 }
Definition: dhcpd.h:175
#define DHO_DHCP_MESSAGE_TYPE
Definition: dhcp.h:149
int cons_options(struct packet *inpacket, struct dhcp_packet *outpacket, int mms, struct tree_cache **options, int overload, int terminate, int bootpp, u_int8_t *prl, int prl_len)
Definition: options.c:199
#define DHO_DHCP_PARAMETER_REQUEST_LIST
Definition: dhcp.h:151
#define BOOTP_MIN_LEN
Definition: dhcp.h:54
int len
Definition: tree.h:50
GLenum GLclampf GLint i
Definition: glfuncs.h:14
smooth NULL
Definition: ftsmooth.c:416
Definition: dhcpd.h:61
#define BOOTREQUEST
Definition: dhcp.h:78
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define DHCPREQUEST
Definition: dhcp.h:164
int buf_size
Definition: tree.h:51
unsigned char * value
Definition: tree.h:49
#define DHO_DHCP_SERVER_IDENTIFIER
Definition: dhcp.h:150
Definition: tftpd.h:85
#define DHO_DHCP_REQUESTED_ADDRESS
Definition: dhcp.h:146
#define memset(x, y, z)
Definition: compat.h:39
time_t timeout
Definition: tree.h:52

◆ new_hash()

struct hash_table* new_hash ( void  )

Definition at line 53 of file hash.c.

Referenced by initialize_universes().

54 {
56  if (!rv)
57  return rv;
58  memset (&rv -> buckets [0], 0,
59  DEFAULT_HASH_SIZE * sizeof (struct hash_bucket *));
60  return rv;
61 }
struct hash_bucket * buckets[DEFAULT_HASH_SIZE]
Definition: dhcpd.h:270
struct hash_table * new_hash_table(int count)
Definition: alloc.c:57
#define DEFAULT_HASH_SIZE
Definition: dhcpd.h:259
#define memset(x, y, z)
Definition: compat.h:39

◆ new_hash_bucket()

struct hash_bucket* new_hash_bucket ( void  )

Definition at line 71 of file alloc.c.

Referenced by add_hash().

72 {
73  struct hash_bucket *rval = calloc(1, sizeof(struct hash_bucket));
74 
75  return (rval);
76 }
float rval
Definition: cylfrac.c:48
#define calloc
Definition: rosglue.h:14

◆ new_hash_table()

struct hash_table* new_hash_table ( int  )

Definition at line 57 of file alloc.c.

Referenced by new_hash().

58 {
59  struct hash_table *rval;
60 
61  rval = calloc(1, sizeof(struct hash_table) -
62  (DEFAULT_HASH_SIZE * sizeof(struct hash_bucket *)) +
63  (count * sizeof(struct hash_bucket *)));
64  if (rval == NULL)
65  return (NULL);
66  rval->hash_count = count;
67  return (rval);
68 }
int hash_count
Definition: dhcpd.h:269
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define DEFAULT_HASH_SIZE
Definition: dhcpd.h:259
smooth NULL
Definition: ftsmooth.c:416
float rval
Definition: cylfrac.c:48
#define calloc
Definition: rosglue.h:14

◆ new_parse()

void new_parse ( char )

◆ new_string_list()

struct string_list* new_string_list ( size_t  size)

Definition at line 46 of file alloc.c.

47 {
48  struct string_list *rval;
49 
50  rval = calloc(1, sizeof(struct string_list) + size);
51  if (rval != NULL)
52  rval->string = ((char *)rval) + sizeof(struct string_list);
53  return (rval);
54 }
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
float rval
Definition: cylfrac.c:48
#define calloc
Definition: rosglue.h:14
char * string
Definition: dhcpd.h:122

◆ next_token()

int next_token ( char **  ,
FILE  
)

Referenced by get_token(), and wcstok_s().

◆ note()

void int int note ( char ,
  ... 
)

◆ packet_to_lease()

struct client_lease* packet_to_lease ( struct packet )

Definition at line 837 of file dhclient.c.

Referenced by dhcpack(), and dhcpoffer().

838 {
839  struct client_lease *lease;
840  int i;
841 
842  lease = malloc(sizeof(struct client_lease));
843 
844  if (!lease) {
845  warning("dhcpoffer: no memory to record lease.");
846  return (NULL);
847  }
848 
849  memset(lease, 0, sizeof(*lease));
850 
851  /* Copy the lease options. */
852  for (i = 0; i < 256; i++) {
853  if (packet->options[i].len) {
854  lease->options[i].data =
855  malloc(packet->options[i].len + 1);
856  if (!lease->options[i].data) {
857  warning("dhcpoffer: no memory for option %d", i);
858  free_client_lease(lease);
859  return (NULL);
860  } else {
861  memcpy(lease->options[i].data,
862  packet->options[i].data,
863  packet->options[i].len);
864  lease->options[i].len =
865  packet->options[i].len;
866  lease->options[i].data[lease->options[i].len] =
867  0;
868  }
869  if (!check_option(lease,i)) {
870  /* ignore a bogus lease offer */
871  warning("Invalid lease option - ignoring offer");
872  free_client_lease(lease);
873  return (NULL);
874  }
875  }
876  }
877 
878  lease->address.len = sizeof(packet->raw->yiaddr);
879  memcpy(lease->address.iabuf, &packet->raw->yiaddr, lease->address.len);
880 #ifdef __REACTOS__
881  lease->serveraddress.len = sizeof(packet->raw->siaddr);
882  memcpy(lease->serveraddress.iabuf, &packet->raw->siaddr, lease->address.len);
883 #endif
884 
885  /* If the server name was filled out, copy it. */
887  !(packet->options[DHO_DHCP_OPTION_OVERLOAD].data[0] & 2)) &&
888  packet->raw->sname[0]) {
889  lease->server_name = malloc(DHCP_SNAME_LEN + 1);
890  if (!lease->server_name) {
891  warning("dhcpoffer: no memory for server name.");
892  free_client_lease(lease);
893  return (NULL);
894  }
895  memcpy(lease->server_name, packet->raw->sname, DHCP_SNAME_LEN);
896  lease->server_name[DHCP_SNAME_LEN]='\0';
897  if (!res_hnok(lease->server_name) ) {
898  warning("Bogus server name %s", lease->server_name );
899  free_client_lease(lease);
900  return (NULL);
901  }
902 
903  }
904 
905  /* Ditto for the filename. */
907  !(packet->options[DHO_DHCP_OPTION_OVERLOAD].data[0] & 1)) &&
908  packet->raw->file[0]) {
909  /* Don't count on the NUL terminator. */
910  lease->filename = malloc(DHCP_FILE_LEN + 1);
911  if (!lease->filename) {
912  warning("dhcpoffer: no memory for filename.");
913  free_client_lease(lease);
914  return (NULL);
915  }
916  memcpy(lease->filename, packet->raw->file, DHCP_FILE_LEN);
917  lease->filename[DHCP_FILE_LEN]='\0';
918  }
919  return lease;
920 }
int check_option(struct client_lease *l, int option)
Definition: dhclient.c:1791
int res_hnok(const char *dn)
Definition: dhclient.c:1886
#define DHCP_FILE_LEN
Definition: dhcp.h:47
char * filename
Definition: dhcpd.h:162
GLenum GLclampf GLint i
Definition: glfuncs.h:14
struct dhcp_packet * raw
Definition: dhcpd.h:136
smooth NULL
Definition: ftsmooth.c:416
Definition: dhcpd.h:135
#define DHO_DHCP_OPTION_OVERLOAD
Definition: dhcp.h:148
struct option_data options[256]
Definition: dhcpd.h:144
struct option_data options[256]
Definition: dhcpd.h:166
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
struct iaddr address
Definition: dhcpd.h:156
#define malloc
Definition: debug_ros.c:4
#define DHCP_SNAME_LEN
Definition: dhcp.h:46
#define memset(x, y, z)
Definition: compat.h:39
void free_client_lease(struct client_lease *lease)
Definition: dhclient.c:1493
#define warning(s)
Definition: debug.h:71
char * server_name
Definition: dhcpd.h:157

◆ parse_client_lease_declaration()

void parse_client_lease_declaration ( FILE ,
struct client_lease ,
struct interface_info **   
)

◆ parse_client_lease_statement()

void parse_client_lease_statement ( FILE ,
int   
)

◆ parse_client_statement()

void parse_client_statement ( FILE ,
struct interface_info ,
struct client_config  
)

◆ parse_date()

time_t parse_date ( FILE )

◆ parse_hardware_param()

void parse_hardware_param ( FILE ,
struct hardware  
)

◆ parse_interface_declaration()

void parse_interface_declaration ( FILE ,
struct client_config  
)

◆ parse_ip_addr()

int parse_ip_addr ( FILE ,
struct iaddr  
)

◆ parse_lease_time()

void parse_lease_time ( FILE ,
time_t  
)

◆ parse_numeric_aggregate()

unsigned char* parse_numeric_aggregate ( FILE ,
unsigned char ,
int ,
int  ,
int  ,
int   
)

◆ parse_option_decl()

struct dhcp_option* parse_option_decl ( FILE ,
struct option_data  
)

◆ parse_option_list()

int parse_option_list ( FILE ,
u_int8_t  
)

◆ parse_reject_statement()

void parse_reject_statement ( FILE ,
struct client_config  
)

◆ parse_semi()

int parse_semi ( FILE )

◆ parse_string()

char* parse_string ( FILE )

◆ parse_string_list()

void parse_string_list ( FILE ,
struct string_list **  ,
int   
)

◆ parse_warn()

void int int int int parse_warn ( char ,
  ... 
)

◆ parse_X()

int parse_X ( FILE ,
u_int8_t ,
int   
)

◆ peek_token()

int peek_token ( char **  ,
FILE  
)

◆ piaddr()

char* piaddr ( struct iaddr  )

Definition at line 6 of file util.c.

Referenced by bind_lease(), bootp(), dhcp(), dhcpack(), dhcpnak(), dhcpoffer(), priv_script_write_params(), set_name_servers(), setup_adapter(), and write_client_lease().

6  {
7  struct sockaddr_in sa;
8  memcpy(&sa.sin_addr,addr.iabuf,sizeof(sa.sin_addr));
9  return inet_ntoa( sa.sin_addr );
10 }
#define inet_ntoa(addr)
Definition: inet.h:100
GLenum const GLvoid * addr
Definition: glext.h:9621
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static struct sockaddr_in sa
Definition: adnsresfilter.c:69

◆ pretty_print_option()

char* pretty_print_option ( unsigned  int,
unsigned char ,
int  ,
int  ,
int   
)

Definition at line 448 of file options.c.

Referenced by check_option(), priv_script_write_params(), and write_client_lease().

450 {
451  static char optbuf[32768]; /* XXX */
452  int hunksize = 0, numhunk = -1, numelem = 0;
453  char fmtbuf[32], *op = optbuf;
454  int i, j, k, opleft = sizeof(optbuf);
455  unsigned char *dp = data;
456  struct in_addr foo;
457  char comma;
458 
459  /* Code should be between 0 and 255. */
460  if (code > 255)
461  error("pretty_print_option: bad code %d", code);
462 
463  if (emit_commas)
464  comma = ',';
465  else
466  comma = ' ';
467 
468  /* Figure out the size of the data. */
469  for (i = 0; dhcp_options[code].format[i]; i++) {
470  if (!numhunk) {
471  warning("%s: Excess information in format string: %s",
473  &(dhcp_options[code].format[i]));
474  break;
475  }
476  numelem++;
477  fmtbuf[i] = dhcp_options[code].format[i];
478  switch (dhcp_options[code].format[i]) {
479  case 'A':
480  --numelem;
481  fmtbuf[i] = 0;
482  numhunk = 0;
483  break;
484  case 'X':
485  for (k = 0; k < len; k++)
486  if (!isascii(data[k]) ||
487  !isprint(data[k]))
488  break;
489  if (k == len) {
490  fmtbuf[i] = 't';
491  numhunk = -2;
492  } else {
493  fmtbuf[i] = 'x';
494  hunksize++;
495  comma = ':';
496  numhunk = 0;
497  }
498  fmtbuf[i + 1] = 0;
499  break;
500  case 't':
501  fmtbuf[i] = 't';
502  fmtbuf[i + 1] = 0;
503  numhunk = -2;
504  break;
505  case 'I':
506  case 'l':
507  case 'L':
508  hunksize += 4;
509  break;
510  case 's':
511  case 'S':
512  hunksize += 2;
513  break;
514  case 'b':
515  case 'B':
516  case 'f':
517  hunksize++;
518  break;
519  case 'e':
520  break;
521  default:
522  warning("%s: garbage in format string: %s",
524  &(dhcp_options[code].format[i]));
525  break;
526  }
527  }
528 
529  /* Check for too few bytes... */
530  if (hunksize > len) {
531  warning("%s: expecting at least %d bytes; got %d",
532  dhcp_options[code].name, hunksize, len);
533  return ("<error>");
534  }
535  /* Check for too many bytes... */
536  if (numhunk == -1 && hunksize < len)
537  warning("%s: %d extra bytes",
538  dhcp_options[code].name, len - hunksize);
539 
540  /* If this is an array, compute its size. */
541  if (!numhunk)
542  numhunk = len / hunksize;
543  /* See if we got an exact number of hunks. */
544  if (numhunk > 0 && numhunk * hunksize < len)
545  warning("%s: %d extra bytes at end of array",
546  dhcp_options[code].name, len - numhunk * hunksize);
547 
548  /* A one-hunk array prints the same as a single hunk. */
549  if (numhunk < 0)
550  numhunk = 1;
551 
552  /* Cycle through the array (or hunk) printing the data. */
553  for (i = 0; i < numhunk; i++) {
554  for (j = 0; j < numelem; j++) {
555  int opcount;
556  switch (fmtbuf[j]) {
557  case 't':
558  if (emit_quotes) {
559  *op++ = '"';
560  opleft--;
561  }
562  for (; dp < data + len; dp++) {
563  if (!isascii(*dp) ||
564  !isprint(*dp)) {
565  if (dp + 1 != data + len ||
566  *dp != 0) {
567  _snprintf(op, opleft,
568  "\\%03o", *dp);
569  op += 4;
570  opleft -= 4;
571  }
572  } else if (*dp == '"' ||
573  *dp == '\'' ||
574  *dp == '$' ||
575  *dp == '`' ||
576  *dp == '\\') {
577  *op++ = '\\';
578  *op++ = *dp;
579  opleft -= 2;
580  } else {
581  *op++ = *dp;
582  opleft--;
583  }
584  }
585  if (emit_quotes) {
586  *op++ = '"';
587  opleft--;
588  }
589 
590  *op = 0;
591  break;
592  case 'I':
593  foo.s_addr = htonl(getULong(dp));
594  strncpy(op, inet_ntoa(foo), opleft - 1);
595  op[opleft - 1] = ANSI_NULL;
596  opcount = strlen(op);
597  if (opcount >= opleft)
598  goto toobig;
599  opleft -= opcount;
600  dp += 4;
601  break;
602  case 'l':
603  opcount = _snprintf(op, opleft, "%ld",
604  (long)getLong(dp));
605  if (opcount >= opleft || opcount == -1)
606  goto toobig;
607  opleft -= opcount;
608  dp += 4;
609  break;
610  case 'L':
611  opcount = _snprintf(op, opleft, "%ld",
612  (unsigned long)getULong(dp));
613  if (opcount >= opleft || opcount == -1)
614  goto toobig;
615  opleft -= opcount;
616  dp += 4;
617  break;
618  case 's':
619  opcount = _snprintf(op, opleft, "%d",
620  getShort(dp));
621  if (opcount >= opleft || opcount == -1)
622  goto toobig;
623  opleft -= opcount;
624  dp += 2;
625  break;
626  case 'S':
627  opcount = _snprintf(op, opleft, "%d",
628  getUShort(dp));
629  if (opcount >= opleft || opcount == -1)
630  goto toobig;
631  opleft -= opcount;
632  dp += 2;
633  break;
634  case 'b':
635  opcount = _snprintf(op, opleft, "%d",
636  *(char *)dp++);
637  if (opcount >= opleft || opcount == -1)
638  goto toobig;
639  opleft -= opcount;
640  break;
641  case 'B':
642  opcount = _snprintf(op, opleft, "%d", *dp++);
643  if (opcount >= opleft || opcount == -1)
644  goto toobig;
645  opleft -= opcount;
646  break;
647  case 'x':
648  opcount = _snprintf(op, opleft, "%x", *dp++);
649  if (opcount >= opleft || opcount == -1)
650  goto toobig;
651  opleft -= opcount;
652  break;
653  case 'f':
654  opcount = (size_t) strncpy(op, *dp++ ? "true" : "false", opleft - 1);
655  op[opleft - 1] = ANSI_NULL;
656  if (opcount >= opleft)
657  goto toobig;
658  opleft -= opcount;
659  break;
660  default:
661  warning("Unexpected format code %c", fmtbuf[j]);
662  }
663  op += strlen(op);
664  opleft -= strlen(op);
665  if (opleft < 1)
666  goto toobig;
667  if (j + 1 < numelem && comma != ':') {
668  *op++ = ' ';
669  opleft--;
670  }
671  }
672  if (i + 1 < numhunk) {
673  *op++ = comma;
674  opleft--;
675  }
676  if (opleft < 1)
677  goto toobig;
678 
679  }
680  return (optbuf);
681  toobig:
682  warning("dhcp option too large");
683  return ("<error>");
684 }
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
int16_t getShort(unsigned char *data)
Definition: util.c:84
#define error(str)
Definition: mkdosfs.c:1605
#define htonl(x)
Definition: module.h:212
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
u_int16_t getUShort(unsigned char *data)
Definition: util.c:88
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
struct dhcp_option dhcp_options[256]
Definition: tables.c:68
#define _snprintf
Definition: xmlstorage.h:200
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define ANSI_NULL
UINT op
Definition: effect.c:223
#define inet_ntoa(addr)
Definition: inet.h:100
__kernel_size_t size_t
Definition: linux.h:237
int32_t getLong(unsigned char *data)
Definition: util.c:92
Definition: tcpip.h:125
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum GLsizei len
Definition: glext.h:6722
int code
Definition: i386-dis.c:3591
#define isascii
Definition: ctype.h:742
u_int32_t getULong(unsigned char *data)
Definition: util.c:96
#define isprint(c)
Definition: acclib.h:73
Definition: name.c:36
int k
Definition: mpi.c:3369
#define warning(s)
Definition: debug.h:71

◆ priv_script_go()

int priv_script_go ( void  )

◆ priv_script_init()

void priv_script_init ( struct interface_info ,
char ,
char  
)

Definition at line 1599 of file dhclient.c.

1600 {
1601  if (ip) {
1602  // XXX Do we need to do anything?
1603  }
1604 }
Definition: dhcpd.h:61

◆ priv_script_write_params()

void priv_script_write_params ( struct interface_info ,
char ,
struct client_lease  
)

Definition at line 1607 of file dhclient.c.

1608 {
1609  u_int8_t dbuf[1500];
1610  int i, len = 0;
1611 
1612 #if 0
1613  script_set_env(ip->client, prefix, "ip_address",
1614  piaddr(lease->address));
1615 #endif
1616 
1617  if (lease->options[DHO_SUBNET_MASK].len &&
1618  (lease->options[DHO_SUBNET_MASK].len <
1619  sizeof(lease->address.iabuf))) {
1620  struct iaddr netmask, subnet, broadcast;
1621 
1622  memcpy(netmask.iabuf, lease->options[DHO_SUBNET_MASK].data,
1623  lease->options[DHO_SUBNET_MASK].len);
1624  netmask.len = lease->options[DHO_SUBNET_MASK].len;
1625 
1626  subnet = subnet_number(lease->address, netmask);
1627  if (subnet.len) {
1628 #if 0
1629  script_set_env(ip->client, prefix, "network_number",
1630  piaddr(subnet));
1631 #endif
1632  if (!lease->options[DHO_BROADCAST_ADDRESS].len) {
1633  broadcast = broadcast_addr(subnet, netmask);
1634  if (broadcast.len)
1635 #if 0
1636  script_set_env(ip->client, prefix,
1637  "broadcast_address",
1638  piaddr(broadcast));
1639 #else
1640  ;
1641 #endif
1642  }
1643  }
1644  }
1645 
1646 #if 0
1647  if (lease->filename)
1648  script_set_env(ip->client, prefix, "filename", lease->filename);
1649  if (lease->server_name)
1650  script_set_env(ip->client, prefix, "server_name",
1651  lease->server_name);
1652 #endif
1653 
1654  for (i = 0; i < 256; i++) {
1655  u_int8_t *dp = NULL;
1656 
1657  if (ip->client->config->defaults[i].len) {
1658  if (lease->options[i].len) {
1659  switch (
1660  ip->client->config->default_actions[i]) {
1661  case ACTION_DEFAULT:
1662  dp = lease->options[i].data;
1663  len = lease->options[i].len;
1664  break;
1665  case ACTION_SUPERSEDE:
1666 supersede:
1667  dp = ip->client->
1668  config->defaults[i].data;
1669  len = ip->client->
1670  config->defaults[i].len;
1671  break;
1672  case ACTION_PREPEND:
1673  len = ip->client->
1674  config->defaults[i].len +
1675  lease->options[i].len;
1676  if (len >= sizeof(dbuf)) {
1677  warning("no space to %s %s",
1678  "prepend option",
1679  dhcp_options[i].name);
1680  goto supersede;
1681  }
1682  dp = dbuf;
1683  memcpy(dp,
1684  ip->client->
1685  config->defaults[i].data,
1686  ip->client->
1687  config->defaults[i].len);
1688  memcpy(dp + ip->client->
1689  config->defaults[i].len,
1690  lease->options[i].data,
1691  lease->options[i].len);
1692  dp[len] = '\0';
1693  break;
1694  case ACTION_APPEND:
1695  len = ip->client->
1696  config->defaults[i].len +
1697  lease->options[i].len + 1;
1698  if (len > sizeof(dbuf)) {
1699  warning("no space to %s %s",
1700  "append option",
1701  dhcp_options[i].name);
1702  goto supersede;
1703  }
1704  dp = dbuf;
1705  memcpy(dp,
1706  lease->options[i].data,
1707  lease->options[i].len);
1708  memcpy(dp + lease->options[i].len,
1709  ip->client->
1710  config->defaults[i].data,
1711  ip->client->
1712  config->defaults[i].len);
1713  dp[len-1] = '\0';
1714  }
1715  } else {
1716  dp = ip->client->
1717  config->defaults[i].data;
1718  len = ip->client->
1719  config->defaults[i].len;
1720  }
1721  } else if (lease->options[i].len) {
1722  len = lease->options[i].len;
1723  dp = lease->options[i].data;
1724  } else {
1725  len = 0;
1726  }
1727 #if 0
1728  if (len) {
1729  char name[256];
1730 
1731  if (dhcp_option_ev_name(name, sizeof(name),
1732  &dhcp_options[i]))
1733  script_set_env(ip->client, prefix, name,
1734  pretty_print_option(i, dp, len, 0, 0));
1735  }
1736 #endif
1737  }
1738 #if 0
1739  snprintf(tbuf, sizeof(tbuf), "%d", (int)lease->expiry);
1740  script_set_env(ip->client, prefix, "expiry", tbuf);
1741 #endif
1742 }
char * pretty_print_option(unsigned int code, unsigned char *data, int len, int emit_commas, int emit_quotes)
Definition: options.c:448
#define snprintf
Definition: wintirpc.h:48
struct dhcp_option dhcp_options[256]
Definition: tables.c:68
GLenum GLclampf GLint i
Definition: glfuncs.h:14
void script_set_env(struct client_state *, const char *, const char *, const char *)
unsigned char u_int8_t
Definition: rosdhcp.h:33
smooth NULL
Definition: ftsmooth.c:416
struct iaddr subnet_number(struct iaddr addr, struct iaddr mask)
Definition: util.c:172
Definition: dhcpd.h:61
#define DHO_SUBNET_MASK
Definition: dhcp.h:97
Definition: dhcpd.h:125
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define DHO_BROADCAST_ADDRESS
Definition: dhcp.h:124
struct iaddr broadcast_addr(struct iaddr addr, struct iaddr mask)
Definition: util.c:167
int dhcp_option_ev_name(char *buf, size_t buflen, struct dhcp_option *option)
Definition: dhclient.c:1745
char * piaddr(struct iaddr addr)
Definition: util.c:6
Definition: name.c:36
#define warning(s)
Definition: debug.h:71

◆ putLong()

void putLong ( unsigned char ,
int32_t   
)

◆ putShort()

void putShort ( unsigned char ,
int   
)

◆ putULong()

void putULong ( unsigned char ,
u_int32_t   
)

◆ putUShort()

void putUShort ( unsigned char ,
unsigned  int 
)

◆ read_client_conf()

int read_client_conf ( struct interface_info )

Definition at line 106 of file util.c.

Referenced by AdapterDiscoveryThread().

106  {
107  /* What a strange dance */
108  struct client_config *config;
109  char ComputerName [MAX_COMPUTERNAME_LENGTH + 1];
110  LPSTR lpCompName;
111  DWORD ComputerNameSize = sizeof ComputerName / sizeof ComputerName[0];
112 
113  if ((ifi!= NULL) && (ifi->client->config != NULL))
114  config = ifi->client->config;
115  else
116  {
117  warn("util.c read_client_conf poorly implemented!");
118  return 0;
119  }
120 
121 
122  GetComputerName(ComputerName, & ComputerNameSize);
123  debug("Hostname: %s, length: %lu",
124  ComputerName, ComputerNameSize);
125  /* This never gets freed since it's only called once */
126  lpCompName =
127  HeapAlloc(GetProcessHeap(), 0, ComputerNameSize + 1);
128  if (lpCompName !=NULL) {
129  memcpy(lpCompName, ComputerName, ComputerNameSize + 1);
130  /* Send our hostname, some dhcpds use this to update DNS */
131  config->send_options[DHO_HOST_NAME].data = (u_int8_t*)lpCompName;
132  config->send_options[DHO_HOST_NAME].len = ComputerNameSize;
133  debug("Hostname: %s, length: %d",
134  config->send_options[DHO_HOST_NAME].data,
135  config->send_options[DHO_HOST_NAME].len);
136  } else {
137  error("Failed to allocate heap for hostname");
138  }
139  /* Both Linux and Windows send this */
141  ifi->hw_address.haddr;
143  ifi->hw_address.hlen;
144 
145  /* Setup the requested option list */
146  config->requested_options
148  config->requested_options
150  config->requested_options
152  config->requested_options
153  [config->requested_option_count++] = DHO_ROUTERS;
154  config->requested_options
156  config->requested_options
158  config->requested_options
160  config->requested_options
162 
163  warn("util.c read_client_conf poorly implemented!");
164  return 0;
165 }
struct config_s config
#define GetComputerName
Definition: winbase.h:3614
char * LPSTR
Definition: xmlstorage.h:182
#define DHO_NTP_SERVERS
Definition: dhcp.h:138
#define DHO_ROUTERS
Definition: dhcp.h:99
#define DHO_DHCP_CLIENT_IDENTIFIER
Definition: dhcp.h:157
unsigned char u_int8_t
Definition: rosdhcp.h:33
#define DHO_TIME_OFFSET
Definition: dhcp.h:98
int warn(char *format,...)
Definition: util.c:42
smooth NULL
Definition: ftsmooth.c:416
int debug(char *format,...)
Definition: util.c:27
int requested_option_count
Definition: dhcpd.h:193
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
void error(char *format,...)
Definition: util.c:72
#define DHO_SUBNET_MASK
Definition: dhcp.h:97
unsigned long DWORD
Definition: ntddk_ex.h:95
u_int8_t requested_options[256]
Definition: dhcpd.h:192
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:240
#define DHO_BROADCAST_ADDRESS
Definition: dhcp.h:124
#define DHO_HOST_NAME
Definition: dhcp.h:108
#define DHO_DOMAIN_NAME
Definition: dhcp.h:111
#define DHO_DOMAIN_NAME_SERVERS
Definition: dhcp.h:102
struct option_data send_options[256]
Definition: dhcpd.h:190

◆ read_client_leases()

void read_client_leases ( void  )

◆ receive_packet()

ssize_t receive_packet ( struct interface_info ,
unsigned char ,
size_t  ,
struct sockaddr_in ,
struct hardware  
)

Definition at line 29 of file socket.c.

Referenced by got_one().

33  {
34  int recv_addr_size = sizeof(*dest);
35  int result =
36  recvfrom (ip -> rfdesc, (char *)packet_data, packet_len, 0,
37  (struct sockaddr *)dest, &recv_addr_size );
38  return result;
39 }
INT WSAAPI recvfrom(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags, OUT LPSOCKADDR from, IN OUT INT FAR *fromlen)
Definition: recv.c:87
Definition: dhcpd.h:61
GLfloat CONST GLvector4f CONST GLfloat GLvector4f * dest
Definition: m_xform.h:122
GLuint64EXT * result
Definition: glext.h:11304

◆ reinitialize_interfaces()

void reinitialize_interfaces ( void  )

◆ remove_protocol()

void remove_protocol ( struct protocol )

Definition at line 360 of file dispatch.c.

Referenced by AdapterDiscoveryThread(), DSLeaseIpAddress(), DSReleaseIpAddressLease(), DSRenewIpAddressLease(), DSStaticRefreshParams(), and got_one().

361 {
362  struct protocol *p, *next, *prev;
363  struct interface_info *ip = proto->local;
364  struct timeout *t, *q, *u;
365 
366  t = NULL;
367  q = timeouts;
368  while (q != NULL)
369  {
370  /* Remove all timeouts for this protocol */
371  if (q->what == ip)
372  {
373  /* Unlink the timeout from previous */
374  if (t)
375  t->next = q->next;
376  else
377  timeouts = q->next;
378 
379  /* Advance to the next timeout */
380  u = q->next;
381 
382  /* Add it to the free list */
383  q->next = free_timeouts;
384  free_timeouts = q;
385  }
386  else
387  {
388  /* Advance to the next timeout */
389  u = q->next;
390 
391  /* Update the previous pointer */
392  t = q;
393  }
394 
395  /* Advance */
396  q = u;
397  }
398 
399  prev = NULL;
400  for (p = protocols; p; p = next) {
401  next = p->next;
402  if (p == proto) {
403  if (prev)
404  prev->next = p->next;
405  else
406  protocols = p->next;
407  free(p);
408  }
409  }
410 }
#define free
Definition: debug_ros.c:5
GLdouble GLdouble t
Definition: gl.h:2047
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble * u
Definition: glfuncs.h:88
Definition: dhcpd.h:245
smooth NULL
Definition: ftsmooth.c:416
Definition: dhcpd.h:61
static struct timeout * free_timeouts
Definition: dispatch.c:54
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
struct timeout * next
Definition: dhcpd.h:246
static unsigned __int64 next
Definition: rand_nt.c:6
struct protocol * protocols
Definition: dispatch.c:52
struct protocol * next
Definition: dhcpd.h:253
void * what
Definition: dhcpd.h:249
struct timeout * timeouts
Definition: dispatch.c:53
GLfloat GLfloat p
Definition: glext.h:8902

◆ rewrite_client_leases()

void rewrite_client_leases ( struct interface_info )

Definition at line 1511 of file dhclient.c.

Referenced by write_client_lease().

1512 {
1513  struct client_lease *lp;
1514 
1515  if (!leaseFile) {
1517  if (!leaseFile)
1518  error("can't create %s", path_dhclient_db);
1519  } else {
1520  fflush(leaseFile);
1521  rewind(leaseFile);
1522  }
1523 
1524  for (lp = ifi->client->leases; lp; lp = lp->next)
1525  write_client_lease(ifi, lp, 1);
1526  if (ifi->client->active)
1527  write_client_lease(ifi, ifi->client->active, 1);
1528 
1529  fflush(leaseFile);
1530 }
#define error(str)
Definition: mkdosfs.c:1605
FILE * leaseFile
Definition: dhclient.c:1508
void write_client_lease(struct interface_info *ip, struct client_lease *lease, int rewrite)
Definition: dhclient.c:1533
char * path_dhclient_db
Definition: dhclient.c:74
_CRTIMP void __cdecl rewind(_Inout_ FILE *_File)
struct client_lease * next
Definition: dhcpd.h:154
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)

◆ script_flush_env()

void script_flush_env ( struct client_state )

◆ script_go()

int script_go ( void  )

◆ script_init()

void script_init ( char ,
struct string_list  
)

◆ script_set_env()

void script_set_env ( struct client_state ,
const char ,
const char ,
const char  
)

◆ script_write_params()

void script_write_params ( char ,
struct client_lease  
)

◆ send_decline()

void send_decline ( void )

Definition at line 1220 of file dhclient.c.

1221 {
1222  struct interface_info *ip = ipp;
1223 
1224  note("DHCPDECLINE on %s to %s port %d", ip->name,
1225  inet_ntoa(sockaddr_broadcast.sin_addr),
1226  ntohs(sockaddr_broadcast.sin_port));
1227 
1228  /* Send out a packet. */
1229  (void) send_packet(ip, &ip->client->packet, ip->client->packet_length,
1231 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
char name[IFNAMSIZ]
Definition: dhcpd.h:231
struct client_state * client
Definition: dhcpd.h:238
#define ntohs(x)
Definition: module.h:208
ssize_t send_packet(struct interface_info *ip, struct dhcp_packet *p, size_t size, struct in_addr addr, struct sockaddr_in *broadcast, struct hardware *hardware)
Definition: socket.c:9
int note(char *format,...)
Definition: util.c:12
smooth NULL
Definition: ftsmooth.c:416
#define inet_ntoa(addr)
Definition: inet.h:100
Definition: dhcpd.h:61
struct sockaddr_in sockaddr_broadcast
Definition: dhclient.c:82
struct in_addr inaddr_any
Definition: dhclient.c:81

◆ send_discover()

void send_discover ( void )

Definition at line 963 of file dhclient.c.

Referenced by dhcpoffer(), send_discover(), state_init(), and state_selecting().

964 {
965  struct interface_info *ip = ipp;
966  int interval, increase = 1;
968 
969  DH_DbgPrint(MID_TRACE,("Doing discover on interface %p\n",ip));
970 
971  time(&cur_time);
972 
973  /* Figure out how long it's been since we started transmitting. */
974  interval = cur_time - ip->client->first_sending;
975 
976  /* If we're past the panic timeout, call the script and tell it
977  we haven't found anything for this interface yet. */
978  if (interval > ip->client->config->timeout) {
979  state_panic(ip);
980  ip->client->first_sending = cur_time;
981  }
982 
983  /* If we're selecting media, try the whole list before doing
984  the exponential backoff, but if we've already received an
985  offer, stop looping, because we obviously have it right. */
986  if (!ip->client->offered_leases &&
987  ip->client->config->media) {
988  int fail = 0;
989 
990  if (ip->client->medium) {
991  ip->client->medium = ip->client->medium->next;
992  increase = 0;
993  }
994  if (!ip->client->medium) {
995  if (fail)
996  error("No valid media types for %s!", ip->name);
997  ip->client->medium = ip->client->config->media;
998  increase = 1;
999  }
1000 
1001  note("Trying medium \"%s\" %d", ip->client->medium->string,
1002  increase);
1003  /* XXX Support other media types eventually */
1004  }
1005 
1006  /*
1007  * If we're supposed to increase the interval, do so. If it's
1008  * currently zero (i.e., we haven't sent any packets yet), set
1009  * it to one; otherwise, add to it a random number between zero
1010  * and two times itself. On average, this means that it will
1011  * double with every transmission.
1012  */
1013  if (increase) {
1014  if (!ip->client->interval)
1015  ip->client->interval =
1016  ip->client->config->initial_interval;
1017  else {
1018  ip->client->interval += (rand() >> 2) %
1019  (2 * ip->client->interval);
1020  }
1021 
1022  /* Don't backoff past cutoff. */
1023  if (ip->client->interval >
1024  ip->client->config->backoff_cutoff)
1025  ip->client->interval =
1026  ((ip->client->config->backoff_cutoff / 2)
1027  + ((rand() >> 2) %
1028  ip->client->config->backoff_cutoff));
1029  } else if (!ip->client->interval)
1030  ip->client->interval =
1031  ip->client->config->initial_interval;
1032 
1033  /* If the backoff would take us to the panic timeout, just use that
1034  as the interval. */
1035  if (cur_time + ip->client->interval >
1036  ip->client->first_sending + ip->client->config->timeout)
1037  ip->client->interval =
1038  (ip->client->first_sending +
1039  ip->client->config->timeout) - cur_time + 1;
1040 
1041  /* Record the number of seconds since we started sending. */
1042  if (interval < 65536)
1043  ip->client->packet.secs = htons(interval);
1044  else
1045  ip->client->packet.secs = htons(65535);
1046  ip->client->secs = ip->client->packet.secs;
1047 
1048  note("DHCPDISCOVER on %s to %s port %d interval %ld",
1049  ip->name, inet_ntoa(sockaddr_broadcast.sin_addr),
1050  ntohs(sockaddr_broadcast.sin_port), (long int)ip->client->interval);
1051 
1052  /* Send out a packet. */
1053  (void)send_packet(ip, &ip->client->packet, ip->client->packet_length,
1055 
1056  DH_DbgPrint(MID_TRACE,("discover timeout: now %x -> then %x\n",
1057  cur_time, cur_time + ip->client->interval));
1058 
1059  add_timeout(cur_time + ip->client->interval, send_discover, ip);
1060 }
#define MID_TRACE
Definition: debug.h:15
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
#define error(str)
Definition: mkdosfs.c:1605
char name[IFNAMSIZ]
Definition: dhcpd.h:231
struct client_state * client
Definition: dhcpd.h:238
time_t cur_time
__u16 time
Definition: mkdosfs.c:366
#define ntohs(x)
Definition: module.h:208
ssize_t send_packet(struct interface_info *ip, struct dhcp_packet *p, size_t size, struct in_addr addr, struct sockaddr_in *broadcast, struct hardware *hardware)
Definition: socket.c:9
_Check_return_ int __cdecl rand(void)
Definition: rand.c:10
int note(char *format,...)
Definition: util.c:12
smooth NULL
Definition: ftsmooth.c:416
#define DH_DbgPrint(_t_, _x_)
Definition: debug.h:49
#define inet_ntoa(addr)
Definition: inet.h:100
Definition: dhcpd.h:61
void state_panic(void *ipp)
Definition: dhclient.c:1069
void send_discover(void *ipp)
Definition: dhclient.c:963
__kernel_time_t time_t
Definition: linux.h:252
static void increase(int &a_)
void add_timeout(time_t when, void(*where)(void *), void *what)
Definition: dispatch.c:254
struct sockaddr_in sockaddr_broadcast
Definition: dhclient.c:82
struct in_addr inaddr_any
Definition: dhclient.c:81
#define htons(x)
Definition: module.h:213

◆ send_packet()

Definition at line 9 of file socket.c.

Referenced by send_decline(), send_discover(), and send_request().

14  {
15  int result =
16  sendto( ip->wfdesc, (char *)p, size, 0,
17  (struct sockaddr *)broadcast, sizeof(*broadcast) );
18 
19  if (result < 0) {
20  note ("send_packet: %x", result);
21  if (result == WSAENETUNREACH)
22  note ("send_packet: please consult README file%s",
23  " regarding broadcast address.");
24  }
25 
26  return result;
27 }
int note(char *format,...)
Definition: util.c:12
GLsizeiptr size
Definition: glext.h:5919
Definition: dhcpd.h:61
#define WSAENETUNREACH
Definition: winerror.h:1964
INT WSAAPI sendto(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags, IN CONST struct sockaddr *to, IN INT tolen)
Definition: send.c:82
GLfloat GLfloat p
Definition: glext.h:8902
GLuint64EXT * result
Definition: glext.h:11304

◆ send_request()

void send_request ( void )

Definition at line 1091 of file dhclient.c.

Referenced by dhcpack(), dhcpnak(), send_request(), state_bound(), state_reboot(), and state_selecting().

1092 {
1093  struct interface_info *ip = ipp;
1094  struct sockaddr_in destination;
1095  struct in_addr from;
1096  int interval;
1097  time_t cur_time;
1098 
1099  time(&cur_time);
1100 
1101  /* Figure out how long it's been since we started transmitting. */
1102  interval = cur_time - ip->client->first_sending;
1103 
1104  /* If we're in the INIT-REBOOT or REQUESTING state and we're
1105  past the reboot timeout, go to INIT and see if we can
1106  DISCOVER an address... */
1107  /* XXX In the INIT-REBOOT state, if we don't get an ACK, it
1108  means either that we're on a network with no DHCP server,
1109  or that our server is down. In the latter case, assuming
1110  that there is a backup DHCP server, DHCPDISCOVER will get
1111  us a new address, but we could also have successfully
1112  reused our old address. In the former case, we're hosed
1113  anyway. This is not a win-prone situation. */
1114  if ((ip->client->state == S_REBOOTING ||
1115  ip->client->state == S_REQUESTING) &&
1116  interval > ip->client->config->reboot_timeout) {
1117  ip->client->state = S_INIT;
1119  state_init(ip);
1120  return;
1121  }
1122 
1123  /* If we're in the reboot state, make sure the media is set up
1124  correctly. */
1125  if (ip->client->state == S_REBOOTING &&
1126  !ip->client->medium &&
1127  ip->client->active->medium ) {
1128  /* If the medium we chose won't fly, go to INIT state. */
1129  /* XXX Nothing for now */
1130 
1131  /* Record the medium. */
1132  ip->client->medium = ip->client->active->medium;
1133  }
1134 
1135  /* If the lease has expired, relinquish the address and go back
1136  to the INIT state. */
1137  if (ip->client->state != S_REQUESTING &&
1138  cur_time > ip->client->active->expiry) {
1139  PDHCP_ADAPTER Adapter = AdapterFindInfo( ip );
1140  /* Run the client script with the new parameters. */
1141  /* No script actions necessary in the expiry case */
1142  /* Now do a preinit on the interface so that we can
1143  discover a new address. */
1144 
1145  if( Adapter )
1146  {
1147  DeleteIPAddress( Adapter->NteContext );
1148  Adapter->NteContext = 0;
1149  }
1150 
1151  ip->client->state = S_INIT;
1152  state_init(ip);
1153  return;
1154  }
1155 
1156  /* Do the exponential backoff... */
1157  if (!ip->client->interval)
1158  ip->client->interval = ip->client->config->initial_interval;
1159  else
1160  ip->client->interval += ((rand() >> 2) %
1161  (2 * ip->client->interval));
1162 
1163  /* Don't backoff past cutoff. */
1164  if (ip->client->interval >
1165  ip->client->config->backoff_cutoff)
1166  ip->client->interval =
1167  ((ip->client->config->backoff_cutoff / 2) +
1168  ((rand() >> 2) % ip->client->interval));
1169 
1170  /* If the backoff would take us to the expiry time, just set the
1171  timeout to the expiry time. */
1172  if (ip->client->state != S_REQUESTING &&
1173  cur_time + ip->client->interval >
1174  ip->client->active->expiry)
1175  ip->client->interval =
1176  ip->client->active->expiry - cur_time + 1;
1177 
1178  /* If the lease T2 time has elapsed, or if we're not yet bound,
1179  broadcast the DHCPREQUEST rather than unicasting. */
1180  memset(&destination, 0, sizeof(destination));
1181  if (ip->client->state == S_REQUESTING ||
1182  ip->client->state == S_REBOOTING ||
1183  cur_time > ip->client->active->rebind)
1184  destination.sin_addr.s_addr = INADDR_BROADCAST;
1185  else
1186  memcpy(&destination.sin_addr.s_addr,
1187  ip->client->destination.iabuf,
1188  sizeof(destination.sin_addr.s_addr));
1189  destination.sin_port = htons(REMOTE_PORT);
1190  destination.sin_family = AF_INET;
1191 // destination.sin_len = sizeof(destination);
1192 
1193  if (ip->client->state != S_REQUESTING)
1194  memcpy(&from, ip->client->active->address.iabuf,
1195  sizeof(from));
1196  else
1197  from.s_addr = INADDR_ANY;
1198 
1199  /* Record the number of seconds since we started sending. */
1200  if (ip->client->state == S_REQUESTING)
1201  ip->client->packet.secs = ip->client->secs;
1202  else {
1203  if (interval < 65536)
1204  ip->client->packet.secs = htons(interval);
1205  else
1206  ip->client->packet.secs = htons(65535);
1207  }
1208 
1209  note("DHCPREQUEST on %s to %s port %d", ip->name,
1210  inet_ntoa(destination.sin_addr), ntohs(destination.sin_port));
1211 
1212  /* Send out a packet. */
1213  (void) send_packet(ip, &ip->client->packet, ip->client->packet_length,
1214  from, &destination, NULL);
1215 
1216  add_timeout(cur_time + ip->client->interval, send_request, ip);
1217 }
#define INADDR_BROADCAST
Definition: winsock.h:313
void send_request(void *ipp)
Definition: dhclient.c:1091
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
ULONG NteContext
Definition: rosdhcp.h:70
char name[IFNAMSIZ]
Definition: dhcpd.h:231
#define REMOTE_PORT
Definition: dhcpd.h:113
Definition: dhcpd.h:172
struct client_state * client
Definition: dhcpd.h:238
time_t cur_time
#define INADDR_ANY
Definition: StrAddr.c:4
__u16 time
Definition: mkdosfs.c:366
#define ntohs(x)
Definition: module.h:208
ssize_t send_packet(struct interface_info *ip, struct dhcp_packet *p, size_t size, struct in_addr addr, struct sockaddr_in *broadcast, struct hardware *hardware)
Definition: socket.c:9
void cancel_timeout(void(*where)(void *), void *what)
Definition: dispatch.c:317
_Check_return_ int __cdecl rand(void)
Definition: rand.c:10
int note(char *format,...)
Definition: util.c:12
smooth NULL
Definition: ftsmooth.c:416
PDHCP_ADAPTER AdapterFindInfo(struct interface_info *ip)
Definition: adapter.c:541
#define inet_ntoa(addr)
Definition: inet.h:100
Definition: dhcpd.h:61
Definition: tcpip.h:125
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
DWORD WINAPI DeleteIPAddress(ULONG NTEContext)
__kernel_time_t time_t
Definition: linux.h:252
void add_timeout(time_t when, void(*where)(void *), void *what)
Definition: dispatch.c:254
void state_init(void *ipp)
Definition: dhclient.c:218
#define AF_INET
Definition: tcpip.h:117
#define htons(x)
Definition: module.h:213
CardRegion * from
Definition: spigame.cpp:19
#define memset(x, y, z)
Definition: compat.h:39

◆ skip_to_semi()

void skip_to_semi ( FILE )

◆ state_bound()

void state_bound ( void )

Definition at line 636 of file dhclient.c.

Referenced by bind_lease().

637 {
638  struct interface_info *ip = ipp;
639 
641 
642  /* T1 has expired. */
643  make_request(ip, ip->client->active);
644  ip->client->xid = ip->client->packet.xid;
645 
646  if (ip->client->active->options[DHO_DHCP_SERVER_IDENTIFIER].len == 4) {
647  memcpy(ip->client->destination.iabuf, ip->client->active->
649  ip->client->destination.len = 4;
650  } else
651  ip->client->destination = iaddr_broadcast;
652 
653  time(&ip->client->first_sending);
654  ip->client->interval = ip->client->config->initial_interval;
655  ip->client->state = S_RENEWING;
656 
657  /* Send the first packet immediately. */
658  send_request(ip);
659 }
Definition: dhcpd.h:175
void send_request(void *ipp)
Definition: dhclient.c:1091
struct client_state * client
Definition: dhcpd.h:238
struct iaddr iaddr_broadcast
Definition: dhclient.c:80
__u16 time
Definition: mkdosfs.c:366
Definition: dhcpd.h:61
#define ASSERT_STATE(state_is, state_shouldbe)
Definition: dhclient.c:88
static int state
Definition: maze.c:121
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define DHO_DHCP_SERVER_IDENTIFIER
Definition: dhcp.h:150
void make_request(struct interface_info *ip, struct client_lease *lease)
Definition: dhclient.c:1317

◆ state_init()

void state_init ( void )

Definition at line 218 of file dhclient.c.

Referenced by AdapterDiscoveryThread(), device_init(), dhcpnak(), send_request(), state_reboot(), state_selecting(), wined3d_cs_create(), wined3d_cs_exec_reset_state(), and wined3d_device_reset().

219 {
220  struct interface_info *ip = ipp;
221 
223 
224  /* Make a DHCPDISCOVER packet, and set appropriate per-interface
225  flags. */
226  make_discover(ip, ip->client->active);
227  ip->client->xid = ip->client->packet.xid;
228  ip->client->destination = iaddr_broadcast;
229  ip->client->state = S_SELECTING;
230  time(&ip->client->first_sending);
231  ip->client->interval = ip->client->config->initial_interval;
232 
233  /* Add an immediate timeout to cause the first DHCPDISCOVER packet
234  to go out. */
235  send_discover(ip);
236 }
Definition: dhcpd.h:172
struct client_state * client
Definition: dhcpd.h:238
struct iaddr iaddr_broadcast
Definition: dhclient.c:80
void make_discover(struct interface_info *ip, struct client_lease *lease)
Definition: dhclient.c:1234
__u16 time
Definition: mkdosfs.c:366
Definition: dhcpd.h:61
#define ASSERT_STATE(state_is, state_shouldbe)
Definition: dhclient.c:88
static int state
Definition: maze.c:121
void send_discover(void *ipp)
Definition: dhclient.c:963

◆ state_panic()

void state_panic ( void )

Definition at line 1069 of file dhclient.c.

Referenced by send_discover().

1070 {
1071  struct interface_info *ip = ipp;
1072  PDHCP_ADAPTER Adapter = AdapterFindInfo(ip);
1073 
1074  note("No DHCPOFFERS received.");
1075 
1076  if (!Adapter->NteContext)
1077  {
1078  /* Generate an automatic private address */
1079  DbgPrint("DHCPCSVC: Failed to receive a response from a DHCP server. An automatic private address will be assigned.\n");
1080 
1081  /* FIXME: The address generation code sucks */
1082  AddIPAddress(htonl(0xA9FE0000 | (rand() % 0xFFFF)), //169.254.X.X
1083  htonl(0xFFFF0000), //255.255.0.0
1084  Adapter->IfMib.dwIndex,
1085  &Adapter->NteContext,
1086  &Adapter->NteInstance);
1087  }
1088 }
ULONG NteInstance
Definition: rosdhcp.h:70
MIB_IFROW IfMib
Definition: rosdhcp.h:66
ULONG NteContext
Definition: rosdhcp.h:70
#define DbgPrint
Definition: loader.c:25
#define htonl(x)
Definition: module.h:212
_Check_return_ int __cdecl rand(void)
Definition: rand.c:10
int note(char *format,...)
Definition: util.c:12
PDHCP_ADAPTER AdapterFindInfo(struct interface_info *ip)
Definition: adapter.c:541
DWORD WINAPI AddIPAddress(IPAddr Address, IPMask Netmask, DWORD IfIndex, PULONG NteContext, PULONG NteInstance)
Definition: iphlpapi_main.c:71
Definition: dhcpd.h:61
DWORD dwIndex
Definition: ifmib.h:38

◆ state_reboot()

void state_reboot ( void )

Definition at line 180 of file dhclient.c.

Referenced by DSLeaseIpAddress(), and DSRenewIpAddressLease().

181 {
182  struct interface_info *ip = ipp;
183  ULONG foo = (ULONG) GetTickCount();
184 
185  /* If we don't remember an active lease, go straight to INIT. */
186  if (!ip->client->active || ip->client->active->is_bootp) {
187  state_init(ip);
188  return;
189  }
190 
191  /* We are in the rebooting state. */
192  ip->client->state = S_REBOOTING;
193 
194  /* make_request doesn't initialize xid because it normally comes
195  from the DHCPDISCOVER, but we haven't sent a DHCPDISCOVER,
196  so pick an xid now. */
197  ip->client->xid = RtlRandom(&foo);
198 
199  /* Make a DHCPREQUEST packet, and set appropriate per-interface
200  flags. */
201  make_request(ip, ip->client->active);
202  ip->client->destination = iaddr_broadcast;
203  time(&ip->client->first_sending);
204  ip->client->interval = ip->client->config->initial_interval;
205 
206  /* Zap the medium list... */
207  ip->client->medium = NULL;
208 
209  /* Send out the first DHCPREQUEST packet. */
210  send_request(ip);
211 }
NTSYSAPI ULONG NTAPI RtlRandom(_Inout_ PULONG Seed)
void send_request(void *ipp)
Definition: dhclient.c:1091
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
struct client_state * client
Definition: dhcpd.h:238
struct iaddr iaddr_broadcast
Definition: dhclient.c:80
__u16 time
Definition: mkdosfs.c:366
smooth NULL
Definition: ftsmooth.c:416
Definition: dhcpd.h:61
void state_init(void *ipp)
Definition: dhclient.c:218
unsigned int ULONG
Definition: retypes.h:1
void make_request(struct interface_info *ip, struct client_lease *lease)
Definition: dhclient.c:1317

◆ state_requesting()

void state_requesting ( void )

◆ state_selecting()

void state_selecting ( void )

Definition at line 243 of file dhclient.c.

Referenced by dhcpoffer(), and state_selecting().

244 {
245  struct interface_info *ip = ipp;
246  struct client_lease *lp, *next, *picked;
248 
250 
251  time(&cur_time);
252 
253  /* Cancel state_selecting and send_discover timeouts, since either
254  one could have got us here. */
257 
258  /* We have received one or more DHCPOFFER packets. Currently,
259  the only criterion by which we judge leases is whether or
260  not we get a response when we arp for them. */
261  picked = NULL;
262  for (lp = ip->client->offered_leases; lp; lp = next) {
263  next = lp->next;
264 
265  /* Check to see if we got an ARPREPLY for the address
266  in this particular lease. */
267  if (!picked) {
268  if( !check_arp(ip,lp) ) goto freeit;
269  picked = lp;
270  picked->next = NULL;
271  } else {
272 freeit:
273  free_client_lease(lp);
274  }
275  }
276  ip->client->offered_leases = NULL;
277 
278  /* If we just tossed all the leases we were offered, go back
279  to square one. */
280  if (!picked) {
281  ip->client->state = S_INIT;
282  state_init(ip);
283  return;
284  }
285 
286  /* If it was a BOOTREPLY, we can just take the address right now. */
287  if (!picked->options[DHO_DHCP_MESSAGE_TYPE].len) {
288  ip->client->new = picked;
289 
290  /* Make up some lease expiry times
291  XXX these should be configurable. */
292  ip->client->new->expiry = cur_time + 12000;
293  ip->client->new->renewal += cur_time + 8000;
294  ip->client->new->rebind += cur_time + 10000;
295 
296  ip->client->state = S_REQUESTING;
297 
298  /* Bind to the address we received. */
299  bind_lease(ip);
300  return;
301  }
302 
303  /* Go to the REQUESTING state. */
304  ip->client->destination = iaddr_broadcast;
305  ip->client->state = S_REQUESTING;
306  ip->client->first_sending = cur_time;
307  ip->client->interval = ip->client->config->initial_interval;
308 
309  /* Make a DHCPREQUEST packet from the lease we picked. */
310  make_request(ip, picked);
311  ip->client->xid = ip->client->packet.xid;
312 
313  /* Toss the lease we picked - we'll get it back in a DHCPACK. */
314  free_client_lease(picked);
315 
316  /* Add an immediate timeout to send the first DHCPREQUEST packet. */
317  send_request(ip);
318 }
void send_request(void *ipp)
Definition: dhclient.c:1091
#define DHO_DHCP_MESSAGE_TYPE
Definition: dhcp.h:149
Definition: dhcpd.h:172
struct client_state * client
Definition: dhcpd.h:238
time_t cur_time
struct iaddr iaddr_broadcast
Definition: dhclient.c:80
__u16 time
Definition: mkdosfs.c:366
void cancel_timeout(void(*where)(void *), void *what)
Definition: dispatch.c:317
int check_arp(struct interface_info *ip, struct client_lease *lp)
Definition: dhclient.c:145
void bind_lease(struct interface_info *ip)
Definition: dhclient.c:588
smooth NULL
Definition: ftsmooth.c:416
Definition: dhcpd.h:61
struct client_lease * next
Definition: dhcpd.h:154
struct option_data options[256]
Definition: dhcpd.h:166
#define ASSERT_STATE(state_is, state_shouldbe)
Definition: dhclient.c:88
static int state
Definition: maze.c:121
void send_discover(void *ipp)
Definition: dhclient.c:963
void state_selecting(void *ipp)
Definition: dhclient.c:243
static unsigned __int64 next
Definition: rand_nt.c:6
__kernel_time_t time_t
Definition: linux.h:252
void state_init(void *ipp)
Definition: dhclient.c:218
void make_request(struct interface_info *ip, struct client_lease *lease)
Definition: dhclient.c:1317
void free_client_lease(struct client_lease *lease)
Definition: dhclient.c:1493

◆ subnet_number()

struct iaddr subnet_number ( struct iaddr  ,
struct iaddr   
)

Definition at line 172 of file util.c.

Referenced by priv_script_write_params().

172  {
173  struct iaddr bcast = { 0 };
174  return bcast;
175 }
Definition: dhcpd.h:125

◆ warning()

void int warning ( char ,
  ... 
)

Definition at line 785 of file uimain.c.

786 {
787  va_list ap;
788  char text[512];
789  char text1[512];
790 
791  sprintf(text1, "WARNING: ");
792  va_start(ap, format);
793  vsprintf(text, format, ap);
794  va_end(ap);
795  strcat(text1, text);
796  mi_warning(text1);
797 }
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
const WCHAR * text
Definition: package.c:1827
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
int __cdecl vsprintf(char *_Dest, const char *_Format, va_list _Args)
Definition: sprintf.c:733
#define va_start(ap, A)
Definition: acmsvcex.h:91
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
void mi_warning(char *msg)
Definition: win32.c:848

◆ write_client_lease()

void write_client_lease ( struct interface_info ,
struct client_lease ,
int   
)

Definition at line 1533 of file dhclient.c.

Referenced by rewrite_client_leases().

1535 {
1536  static int leases_written;
1537  struct tm *t;
1538  int i;
1539 
1540  if (!rewrite) {
1541  if (leases_written++ > 20) {
1543  leases_written = 0;