ReactOS  0.4.15-dev-3440-g915569a
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 **)
 
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.

◆ 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.

◆ IP_MF

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

Definition at line 71 of file dhcpd.h.

◆ IP_OFFMASK

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

Definition at line 72 of file dhcpd.h.

◆ 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.

◆ 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.

◆ 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.

◆ SIZE_T_MAX

#define SIZE_T_MAX   1600

Definition at line 91 of file dhcpd.h.

◆ 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.

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: pdh_main.c:93
#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:38
struct hash_bucket * new_hash_bucket(void)
Definition: alloc.c:71
GLuint const GLchar * name
Definition: glext.h:6031

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

◆ add_protocol()

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

Definition at line 342 of file dispatch.c.

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

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

◆ add_timeout()

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

Definition at line 253 of file dispatch.c.

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

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

◆ addr_eq()

int addr_eq ( struct iaddr  ,
struct iaddr   
)

Definition at line 100 of file util.c.

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

Referenced by bootp(), and dhcp().

◆ 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 580 of file dhclient.c.

581 {
582  PDHCP_ADAPTER Adapter;
583  struct client_lease *new_lease = ip->client->new;
585 
586  time(&cur_time);
587 
588  /* Remember the medium. */
589  ip->client->new->medium = ip->client->medium;
590 
591  /* Replace the old active lease with the new one. */
592  if (ip->client->active)
593  free_client_lease(ip->client->active);
594  ip->client->active = ip->client->new;
595  ip->client->new = NULL;
596 
597  /* Set up a timeout to start the renewal process. */
598  /* Timeout of zero means no timeout (some implementations seem to use
599  * one day).
600  */
601  if( ip->client->active->renewal - cur_time )
602  add_timeout(ip->client->active->renewal, state_bound, ip);
603 
604  note("bound to %s -- renewal in %ld seconds.",
605  piaddr(ip->client->active->address),
606  (long int)(ip->client->active->renewal - cur_time));
607 
608  ip->client->state = S_BOUND;
609 
610  Adapter = AdapterFindInfo( ip );
611 
612  if( Adapter ) setup_adapter( Adapter, new_lease );
613  else {
614  warning("Could not find adapter for info %p\n", ip);
615  return;
616  }
617  set_name_servers( Adapter, new_lease );
618  set_domain( Adapter, new_lease );
619 }
Definition: dhcpd.h:175
time_t cur_time
void setup_adapter(PDHCP_ADAPTER Adapter, struct client_lease *new_lease)
Definition: dhclient.c:492
void state_bound(void *ipp)
Definition: dhclient.c:628
__u16 time
Definition: mkdosfs.c:366
int note(char *format,...)
Definition: util.c:12
PDHCP_ADAPTER AdapterFindInfo(struct interface_info *ip)
Definition: adapter.c:526
void set_name_servers(PDHCP_ADAPTER Adapter, struct client_lease *new_lease)
Definition: dhclient.c:398
Definition: dhcpd.h:61
__kernel_time_t time_t
Definition: linux.h:252
#define NULL
Definition: types.h:112
char * piaddr(struct iaddr addr)
Definition: util.c:6
void add_timeout(time_t when, void(*where)(void *), void *what)
Definition: dispatch.c:253
void set_domain(PDHCP_ADAPTER Adapter, struct client_lease *new_lease)
Definition: dhclient.c:443
void free_client_lease(struct client_lease *lease)
Definition: dhclient.c:1515
#define warning(s)
Definition: debug.h:83

Referenced by dhcpack(), and state_selecting().

◆ bootp()

void bootp ( struct packet )

Definition at line 654 of file dhclient.c.

655 {
656  struct iaddrlist *ap;
657 
658  if (packet->raw->op != BOOTREPLY)
659  return;
660 
661  /* If there's a reject list, make sure this packet's sender isn't
662  on it. */
663  for (ap = packet->interface->client->config->reject_list;
664  ap; ap = ap->next) {
665  if (addr_eq(packet->client_addr, ap->addr)) {
666  note("BOOTREPLY from %s rejected.", piaddr(ap->addr));
667  return;
668  }
669  }
670  dhcpoffer(packet);
671 }
int addr_eq(struct iaddr a, struct iaddr b)
Definition: util.c:100
void dhcpoffer(struct packet *packet)
Definition: dhclient.c:710
struct dhcp_packet * raw
Definition: dhcpd.h:136
int note(char *format,...)
Definition: util.c:12
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

Referenced by do_packet().

◆ broadcast_addr()

struct iaddr broadcast_addr ( struct iaddr  ,
struct iaddr   
)

Definition at line 167 of file util.c.

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

Referenced by priv_script_write_params().

◆ 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 316 of file dispatch.c.

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

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

◆ 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.

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
static WCHAR foo[]
Definition: stringtable.c:56
struct _pair * pair
Definition: _pair.h:47
void * dmalloc(int size, char *name)
Definition: util.c:104

Referenced by xmlParseConditionalSections(), xmlParseContentInternal(), xmlParseExternalSubset(), xmlParseInternalSubset(), and xmlParseStartTag2().

◆ cons_options()

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

Definition at line 199 of file options.c.

201 {
202  unsigned char priority_list[300], buffer[4096];
203  int priority_len, main_buffer_size, mainbufix;
204  int option_size, length;
205 
206  /*
207  * If the client has provided a maximum DHCP message size, use
208  * that; otherwise, if it's BOOTP, only 64 bytes; otherwise use
209  * up to the minimum IP MTU size (576 bytes).
210  *
211  * XXX if a BOOTP client specifies a max message size, we will
212  * honor it.
213  */
214  if (!mms &&
215  inpacket &&
216  inpacket->options[DHO_DHCP_MAX_MESSAGE_SIZE].data &&
217  (inpacket->options[DHO_DHCP_MAX_MESSAGE_SIZE].len >=
218  sizeof(u_int16_t)))
219  mms = getUShort(
220  inpacket->options[DHO_DHCP_MAX_MESSAGE_SIZE].data);
221 
222  if (mms)
223  main_buffer_size = mms - DHCP_FIXED_LEN;
224  else
225  main_buffer_size = 576 - DHCP_FIXED_LEN;
226 
227  if (main_buffer_size > sizeof(buffer))
228  main_buffer_size = sizeof(buffer);
229 
230  /* Preload the option priority list with mandatory options. */
231  priority_len = 0;
232  priority_list[priority_len++] = DHO_DHCP_MESSAGE_TYPE;
233  priority_list[priority_len++] = DHO_DHCP_SERVER_IDENTIFIER;
234  priority_list[priority_len++] = DHO_DHCP_LEASE_TIME;
235  priority_list[priority_len++] = DHO_DHCP_MESSAGE;
236 
237  /*
238  * If the client has provided a list of options that it wishes
239  * returned, use it to prioritize. Otherwise, prioritize based
240  * on the default priority list.
241  */
242  if (inpacket &&
243  inpacket->options[DHO_DHCP_PARAMETER_REQUEST_LIST].data) {
244  int prlen =
245  inpacket->options[DHO_DHCP_PARAMETER_REQUEST_LIST].len;
246  if (prlen + priority_len > sizeof(priority_list))
247  prlen = sizeof(priority_list) - priority_len;
248 
249  memcpy(&priority_list[priority_len],
250  inpacket->options[DHO_DHCP_PARAMETER_REQUEST_LIST].data,
251  prlen);
252  priority_len += prlen;
253  } else {
254  memcpy(&priority_list[priority_len],
258  }
259 
260  /* Copy the options into the big buffer... */
261  option_size = store_options(
262  buffer,
263  main_buffer_size - 7,
264  options, priority_list, priority_len, main_buffer_size,
265  main_buffer_size);
266 
267  /* Put the cookie up front... */
268  memcpy(outpacket->options, DHCP_OPTIONS_COOKIE, 4);
269  mainbufix = 4;
270 
271  /*
272  * If we're going to have to overload, store the overload option
273  * at the beginning. If we can, though, just store the whole
274  * thing in the packet's option buffer and leave it at that.
275  */
276  if (option_size <= main_buffer_size - mainbufix) {
277  memcpy(&outpacket->options[mainbufix],
278  buffer, option_size);
279  mainbufix += option_size;
280  if (mainbufix < main_buffer_size)
281  outpacket->options[mainbufix++] = DHO_END;
282  length = DHCP_FIXED_NON_UDP + mainbufix;
283  } else {
284  outpacket->options[mainbufix++] = DHO_DHCP_OPTION_OVERLOAD;
285  outpacket->options[mainbufix++] = 1;
286  if (option_size >
287  main_buffer_size - mainbufix + DHCP_FILE_LEN)
288  outpacket->options[mainbufix++] = 3;
289  else
290  outpacket->options[mainbufix++] = 1;
291 
292  memcpy(&outpacket->options[mainbufix],
293  buffer, main_buffer_size - mainbufix);
294  length = DHCP_FIXED_NON_UDP + mainbufix;
295  }
296  return (length);
297 }
#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
int store_options(unsigned char *, int, struct tree_cache **, unsigned char *, int, int, int)
Definition: options.c:303
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
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

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

◆ 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.

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:38
#define warning(s)
Definition: debug.h:83

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

◆ dhcp()

void dhcp ( struct packet )

Definition at line 674 of file dhclient.c.

675 {
676  struct iaddrlist *ap;
677  void (*handler)(struct packet *);
678  char *type;
679 
680  switch (packet->packet_type) {
681  case DHCPOFFER:
682  handler = dhcpoffer;
683  type = "DHCPOFFER";
684  break;
685  case DHCPNAK:
686  handler = dhcpnak;
687  type = "DHCPNACK";
688  break;
689  case DHCPACK:
690  handler = dhcpack;
691  type = "DHCPACK";
692  break;
693  default:
694  return;
695  }
696 
697  /* If there's a reject list, make sure this packet's sender isn't
698  on it. */
699  for (ap = packet->interface->client->config->reject_list;
700  ap; ap = ap->next) {
701  if (addr_eq(packet->client_addr, ap->addr)) {
702  note("%s from %s rejected.", type, piaddr(ap->addr));
703  return;
704  }
705  }
706  (*handler)(packet);
707 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
int addr_eq(struct iaddr a, struct iaddr b)
Definition: util.c:100
void dhcpoffer(struct packet *packet)
Definition: dhclient.c:710
UCHAR packet[_PAGE_SIZE]
Definition: serial.c:53
void dhcpnak(struct packet *packet)
Definition: dhclient.c:915
#define DHCPOFFER
Definition: dhcp.h:163
#define DHCPACK
Definition: dhcp.h:166
void dhcpack(struct packet *packet)
Definition: dhclient.c:316
int note(char *format,...)
Definition: util.c:12
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
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786

Referenced by do_packet().

◆ dhcp_option_ev_name()

int dhcp_option_ev_name ( char ,
size_t  ,
struct dhcp_option  
)

Definition at line 1767 of file dhclient.c.

1768 {
1769  int i;
1770 
1771  for (i = 0; option->name[i]; i++) {
1772  if (i + 1 == buflen)
1773  return 0;
1774  if (option->name[i] == '-')
1775  buf[i] = '_';
1776  else
1777  buf[i] = option->name[i];
1778  }
1779 
1780  buf[i] = 0;
1781  return 1;
1782 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
WCHAR * name
Definition: getopt.h:110
Definition: getopt.h:108
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by priv_script_write_params().

◆ dhcpack()

void dhcpack ( struct packet )

Definition at line 316 of file dhclient.c.

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

Referenced by dhcp().

◆ dhcpnak()

void dhcpnak ( struct packet )

Definition at line 915 of file dhclient.c.

916 {
917  struct interface_info *ip = packet->interface;
918 
919  /* If we're not receptive to an offer right now, or if the offer
920  has an unrecognizable transaction id, then just drop it. */
921  if (packet->interface->client->xid != packet->raw->xid ||
922  (packet->interface->hw_address.hlen != packet->raw->hlen) ||
923  (memcmp(packet->interface->hw_address.haddr,
924  packet->raw->chaddr, packet->raw->hlen)))
925  return;
926 
927  if (ip->client->state != S_REBOOTING &&
928  ip->client->state != S_REQUESTING &&
929  ip->client->state != S_RENEWING &&
930  ip->client->state != S_REBINDING)
931  return;
932 
933  note("DHCPNAK from %s", piaddr(packet->client_addr));
934 
935  if (!ip->client->active) {
936  note("DHCPNAK with no active lease.\n");
937  return;
938  }
939 
940  free_client_lease(ip->client->active);
941  ip->client->active = NULL;
942 
943  /* Stop sending DHCPREQUEST packets... */
945 
946  ip->client->state = S_INIT;
947  state_init(ip);
948 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
Definition: dhcpd.h:172
void cancel_timeout(void(*where)(void *), void *what)
Definition: dispatch.c:316
struct dhcp_packet * raw
Definition: dhcpd.h:136
int note(char *format,...)
Definition: util.c:12
struct interface_info * interface
Definition: dhcpd.h:142
Definition: dhcpd.h:135
Definition: dhcpd.h:61
#define NULL
Definition: types.h:112
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:210
void free_client_lease(struct client_lease *lease)
Definition: dhclient.c:1515

Referenced by dhcp().

◆ dhcpoffer()

void dhcpoffer ( struct packet )

Definition at line 710 of file dhclient.c.

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

Referenced by bootp(), and dhcp().

◆ discover_interfaces()

void discover_interfaces ( struct interface_info )

◆ dispatch()

void dispatch ( HANDLE  hStopEvent)

Definition at line 70 of file dispatch.c.

71 {
72  int count, to_msec;
73  struct protocol *l;
74  time_t howlong, cur_time;
75  HANDLE Events[3];
76  int EventCount = 2;
77 
79  Events[1] = hStopEvent;
81 
82  ApiLock();
83 
84  do {
85  /*
86  * Call any expired timeouts, and then if there's still
87  * a timeout registered, time out the select call then.
88  */
89  time(&cur_time);
90 
91  if (timeouts)
92  {
93  struct timeout *t;
94 
95  if (timeouts->when <= cur_time) {
96  t = timeouts;
97  timeouts = timeouts->next;
98  (*(t->func))(t->what);
99  t->next = free_timeouts;
100  free_timeouts = t;
101  continue;
102  }
103 
104  /*
105  * Figure timeout in milliseconds, and check for
106  * potential overflow, so we can cram into an
107  * int for poll, while not polling with a
108  * negative timeout and blocking indefinitely.
109  */
110  howlong = timeouts->when - cur_time;
111  if (howlong > INT_MAX / 1000)
112  howlong = INT_MAX / 1000;
113  to_msec = howlong * 1000;
114  }
115  else
116  {
117  to_msec = INFINITE;
118  }
119 
121  {
122  Events[2] = WSACreateEvent();
123  if (Events[2] != WSA_INVALID_EVENT)
124  {
126  if (count != NO_ERROR)
127  {
128  WSACloseEvent(Events[2]);
130  }
131  else
132  {
133  EventCount = 3;
134  }
135  }
136  }
137  else if (Events[2] != WSA_INVALID_EVENT && DhcpSocket == INVALID_SOCKET)
138  {
139  WSACloseEvent(Events[2]);
141 
142  EventCount = 2;
143  }
144 
145  ApiUnlock();
146  count = WaitForMultipleObjects(EventCount,
147  Events,
148  FALSE,
149  to_msec);
150  ApiLock();
151  if (count == WAIT_OBJECT_0)
152  {
153  /* Adapter state change */
154  continue;
155  }
156  else if (count == WAIT_OBJECT_0 + 1)
157  {
158  /* Stop event signalled */
159  DPRINT("Dispatch thread stop event!\n");
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 
186  WSACloseEvent(Events[2]);
187 
188  ApiUnlock();
189 
190  DPRINT("Dispatch thread stopped!\n");
191 }
#define MID_TRACE
Definition: debug.h:15
#define INT_MAX
Definition: limits.h:40
GLuint GLuint GLsizei count
Definition: gl.h:1545
time_t cur_time
GLdouble GLdouble t
Definition: gl.h:2047
void got_one(struct protocol *l)
Definition: dispatch.c:194
#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
BOOL WSAAPI WSAResetEvent(IN WSAEVENT hEvent)
Definition: event.c:53
#define WSA_INVALID_EVENT
Definition: winsock2.h:595
#define FALSE
Definition: types.h:117
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
#define DH_DbgPrint(_t_, _x_)
Definition: debug.h:49
r l[0]
Definition: byte_order.h:167
#define WAIT_OBJECT_0
Definition: winbase.h:403
#define FD_CLOSE
Definition: winsock.h:410
#define INVALID_SOCKET
Definition: winsock.h:332
Definition: dhcpd.h:61
static struct timeout * free_timeouts
Definition: dispatch.c:58
HANDLE hAdapterStateChangedEvent
Definition: dhcpcsvc.c:20
SOCKET DhcpSocket
Definition: adapter.c:8
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:56
VOID ApiUnlock()
Definition: api.c:26
struct timeout * timeouts
Definition: dispatch.c:57
#define DPRINT
Definition: sndvol32.h:71
#define INFINITE
Definition: serial.h:102
VOID ApiLock()
Definition: api.c:22

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

◆ 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 635 of file options.c.

637 {
638  struct packet tp;
639  int i;
640 
641  if (packet->hlen > sizeof(packet->chaddr)) {
642  note("Discarding packet with invalid hlen.");
643  return;
644  }
645 
646  memset(&tp, 0, sizeof(tp));
647  tp.raw = packet;
648  tp.packet_length = len;
649  tp.client_port = from_port;
650  tp.client_addr = from;
651  tp.interface = interface;
652  tp.haddr = hfrom;
653 
654  parse_options(&tp);
655  if (tp.options_valid &&
656  tp.options[DHO_DHCP_MESSAGE_TYPE].data)
657  tp.packet_type = tp.options[DHO_DHCP_MESSAGE_TYPE].data[0];
658  if (tp.packet_type)
659  dhcp(&tp);
660  else
661  bootp(&tp);
662 
663  /* Free the data associated with the options. */
664  for (i = 0; i < 256; i++)
665  if (tp.options[i].len && tp.options[i].data)
666  free(tp.options[i].data);
667 }
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:654
int note(char *format,...)
Definition: util.c:12
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2930
Definition: dhcpd.h:135
GLenum GLsizei len
Definition: glext.h:6722
#define interface
Definition: basetyps.h:61
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
void dhcp(struct packet *packet)
Definition: dhclient.c:674
void parse_options(struct packet *)
Definition: options.c:59
CardRegion * from
Definition: spigame.cpp:19
#define memset(x, y, z)
Definition: compat.h:39

Referenced by init_client().

◆ 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
va_start(ap, x)
int __cdecl vsprintf(char *_Dest, const char *_Format, va_list _Args)
Definition: sprintf.c:733
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 412 of file dispatch.c.

413 {
414  struct protocol *p;
415 
416  for( p = protocols; p; p = p->next ) {
417  if( p->local == (void *)info ) return p;
418  }
419 
420  return NULL;
421 }
struct protocol * protocols
Definition: dispatch.c:56
#define NULL
Definition: types.h:112
GLfloat GLfloat p
Definition: glext.h:8902

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

◆ free_client_lease()

void free_client_lease ( struct client_lease )

Definition at line 1515 of file dhclient.c.

1516 {
1517  int i;
1518 
1519  if (lease->server_name)
1520  free(lease->server_name);
1521  if (lease->filename)
1522  free(lease->filename);
1523  for (i = 0; i < 256; i++) {
1524  if (lease->options[i].len)
1525  free(lease->options[i].data);
1526  }
1527  free(lease);
1528 }
#define free
Definition: debug_ros.c:5
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

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

◆ free_hash_bucket()

void free_hash_bucket ( struct hash_bucket ,
char  
)

Definition at line 89 of file alloc.c.

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:38

Referenced by delete_hash_entry().

◆ getLong()

int32_t getLong ( unsigned char )

Definition at line 92 of file util.c.

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

Referenced by pretty_print_option().

◆ getShort()

int16_t getShort ( unsigned char )

Definition at line 84 of file util.c.

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

Referenced by pretty_print_option().

◆ getULong()

u_int32_t getULong ( unsigned char )

Definition at line 96 of file util.c.

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

Referenced by dhcpack(), and pretty_print_option().

◆ getUShort()

u_int16_t getUShort ( unsigned char )

Definition at line 88 of file util.c.

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

Referenced by cons_options(), and pretty_print_option().

◆ go_daemon()

void go_daemon ( void  )

◆ got_one()

void got_one ( struct protocol )

Definition at line 194 of file dispatch.c.

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

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

◆ 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:38

◆ if_register_bpf()

int if_register_bpf ( struct interface_info )

◆ if_register_receive()

void if_register_receive ( struct interface_info )

Definition at line 575 of file adapter.c.

575  {
576 }

◆ if_register_send()

void if_register_send ( struct interface_info )

Definition at line 571 of file adapter.c.

571  {
572 
573 }

◆ 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
struct hash_table universe_hash
Definition: tables.c:672
struct universe dhcp_universe
Definition: tables.c:67
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
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 424 of file dispatch.c.

425 {
426  return (1);
427 }

◆ 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 1441 of file dhclient.c.

1442 {
1443  struct tree_cache *options[256], message_type_tree;
1444  struct tree_cache requested_address_tree;
1445  struct tree_cache server_id_tree, client_id_tree;
1446  unsigned char decline = DHCPDECLINE;
1447  int i;
1448 
1449  memset(options, 0, sizeof(options));
1450  memset(&ip->client->packet, 0, sizeof(ip->client->packet));
1451 
1452  /* Set DHCP_MESSAGE_TYPE to DHCPDECLINE */
1454  options[i] = &message_type_tree;
1455  options[i]->value = &decline;
1456  options[i]->len = sizeof(decline);
1457  options[i]->buf_size = sizeof(decline);
1458  options[i]->timeout = 0xFFFFFFFF;
1459 
1460  /* Send back the server identifier... */
1462  options[i] = &server_id_tree;
1463  options[i]->value = lease->options[i].data;
1464  options[i]->len = lease->options[i].len;
1465  options[i]->buf_size = lease->options[i].len;
1466  options[i]->timeout = 0xFFFFFFFF;
1467 
1468  /* Send back the address we're declining. */
1470  options[i] = &requested_address_tree;
1471  options[i]->value = lease->address.iabuf;
1472  options[i]->len = lease->address.len;
1473  options[i]->buf_size = lease->address.len;
1474  options[i]->timeout = 0xFFFFFFFF;
1475 
1476  /* Send the uid if the user supplied one. */
1478  if (ip->client->config->send_options[i].len) {
1479  options[i] = &client_id_tree;
1480  options[i]->value = ip->client->config->send_options[i].data;
1481  options[i]->len = ip->client->config->send_options[i].len;
1482  options[i]->buf_size = ip->client->config->send_options[i].len;
1483  options[i]->timeout = 0xFFFFFFFF;
1484  }
1485 
1486 
1487  /* Set up the option buffer... */
1488  ip->client->packet_length = cons_options(NULL, &ip->client->packet, 0,
1489  options);
1490  if (ip->client->packet_length < BOOTP_MIN_LEN)
1491  ip->client->packet_length = BOOTP_MIN_LEN;
1492 
1493  ip->client->packet.op = BOOTREQUEST;
1494  ip->client->packet.htype = ip->hw_address.htype;
1495  ip->client->packet.hlen = ip->hw_address.hlen;
1496  ip->client->packet.hops = 0;
1497  ip->client->packet.xid = ip->client->xid;
1498  ip->client->packet.secs = 0; /* Filled in by send_request. */
1499  ip->client->packet.flags = 0;
1500 
1501  /* ciaddr must always be zero. */
1502  memset(&ip->client->packet.ciaddr, 0,
1503  sizeof(ip->client->packet.ciaddr));
1504  memset(&ip->client->packet.yiaddr, 0,
1505  sizeof(ip->client->packet.yiaddr));
1506  memset(&ip->client->packet.siaddr, 0,
1507  sizeof(ip->client->packet.siaddr));
1508  memset(&ip->client->packet.giaddr, 0,
1509  sizeof(ip->client->packet.giaddr));
1510  memcpy(ip->client->packet.chaddr,
1511  ip->hw_address.haddr, ip->hw_address.hlen);
1512 }
#define DHO_DHCP_MESSAGE_TYPE
Definition: dhcp.h:149
#define BOOTP_MIN_LEN
Definition: dhcp.h:54
#define DHO_DHCP_CLIENT_IDENTIFIER
Definition: dhcp.h:157
Definition: dhcpd.h:61
int cons_options(struct packet *inpacket, struct dhcp_packet *outpacket, int mms, struct tree_cache **options)
Definition: options.c:199
#define BOOTREQUEST
Definition: dhcp.h:78
#define DHCPDECLINE
Definition: dhcp.h:165
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
#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

◆ make_discover()

void make_discover ( struct interface_info ,
struct client_lease  
)

Definition at line 1256 of file dhclient.c.

1257 {
1258  unsigned char discover = DHCPDISCOVER;
1259  struct tree_cache *options[256];
1260  struct tree_cache option_elements[256];
1261  int i;
1262  ULONG foo = (ULONG) GetTickCount();
1263 
1264  memset(option_elements, 0, sizeof(option_elements));
1265  memset(options, 0, sizeof(options));
1266  memset(&ip->client->packet, 0, sizeof(ip->client->packet));
1267 
1268  /* Set DHCP_MESSAGE_TYPE to DHCPDISCOVER */
1270  options[i] = &option_elements[i];
1271  options[i]->value = &discover;
1272  options[i]->len = sizeof(discover);
1273  options[i]->buf_size = sizeof(discover);
1274  options[i]->timeout = 0xFFFFFFFF;
1275 
1276  /* Request the options we want */
1278  options[i] = &option_elements[i];
1279  options[i]->value = ip->client->config->requested_options;
1280  options[i]->len = ip->client->config->requested_option_count;
1281  options[i]->buf_size =
1282  ip->client->config->requested_option_count;
1283  options[i]->timeout = 0xFFFFFFFF;
1284 
1285  /* If we had an address, try to get it again. */
1286  if (lease) {
1287  ip->client->requested_address = lease->address;
1289  options[i] = &option_elements[i];
1290  options[i]->value = lease->address.iabuf;
1291  options[i]->len = lease->address.len;
1292  options[i]->buf_size = lease->address.len;
1293  options[i]->timeout = 0xFFFFFFFF;
1294  } else
1295  ip->client->requested_address.len = 0;
1296 
1297  /* Send any options requested in the config file. */
1298  for (i = 0; i < 256; i++)
1299  if (!options[i] &&
1300  ip->client->config->send_options[i].data) {
1301  options[i] = &option_elements[i];
1302  options[i]->value =
1303  ip->client->config->send_options[i].data;
1304  options[i]->len =
1305  ip->client->config->send_options[i].len;
1306  options[i]->buf_size =
1307  ip->client->config->send_options[i].len;
1308  options[i]->timeout = 0xFFFFFFFF;
1309  }
1310 
1311  /* Set up the option buffer... */
1312  ip->client->packet_length = cons_options(NULL, &ip->client->packet, 0,
1313  options);
1314  if (ip->client->packet_length < BOOTP_MIN_LEN)
1315  ip->client->packet_length = BOOTP_MIN_LEN;
1316 
1317  ip->client->packet.op = BOOTREQUEST;
1318  ip->client->packet.htype = ip->hw_address.htype;
1319  ip->client->packet.hlen = ip->hw_address.hlen;
1320  ip->client->packet.hops = 0;
1321  ip->client->packet.xid = RtlRandom(&foo);
1322  ip->client->packet.secs = 0; /* filled in by send_discover. */
1323  ip->client->packet.flags = 0;
1324 
1325  memset(&(ip->client->packet.ciaddr),
1326  0, sizeof(ip->client->packet.ciaddr));
1327  memset(&(ip->client->packet.yiaddr),
1328  0, sizeof(ip->client->packet.yiaddr));
1329  memset(&(ip->client->packet.siaddr),
1330  0, sizeof(ip->client->packet.siaddr));
1331  memset(&(ip->client->packet.giaddr),
1332  0, sizeof(ip->client->packet.giaddr));
1333  memcpy(ip->client->packet.chaddr,
1334  ip->hw_address.haddr, ip->hw_address.hlen);
1335 }
NTSYSAPI ULONG NTAPI RtlRandom(_Inout_ PULONG Seed)
#define DHO_DHCP_MESSAGE_TYPE
Definition: dhcp.h:149
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
#define DHO_DHCP_PARAMETER_REQUEST_LIST
Definition: dhcp.h:151
#define BOOTP_MIN_LEN
Definition: dhcp.h:54
#define DHCPDISCOVER
Definition: dhcp.h:162
Definition: dhcpd.h:61
int cons_options(struct packet *inpacket, struct dhcp_packet *outpacket, int mms, struct tree_cache **options)
Definition: options.c:199
#define BOOTREQUEST
Definition: dhcp.h:78
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
#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

Referenced by state_init().

◆ make_request()

void make_request ( struct interface_info ,
struct client_lease  
)

Definition at line 1339 of file dhclient.c.

1340 {
1341  unsigned char request = DHCPREQUEST;
1342  struct tree_cache *options[256];
1343  struct tree_cache option_elements[256];
1344  int i;
1345 
1346  memset(options, 0, sizeof(options));
1347  memset(&ip->client->packet, 0, sizeof(ip->client->packet));
1348 
1349  /* Set DHCP_MESSAGE_TYPE to DHCPREQUEST */
1351  options[i] = &option_elements[i];
1352  options[i]->value = &request;
1353  options[i]->len = sizeof(request);
1354  options[i]->buf_size = sizeof(request);
1355  options[i]->timeout = 0xFFFFFFFF;
1356 
1357  /* Request the options we want */
1359  options[i] = &option_elements[i];
1360  options[i]->value = ip->client->config->requested_options;
1361  options[i]->len = ip->client->config->requested_option_count;
1362  options[i]->buf_size =
1363  ip->client->config->requested_option_count;
1364  options[i]->timeout = 0xFFFFFFFF;
1365 
1366  /* If we are requesting an address that hasn't yet been assigned
1367  to us, use the DHCP Requested Address option. */
1368  if (ip->client->state == S_REQUESTING) {
1369  /* Send back the server identifier... */
1371  options[i] = &option_elements[i];
1372  options[i]->value = lease->options[i].data;
1373  options[i]->len = lease->options[i].len;
1374  options[i]->buf_size = lease->options[i].len;
1375  options[i]->timeout = 0xFFFFFFFF;
1376  }
1377  if (ip->client->state == S_REQUESTING ||
1378  ip->client->state == S_REBOOTING) {
1379  ip->client->requested_address = lease->address;
1381  options[i] = &option_elements[i];
1382  options[i]->value = lease->address.iabuf;
1383  options[i]->len = lease->address.len;
1384  options[i]->buf_size = lease->address.len;
1385  options[i]->timeout = 0xFFFFFFFF;
1386  } else
1387  ip->client->requested_address.len = 0;
1388 
1389  /* Send any options requested in the config file. */
1390  for (i = 0; i < 256; i++)
1391  if (!options[i] &&
1392  ip->client->config->send_options[i].data) {
1393  options[i] = &option_elements[i];
1394  options[i]->value =
1395  ip->client->config->send_options[i].data;
1396  options[i]->len =
1397  ip->client->config->send_options[i].len;
1398  options[i]->buf_size =
1399  ip->client->config->send_options[i].len;
1400  options[i]->timeout = 0xFFFFFFFF;
1401  }
1402 
1403  /* Set up the option buffer... */
1404  ip->client->packet_length = cons_options(NULL, &ip->client->packet, 0,
1405  options);
1406  if (ip->client->packet_length < BOOTP_MIN_LEN)
1407  ip->client->packet_length = BOOTP_MIN_LEN;
1408 
1409  ip->client->packet.op = BOOTREQUEST;
1410  ip->client->packet.htype = ip->hw_address.htype;
1411  ip->client->packet.hlen = ip->hw_address.hlen;
1412  ip->client->packet.hops = 0;
1413  ip->client->packet.xid = ip->client->xid;
1414  ip->client->packet.secs = 0; /* Filled in by send_request. */
1415 
1416  /* If we own the address we're requesting, put it in ciaddr;
1417  otherwise set ciaddr to zero. */
1418  if (ip->client->state == S_BOUND ||
1419  ip->client->state == S_RENEWING ||
1420  ip->client->state == S_REBINDING) {
1421  memcpy(&ip->client->packet.ciaddr,
1422  lease->address.iabuf, lease->address.len);
1423  ip->client->packet.flags = 0;
1424  } else {
1425  memset(&ip->client->packet.ciaddr, 0,
1426  sizeof(ip->client->packet.ciaddr));
1427  ip->client->packet.flags = 0;
1428  }
1429 
1430  memset(&ip->client->packet.yiaddr, 0,
1431  sizeof(ip->client->packet.yiaddr));
1432  memset(&ip->client->packet.siaddr, 0,
1433  sizeof(ip->client->packet.siaddr));
1434  memset(&ip->client->packet.giaddr, 0,
1435  sizeof(ip->client->packet.giaddr));
1436  memcpy(ip->client->packet.chaddr,
1437  ip->hw_address.haddr, ip->hw_address.hlen);
1438 }
Definition: dhcpd.h:175
#define DHO_DHCP_MESSAGE_TYPE
Definition: dhcp.h:149
#define DHO_DHCP_PARAMETER_REQUEST_LIST
Definition: dhcp.h:151
#define BOOTP_MIN_LEN
Definition: dhcp.h:54
FxRequest * request
Definition: dhcpd.h:61
int cons_options(struct packet *inpacket, struct dhcp_packet *outpacket, int mms, struct tree_cache **options)
Definition: options.c:199
#define BOOTREQUEST
Definition: dhcp.h:78
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define DHCPREQUEST
Definition: dhcp.h:164
#define NULL
Definition: types.h:112
#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

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

◆ new_hash()

struct hash_table* new_hash ( void  )

Definition at line 53 of file hash.c.

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

Referenced by initialize_universes(), and test_put_hash().

◆ new_hash_bucket()

struct hash_bucket* new_hash_bucket ( void  )

Definition at line 71 of file alloc.c.

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

Referenced by add_hash().

◆ new_hash_table()

struct hash_table* new_hash_table ( int  )

Definition at line 57 of file alloc.c.

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 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define DEFAULT_HASH_SIZE
Definition: dhcpd.h:259
float rval
Definition: cylfrac.c:48
#define NULL
Definition: types.h:112
#define calloc
Definition: rosglue.h:14

Referenced by new_hash().

◆ 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 }
GLsizeiptr size
Definition: glext.h:5919
float rval
Definition: cylfrac.c:48
#define NULL
Definition: types.h:112
#define calloc
Definition: rosglue.h:14

◆ 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 829 of file dhclient.c.

830 {
831  struct client_lease *lease;
832  int i;
833 
834  lease = malloc(sizeof(struct client_lease));
835 
836  if (!lease) {
837  warning("dhcpoffer: no memory to record lease.");
838  return (NULL);
839  }
840 
841  memset(lease, 0, sizeof(*lease));
842 
843  /* Copy the lease options. */
844  for (i = 0; i < 256; i++) {
845  if (packet->options[i].len) {
846  lease->options[i].data =
847  malloc(packet->options[i].len + 1);
848  if (!lease->options[i].data) {
849  warning("dhcpoffer: no memory for option %d", i);
850  free_client_lease(lease);
851  return (NULL);
852  } else {
853  memcpy(lease->options[i].data,
854  packet->options[i].data,
855  packet->options[i].len);
856  lease->options[i].len =
857  packet->options[i].len;
858  lease->options[i].data[lease->options[i].len] =
859  0;
860  }
861  if (!check_option(lease,i)) {
862  /* ignore a bogus lease offer */
863  warning("Invalid lease option - ignoring offer");
864  free_client_lease(lease);
865  return (NULL);
866  }
867  }
868  }
869 
870  lease->address.len = sizeof(packet->raw->yiaddr);
871  memcpy(lease->address.iabuf, &packet->raw->yiaddr, lease->address.len);
872 #ifdef __REACTOS__
873  lease->serveraddress.len = sizeof(packet->raw->siaddr);
874  memcpy(lease->serveraddress.iabuf, &packet->raw->siaddr, lease->address.len);
875 #endif
876 
877  /* If the server name was filled out, copy it. */
879  !(packet->options[DHO_DHCP_OPTION_OVERLOAD].data[0] & 2)) &&
880  packet->raw->sname[0]) {
881  lease->server_name = malloc(DHCP_SNAME_LEN + 1);
882  if (!lease->server_name) {
883  warning("dhcpoffer: no memory for server name.");
884  free_client_lease(lease);
885  return (NULL);
886  }
887  memcpy(lease->server_name, packet->raw->sname, DHCP_SNAME_LEN);
888  lease->server_name[DHCP_SNAME_LEN]='\0';
889  if (!res_hnok(lease->server_name) ) {
890  warning("Bogus server name %s", lease->server_name );
891  free_client_lease(lease);
892  return (NULL);
893  }
894 
895  }
896 
897  /* Ditto for the filename. */
899  !(packet->options[DHO_DHCP_OPTION_OVERLOAD].data[0] & 1)) &&
900  packet->raw->file[0]) {
901  /* Don't count on the NUL terminator. */
902  lease->filename = malloc(DHCP_FILE_LEN + 1);
903  if (!lease->filename) {
904  warning("dhcpoffer: no memory for filename.");
905  free_client_lease(lease);
906  return (NULL);
907  }
908  memcpy(lease->filename, packet->raw->file, DHCP_FILE_LEN);
909  lease->filename[DHCP_FILE_LEN]='\0';
910  }
911  return lease;
912 }
int check_option(struct client_lease *l, int option)
Definition: dhclient.c:1813
int res_hnok(const char *dn)
Definition: dhclient.c:1908
#define DHCP_FILE_LEN
Definition: dhcp.h:47
char * filename
Definition: dhcpd.h:162
struct dhcp_packet * raw
Definition: dhcpd.h:136
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
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
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:1515
#define warning(s)
Definition: debug.h:83
char * server_name
Definition: dhcpd.h:157

Referenced by dhcpack(), and dhcpoffer().

◆ 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.

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

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

◆ pretty_print_option()

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

Definition at line 396 of file options.c.

398 {
399  static char optbuf[32768]; /* XXX */
400  int hunksize = 0, numhunk = -1, numelem = 0;
401  char fmtbuf[32], *op = optbuf;
402  int i, j, k, opleft = sizeof(optbuf);
403  unsigned char *dp = data;
404  struct in_addr foo;
405  char comma;
406 
407  /* Code should be between 0 and 255. */
408  if (code > 255)
409  error("pretty_print_option: bad code %d", code);
410 
411  if (emit_commas)
412  comma = ',';
413  else
414  comma = ' ';
415 
416  /* Figure out the size of the data. */
417  for (i = 0; dhcp_options[code].format[i]; i++) {
418  if (!numhunk) {
419  warning("%s: Excess information in format string: %s",
421  &(dhcp_options[code].format[i]));
422  break;
423  }
424  numelem++;
425  fmtbuf[i] = dhcp_options[code].format[i];
426  switch (dhcp_options[code].format[i]) {
427  case 'A':
428  --numelem;
429  fmtbuf[i] = 0;
430  numhunk = 0;
431  break;
432  case 'X':
433  for (k = 0; k < len; k++)
434  if (!isascii(data[k]) ||
435  !isprint(data[k]))
436  break;
437  if (k == len) {
438  fmtbuf[i] = 't';
439  numhunk = -2;
440  } else {
441  fmtbuf[i] = 'x';
442  hunksize++;
443  comma = ':';
444  numhunk = 0;
445  }
446  fmtbuf[i + 1] = 0;
447  break;
448  case 't':
449  fmtbuf[i] = 't';
450  fmtbuf[i + 1] = 0;
451  numhunk = -2;
452  break;
453  case 'I':
454  case 'l':
455  case 'L':
456  hunksize += 4;
457  break;
458  case 's':
459  case 'S':
460  hunksize += 2;
461  break;
462  case 'b':
463  case 'B':
464  case 'f':
465  hunksize++;
466  break;
467  case 'e':
468  break;
469  default:
470  warning("%s: garbage in format string: %s",
472  &(dhcp_options[code].format[i]));
473  break;
474  }
475  }
476 
477  /* Check for too few bytes... */
478  if (hunksize > len) {
479  warning("%s: expecting at least %d bytes; got %d",
480  dhcp_options[code].name, hunksize, len);
481  return ("<error>");
482  }
483  /* Check for too many bytes... */
484  if (numhunk == -1 && hunksize < len)
485  warning("%s: %d extra bytes",
486  dhcp_options[code].name, len - hunksize);
487 
488  /* If this is an array, compute its size. */
489  if (!numhunk)
490  numhunk = len / hunksize;
491  /* See if we got an exact number of hunks. */
492  if (numhunk > 0 && numhunk * hunksize < len)
493  warning("%s: %d extra bytes at end of array",
494  dhcp_options[code].name, len - numhunk * hunksize);
495 
496  /* A one-hunk array prints the same as a single hunk. */
497  if (numhunk < 0)
498  numhunk = 1;
499 
500  /* Cycle through the array (or hunk) printing the data. */
501  for (i = 0; i < numhunk; i++) {
502  for (j = 0; j < numelem; j++) {
503  int opcount;
504  switch (fmtbuf[j]) {
505  case 't':
506  if (emit_quotes) {
507  *op++ = '"';
508  opleft--;
509  }
510  for (; dp < data + len; dp++) {
511  if (!isascii(*dp) ||
512  !isprint(*dp)) {
513  if (dp + 1 != data + len ||
514  *dp != 0) {
515  _snprintf(op, opleft,
516  "\\%03o", *dp);
517  op += 4;
518  opleft -= 4;
519  }
520  } else if (*dp == '"' ||
521  *dp == '\'' ||
522  *dp == '$' ||
523  *dp == '`' ||
524  *dp == '\\') {
525  *op++ = '\\';
526  *op++ = *dp;
527  opleft -= 2;
528  } else {
529  *op++ = *dp;
530  opleft--;
531  }
532  }
533  if (emit_quotes) {
534  *op++ = '"';
535  opleft--;
536  }
537 
538  *op = 0;
539  break;
540  case 'I':
541  foo.s_addr = htonl(getULong(dp));
542  strncpy(op, inet_ntoa(foo), opleft - 1);
543  op[opleft - 1] = ANSI_NULL;
544  opcount = strlen(op);
545  if (opcount >= opleft)
546  goto toobig;
547  opleft -= opcount;
548  dp += 4;
549  break;
550  case 'l':
551  opcount = _snprintf(op, opleft, "%ld",
552  (long)getLong(dp));
553  if (opcount >= opleft || opcount == -1)
554  goto toobig;
555  opleft -= opcount;
556  dp += 4;
557  break;
558  case 'L':
559  opcount = _snprintf(op, opleft, "%ld",
560  (unsigned long)getULong(dp));
561  if (opcount >= opleft || opcount == -1)
562  goto toobig;
563  opleft -= opcount;
564  dp += 4;
565  break;
566  case 's':
567  opcount = _snprintf(op, opleft, "%d",
568  getShort(dp));
569  if (opcount >= opleft || opcount == -1)
570  goto toobig;
571  opleft -= opcount;
572  dp += 2;
573  break;
574  case 'S':
575  opcount = _snprintf(op, opleft, "%d",
576  getUShort(dp));
577  if (opcount >= opleft || opcount == -1)
578  goto toobig;
579  opleft -= opcount;
580  dp += 2;
581  break;
582  case 'b':
583  opcount = _snprintf(op, opleft, "%d",
584  *(char *)dp++);
585  if (opcount >= opleft || opcount == -1)
586  goto toobig;
587  opleft -= opcount;
588  break;
589  case 'B':
590  opcount = _snprintf(op, opleft, "%d", *dp++);
591  if (opcount >= opleft || opcount == -1)
592  goto toobig;
593  opleft -= opcount;
594  break;
595  case 'x':
596  opcount = _snprintf(op, opleft, "%x", *dp++);
597  if (opcount >= opleft || opcount == -1)
598  goto toobig;
599  opleft -= opcount;
600  break;
601  case 'f':
602  opcount = (size_t) strncpy(op, *dp++ ? "true" : "false", opleft - 1);
603  op[opleft - 1] = ANSI_NULL;
604  if (opcount >= opleft)
605  goto toobig;
606  opleft -= opcount;
607  break;
608  default:
609  warning("Unexpected format code %c", fmtbuf[j]);
610  }
611  op += strlen(op);
612  opleft -= strlen(op);
613  if (opleft < 1)
614  goto toobig;
615  if (j + 1 < numelem && comma != ':') {
616  *op++ = ' ';
617  opleft--;
618  }
619  }
620  if (i + 1 < numhunk) {
621  *op++ = comma;
622  opleft--;
623  }
624  if (opleft < 1)
625  goto toobig;
626 
627  }
628  return (optbuf);
629  toobig:
630  warning("dhcp option too large");
631  return ("<error>");
632 }
int16_t getShort(unsigned char *data)
Definition: util.c:84
#define error(str)
Definition: mkdosfs.c:1605
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
#define htonl(x)
Definition: module.h:212
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
#define ANSI_NULL
#define inet_ntoa(addr)
Definition: inet.h:100
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
__kernel_size_t size_t
Definition: linux.h:237
int32_t getLong(unsigned char *data)
Definition: util.c:92
Definition: tcpip.h:125
UINT op
Definition: effect.c:236
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum GLsizei len
Definition: glext.h:6722
Definition: inflate.c:139
int code
Definition: main.c:75
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#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:38
int k
Definition: mpi.c:3369
#define warning(s)
Definition: debug.h:83

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

◆ priv_script_go()

int priv_script_go ( void  )

◆ priv_script_init()

void priv_script_init ( struct interface_info ,
char ,
char  
)

Definition at line 1621 of file dhclient.c.

1622 {
1623  if (ip) {
1624  // XXX Do we need to do anything?
1625  }
1626 }
Definition: dhcpd.h:61

◆ priv_script_write_params()

void priv_script_write_params ( struct interface_info ,
char ,
struct client_lease  
)

Definition at line 1629 of file dhclient.c.

1630 {
1631  u_int8_t dbuf[1500];
1632  int i, len = 0;
1633 
1634 #if 0
1635  script_set_env(ip->client, prefix, "ip_address",
1636  piaddr(lease->address));
1637 #endif
1638 
1639  if (lease->options[DHO_SUBNET_MASK].len &&
1640  (lease->options[DHO_SUBNET_MASK].len <
1641  sizeof(lease->address.iabuf))) {
1642  struct iaddr netmask, subnet, broadcast;
1643 
1644  memcpy(netmask.iabuf, lease->options[DHO_SUBNET_MASK].data,
1645  lease->options[DHO_SUBNET_MASK].len);
1646  netmask.len = lease->options[DHO_SUBNET_MASK].len;
1647 
1648  subnet = subnet_number(lease->address, netmask);
1649  if (subnet.len) {
1650 #if 0
1651  script_set_env(ip->client, prefix, "network_number",
1652  piaddr(subnet));
1653 #endif
1654  if (!lease->options[DHO_BROADCAST_ADDRESS].len) {
1655  broadcast = broadcast_addr(subnet, netmask);
1656  if (broadcast.len)
1657 #if 0
1658  script_set_env(ip->client, prefix,
1659  "broadcast_address",
1660  piaddr(broadcast));
1661 #else
1662  ;
1663 #endif
1664  }
1665  }
1666  }
1667 
1668 #if 0
1669  if (lease->filename)
1670  script_set_env(ip->client, prefix, "filename", lease->filename);
1671  if (lease->server_name)
1672  script_set_env(ip->client, prefix, "server_name",
1673  lease->server_name);
1674 #endif
1675 
1676  for (i = 0; i < 256; i++) {
1677  u_int8_t *dp = NULL;
1678 
1679  if (ip->client->config->defaults[i].len) {
1680  if (lease->options[i].len) {
1681  switch (
1682  ip->client->config->default_actions[i]) {
1683  case ACTION_DEFAULT:
1684  dp = lease->options[i].data;
1685  len = lease->options[i].len;
1686  break;
1687  case ACTION_SUPERSEDE:
1688 supersede:
1689  dp = ip->client->
1690  config->defaults[i].data;
1691  len = ip->client->
1692  config->defaults[i].len;
1693  break;
1694  case ACTION_PREPEND:
1695  len = ip->client->
1696  config->defaults[i].len +
1697  lease->options[i].len;
1698  if (len >= sizeof(dbuf)) {
1699  warning("no space to %s %s",
1700  "prepend option",
1701  dhcp_options[i].name);
1702  goto supersede;
1703  }
1704  dp = dbuf;
1705  memcpy(dp,
1706  ip->client->
1707  config->defaults[i].data,
1708  ip->client->
1709  config->defaults[i].len);
1710  memcpy(dp + ip->client->
1711  config->defaults[i].len,
1712  lease->options[i].data,
1713  lease->options[i].len);
1714  dp[len] = '\0';
1715  break;
1716  case ACTION_APPEND:
1717  len = ip->client->
1718  config->defaults[i].len +
1719  lease->options[i].len + 1;
1720  if (len > sizeof(dbuf)) {
1721  warning("no space to %s %s",
1722  "append option",
1723  dhcp_options[i].name);
1724  goto supersede;
1725  }
1726  dp = dbuf;
1727  memcpy(dp,
1728  lease->options[i].data,
1729  lease->options[i].len);
1730  memcpy(dp + lease->options[i].len,
1731  ip->client->
1732  config->defaults[i].data,
1733  ip->client->
1734  config->defaults[i].len);
1735  dp[len-1] = '\0';
1736  }
1737  } else {
1738  dp = ip->client->
1739  config->defaults[i].data;
1740  len = ip->client->
1741  config->defaults[i].len;
1742  }
1743  } else if (lease->options[i].len) {
1744  len = lease->options[i].len;
1745  dp = lease->options[i].data;
1746  } else {
1747  len = 0;
1748  }
1749 #if 0
1750  if (len) {
1751  char name[256];
1752 
1753  if (dhcp_option_ev_name(name, sizeof(name),
1754  &dhcp_options[i]))
1755  script_set_env(ip->client, prefix, name,
1756  pretty_print_option(i, dp, len, 0, 0));
1757  }
1758 #endif
1759  }
1760 #if 0
1761  snprintf(tbuf, sizeof(tbuf), "%d", (int)lease->expiry);
1762  script_set_env(ip->client, prefix, "expiry", tbuf);
1763 #endif
1764 }
char * pretty_print_option(unsigned int code, unsigned char *data, int len, int emit_commas, int emit_quotes)
Definition: options.c:396
#define snprintf
Definition: wintirpc.h:48
struct dhcp_option dhcp_options[256]
Definition: tables.c:68
void script_set_env(struct client_state *, const char *, const char *, const char *)
unsigned char u_int8_t
Definition: rosdhcp.h:33
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
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#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:1767
#define NULL
Definition: types.h:112
char * piaddr(struct iaddr addr)
Definition: util.c:6
Definition: name.c:38
#define warning(s)
Definition: debug.h:83

◆ 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.

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 */
140  config->send_options[DHO_DHCP_CLIENT_IDENTIFIER].data =
141  ifi->hw_address.haddr;
142  config->send_options[DHO_DHCP_CLIENT_IDENTIFIER].len =
143  ifi->hw_address.hlen;
144 
145  /* Setup the requested option list */
146  config->requested_options
147  [config->requested_option_count++] = DHO_SUBNET_MASK;
148  config->requested_options
149  [config->requested_option_count++] = DHO_BROADCAST_ADDRESS;
150  config->requested_options
151  [config->requested_option_count++] = DHO_TIME_OFFSET;
152  config->requested_options
153  [config->requested_option_count++] = DHO_ROUTERS;
154  config->requested_options
155  [config->requested_option_count++] = DHO_DOMAIN_NAME;
156  config->requested_options
157  [config->requested_option_count++] = DHO_DOMAIN_NAME_SERVERS;
158  config->requested_options
159  [config->requested_option_count++] = DHO_HOST_NAME;
160  config->requested_options
161  [config->requested_option_count++] = DHO_NTP_SERVERS;
162 
163  warn("util.c read_client_conf poorly implemented!");
164  return 0;
165 }
struct config_s config
#define GetComputerName
Definition: winbase.h:3656
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
int debug(char *format,...)
Definition: util.c:27
#define GetProcessHeap()
Definition: compat.h:595
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
#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 NULL
Definition: types.h:112
#define DHO_DOMAIN_NAME
Definition: dhcp.h:111
#define DHO_DOMAIN_NAME_SERVERS
Definition: dhcp.h:102

Referenced by AdapterDiscoveryThread().

◆ 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 34 of file socket.c.

38  {
39  int recv_addr_size = sizeof(*dest);
40  int result;
41 
42  if (packet_len > INT_MAX)
43  return WSAEMSGSIZE;
44 
45  result =
46  recvfrom (ip -> rfdesc, (char *)packet_data, (int)packet_len, 0,
47  (struct sockaddr *)dest, &recv_addr_size );
48  return result;
49 }
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
#define INT_MAX
Definition: limits.h:40
GLuint64EXT * result
Definition: glext.h:11304
Definition: dhcpd.h:61
#define WSAEMSGSIZE
Definition: winerror.h:1953
static char * dest
Definition: rtl.c:135

Referenced by got_one().

◆ reinitialize_interfaces()

void reinitialize_interfaces ( void  )

◆ remove_protocol()

void remove_protocol ( struct protocol )

Definition at line 359 of file dispatch.c.

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

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

◆ rewrite_client_leases()

void rewrite_client_leases ( struct interface_info )

Definition at line 1533 of file dhclient.c.

1534 {
1535  struct client_lease *lp;
1536 
1537  if (!leaseFile) {
1539  if (!leaseFile)
1540  error("can't create %s", path_dhclient_db);
1541  } else {
1542  fflush(leaseFile);
1543  rewind(leaseFile);
1544  }
1545 
1546  for (lp = ifi->client->leases; lp; lp = lp->next)
1547  write_client_lease(ifi, lp, 1);
1548  if (ifi->client->active)
1549  write_client_lease(ifi, ifi->client->active, 1);
1550 
1551  fflush(leaseFile);
1552 }
#define error(str)
Definition: mkdosfs.c:1605
FILE * leaseFile
Definition: dhclient.c:1530
void write_client_lease(struct interface_info *ip, struct client_lease *lease, int rewrite)
Definition: dhclient.c:1555
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)

Referenced by write_client_lease().

◆ 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 1242 of file dhclient.c.

1243 {
1244  struct interface_info *ip = ipp;
1245 
1246  note("DHCPDECLINE on %s to %s port %d", ip->name,
1247  inet_ntoa(sockaddr_broadcast.sin_addr),
1248  ntohs(sockaddr_broadcast.sin_port));
1249 
1250  /* Send out a packet. */
1251  (void) send_packet(ip, &ip->client->packet, ip->client->packet_length,
1253 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
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
#define inet_ntoa(addr)
Definition: inet.h:100
Definition: dhcpd.h:61
#define ntohs(x)
Definition: module.h:208
#define NULL
Definition: types.h:112
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 955 of file dhclient.c.

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

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

◆ send_packet()

Definition at line 9 of file socket.c.

14  {
15  int result;
16 
17  if (size > INT_MAX)
18  return WSAEMSGSIZE;
19 
20  result =
21  sendto( ip->wfdesc, (char *)p, (int)size, 0,
22  (struct sockaddr *)broadcast, sizeof(*broadcast) );
23 
24  if (result < 0) {
25  note ("send_packet: %x", result);
26  if (result == WSAENETUNREACH)
27  note ("send_packet: please consult README file%s",
28  " regarding broadcast address.");
29  }
30 
31  return result;
32 }
#define INT_MAX
Definition: limits.h:40
GLuint64EXT * result
Definition: glext.h:11304
int note(char *format,...)
Definition: util.c:12
GLsizeiptr size
Definition: glext.h:5919
Definition: dhcpd.h:61
#define WSAEMSGSIZE
Definition: winerror.h:1953
#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

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

◆ send_request()

Definition at line 1113 of file dhclient.c.

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

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

◆ skip_to_semi()

void skip_to_semi ( FILE )

◆ state_bound()

void state_bound ( void )

Definition at line 628 of file dhclient.c.

629 {
630  struct interface_info *ip = ipp;
631 
633 
634  /* T1 has expired. */
635  make_request(ip, ip->client->active);
636  ip->client->xid = ip->client->packet.xid;
637 
638  if (ip->client->active->options[DHO_DHCP_SERVER_IDENTIFIER].len == 4) {
639  memcpy(ip->client->destination.iabuf, ip->client->active->
641  ip->client->destination.len = 4;
642  } else
643  ip->client->destination = iaddr_broadcast;
644 
645  time(&ip->client->first_sending);
646  ip->client->interval = ip->client->config->initial_interval;
647  ip->client->state = S_RENEWING;
648 
649  /* Send the first packet immediately. */
650  send_request(ip);
651 }
Definition: dhcpd.h:175
void send_request(void *ipp)
Definition: dhclient.c:1113
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:1339

Referenced by bind_lease().

◆ state_init()

void state_init ( void )

Definition at line 210 of file dhclient.c.

211 {
212  struct interface_info *ip = ipp;
213 
215 
216  /* Make a DHCPDISCOVER packet, and set appropriate per-interface
217  flags. */
218  make_discover(ip, ip->client->active);
219  ip->client->xid = ip->client->packet.xid;
220  ip->client->destination = iaddr_broadcast;
221  ip->client->state = S_SELECTING;
222  time(&ip->client->first_sending);
223  ip->client->interval = ip->client->config->initial_interval;
224 
225  /* Add an immediate timeout to cause the first DHCPDISCOVER packet
226  to go out. */
227  send_discover(ip);
228 }
Definition: dhcpd.h:172
struct iaddr iaddr_broadcast
Definition: dhclient.c:80
void make_discover(struct interface_info *ip, struct client_lease *lease)
Definition: dhclient.c:1256
__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:955

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

◆ state_panic()

void state_panic ( void )

Definition at line 1061 of file dhclient.c.

1062 {
1063  struct interface_info *ip = ipp;
1064  uint16_t address_low;
1065  int i;
1066  IPAddr IpAddress;
1067  ULONG Buffer[20];
1068  ULONG BufferSize;
1069  DWORD ret;
1070  PDHCP_ADAPTER Adapter = AdapterFindInfo(ip);
1071 
1072  note("No DHCPOFFERS received.");
1073 
1074  if (!Adapter->NteContext)
1075  {
1076  /* Generate an automatic private address */
1077  DbgPrint("DHCPCSVC: Failed to receive a response from a DHCP server. An automatic private address will be assigned.\n");
1078 
1079  /* FIXME: The address generation code sucks */
1080  srand(0);
1081 
1082  for (;;)
1083  {
1084  address_low = rand();
1085  for (i = 0; i < ip->hw_address.hlen; i++)
1086  address_low += ip->hw_address.haddr[i];
1087 
1088  IpAddress = htonl(0xA9FE0000 | address_low); // 169.254.X.X
1089 
1090  /* Send an ARP request to check if the IP address is already in use */
1091  BufferSize = sizeof(Buffer);
1092  ret = SendARP(IpAddress,
1093  IpAddress,
1094  Buffer,
1095  &BufferSize);
1096  DH_DbgPrint(MID_TRACE,("DHCPCSVC: SendARP returned %lu\n", ret));
1097  if (ret != 0)
1098  {
1099  /* The IP address is not in use */
1100  DH_DbgPrint(MID_TRACE,("DHCPCSVC: Using automatic private address\n"));
1101  AddIPAddress(IpAddress,
1102  htonl(0xFFFF0000), // 255.255.0.0
1103  Adapter->IfMib.dwIndex,
1104  &Adapter->NteContext,
1105  &Adapter->NteInstance);
1106  return;
1107  }
1108  }
1109  }
1110 }
ULONG NteInstance
Definition: rosdhcp.h:70
MIB_IFROW IfMib
Definition: rosdhcp.h:66
#define MID_TRACE
Definition: debug.h:15
#define DbgPrint
Definition: hal.h:12
ULONG NteContext
Definition: rosdhcp.h:70
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
void __cdecl srand(_In_ unsigned int _Seed)
unsigned short int uint16_t
Definition: acefiex.h:54
#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
#define DH_DbgPrint(_t_, _x_)
Definition: debug.h:49
Definition: bufpool.h:45
ULONG IPAddr
Definition: pfhook.h:35
PDHCP_ADAPTER AdapterFindInfo(struct interface_info *ip)
Definition: adapter.c:526
DWORD WINAPI AddIPAddress(IPAddr Address, IPMask Netmask, DWORD IfIndex, PULONG NteContext, PULONG NteInstance)
Definition: iphlpapi_main.c:71
Definition: dhcpd.h:61
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int ULONG
Definition: retypes.h:1
DWORD dwIndex
Definition: ifmib.h:38
DWORD WINAPI SendARP(IPAddr DestIP, IPAddr SrcIP, PULONG pMacAddr, PULONG PhyAddrLen)
#define BufferSize
Definition: mmc.h:75
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251

Referenced by send_discover().

◆ state_reboot()

void state_reboot ( void )

Definition at line 172 of file dhclient.c.

173 {
174  struct interface_info *ip = ipp;
175  ULONG foo = (ULONG) GetTickCount();
176 
177  /* If we don't remember an active lease, go straight to INIT. */
178  if (!ip->client->active || ip->client->active->is_bootp) {
179  state_init(ip);
180  return;
181  }
182 
183  /* We are in the rebooting state. */
184  ip->client->state = S_REBOOTING;
185 
186  /* make_request doesn't initialize xid because it normally comes
187  from the DHCPDISCOVER, but we haven't sent a DHCPDISCOVER,
188  so pick an xid now. */
189  ip->client->xid = RtlRandom(&foo);
190 
191  /* Make a DHCPREQUEST packet, and set appropriate per-interface
192  flags. */
193