ReactOS  0.4.15-dev-3456-g4a17d4b
leases.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int find_lease (DHCPLEASE *, u32b, u8b *)
 
int init_leases_list ()
 
int confirm_lease (DHCPLEASE *, u32b)
 
int release_lease (DHCPLEASE *, u32b, u8b *)
 

Variables

DHCPLISTlist
 

Function Documentation

◆ confirm_lease()

int confirm_lease ( DHCPLEASE ,
u32b   
)

Definition at line 183 of file leases.c.

184 {
185  int result = -1;
186  DHCPLIST *temp;
187 
188  for( temp = list; temp; temp=temp->next )
189  if( temp->xid == xid )
190  {
191  dhcpl->ip = temp->data.ip;
192  dhcpl->router = temp->data.router;
193  dhcpl->mask = temp->data.mask;
194  dhcpl->lease = temp->data.lease;
195  dhcpl->siaddr = temp->data.siaddr;
196  temp->available = BUSY;
197  temp->ltime = temp->data.lease;
198  result = 0;
199  return result;
200  }
201  return result;
202 }
GLuint64EXT * result
Definition: glext.h:11304
LONGLONG xid
Definition: nfs41_driver.c:106
Definition: _list.h:228
static calc_node_t temp
Definition: rpn_ieee.c:38
Definition: user_lib.h:47

Referenced by process_dhcp_packet().

◆ find_lease()

int find_lease ( DHCPLEASE ,
u32b  ,
u8b  
)

Referenced by process_dhcp_packet().

◆ init_leases_list()

int init_leases_list ( )

Definition at line 8 of file leases.c.

9 {
10  DHCPLIST *temp;
11  int i, j;
12  u8b chaddr[16];
13  FILE *config;
14  char line[80];
15  char textsubnet[16];
16  char textlease[5];
17  char textrouter[16];
18  char textmask[16];
19  char textlowrange[4], texthighrange[4];
20  char textserver[16];
21  u8b ip0, ip1, ip2, ip3;
22  u8b lowrange, highrange;
23  u8b textmac[17], textip[16];
24  u32b lease;
25 
26  /* Be nice variables and behave yourselves */
27 
28  for( j = 0; j < 16; j++ )
29  {
30  chaddr[j] = 0;
31  textsubnet[j] = 0;
32  textrouter[j] = 0;
33  textmask[j] = 0;
34  textip[j] = 0;
35  textmac[j] = 0;
36  }
37 
38  textlease[0] = 0;
39  textlowrange[0] = 0;
40  texthighrange[0] = 0;
41 
42  /* Now we can read our configuration file */
43 
44  config = fopen( "dhcp.conf", "r" );
45  if( !config )
46  {
47  perror("Reading config files");
48  exit( 0 );
49  }
50 
51  /* We _DO_ need a better parser */
52  list = (DHCPLIST *)malloc( sizeof( DHCPLIST ));
53  temp = list;
54  temp->back = NULL;
55 
56  while( (!feof( config )) && ( line ))
57  {
58  fscanf( config, "%s", line);
59  if( !strcmp( line, "subnet" ))
60  /* Read subnet parameters */
61  fscanf( config, "%s", textsubnet );
62 
63  if( !strcmp( line, "lease" ))
64  /* read lease parameters */
65  fscanf( config, "%s", textlease );
66 
67  if( !strcmp( line, "router" ))
68  fscanf( config, "%s", textrouter );
69 
70  if( !strcmp( line, "mask" ))
71  fscanf( config, "%s", textmask );
72 
73  if( !strcmp( line, "range" ))
74  fscanf( config, "%s %s", textlowrange, texthighrange );
75  if( !strcmp( line, "server" ))
76  fscanf( config, "%s", textserver );
77  if( !strcmp( line, "host" ))
78  {
79  /* Host Specific Configuration */
80  fscanf( config, "%s %s", textmac, textip );
81  str2mac( textmac, temp->chaddr );
82  temp->type = STATIC;
83  temp->data.ip = inet_addr( textip );
84  temp->next = (DHCPLIST *)malloc( sizeof( DHCPLIST ));
85  temp->next->back = temp;
86  temp = temp->next;
87  temp->next =NULL;
88  }
89  }
90  fclose( config );
91 
92  lowrange = (u8b)atoi( textlowrange );
93  highrange = (u8b)atoi( texthighrange );
94  lease = (u32b)atoi( textlease );
95 
96  /* Creating Static IP */
97 
98  for( temp = list; temp->next; temp = temp->next )
99  {
100  temp->available = FREE;
101  temp->xid = 0;
102  temp->data.router = inet_addr( textrouter );
103  temp->data.mask = inet_addr( textmask );
104  temp->data.lease = lease;
105  temp->data.siaddr = inet_addr( textserver );
106  }
107 
108  /* Creating Dynamic IP */
109 
110  for( i = lowrange; i < (highrange + 1); i++ )
111  {
112  temp->available = FREE;
113  temp->xid = 0;
114  temp->type = DYNAMIC;
115  maccpy( temp->chaddr, chaddr );
116  split_ip( textsubnet, &ip0, 0 );
117  split_ip( textsubnet, &ip1, 1 );
118  split_ip( textsubnet, &ip2, 2 );
119  temp->data.ip = i;
120  temp->data.ip = temp->data.ip << 8;
121  temp->data.ip += ip2;
122  temp->data.ip = temp->data.ip << 8;
123  temp->data.ip += ip1;
124  temp->data.ip = temp->data.ip << 8;
125  temp->data.ip += ip0;
126  temp->data.router = inet_addr( textrouter );
127  temp->data.mask = inet_addr( textmask );
128  temp->data.lease = lease;
129  temp->data.siaddr = inet_addr( textserver );
130  temp->next = (DHCPLIST *)malloc( sizeof( DHCPLIST ));
131  temp->next->back = temp;
132  temp = temp->next;
133  }
134  return 0;
135 }
_Check_return_ _CRTIMP int __cdecl fscanf(_Inout_ FILE *_File, _In_z_ _Scanf_format_string_ const char *_Format,...)
int maccpy(u8b *, u8b *)
struct config_s config
#define inet_addr(cp)
Definition: inet.h:98
int split_ip(char *, u8b *, int)
Definition: iputils.c:6
#define DYNAMIC
Definition: options.h:112
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
Definition: parser.c:48
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
_Check_return_ _CRTIMP int __cdecl feof(_In_ FILE *_File)
int str2mac(u8b from[17], u8b to[16])
Definition: macutils.c:24
#define FREE(ptr, size)
Definition: auth_des.c:64
Definition: _list.h:228
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
#define STATIC
Definition: options.h:116
IN PCTCH line
Definition: pager.h:36
unsigned int u32b
Definition: datatypes.h:6
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
static calc_node_t temp
Definition: rpn_ieee.c:38
#define list
Definition: rosglue.h:35
#define NULL
Definition: types.h:112
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define malloc
Definition: debug_ros.c:4
unsigned char u8b
Definition: datatypes.h:4
void exit(int exitcode)
Definition: _exit.c:33

Referenced by main().

◆ release_lease()

int release_lease ( DHCPLEASE ,
u32b  ,
u8b  
)

Variable Documentation

◆ list

Definition at line 298 of file glfuncs.h.