#include <headers.h>
#include <datatypes.h>
#include <display.h>
#include <parser.h>
#include <leases.h>
#include <options.h>
Go to the source code of this file.
◆ parse_dhcp_options()
Definition at line 8 of file parser.c.
9{
11 int olength;
12
14
16
17
18
20
22
24
26
28
30
32 {
34 {
36 return -1;
37 }
41 break;
43
46 break;
48
51 while( opointer < olength )
52 {
53 switch( dhcpm->
options[opointer] ){
55
56 opointer += 2;
64 break;
66
67 opointer += 2;
75 break;
77
78 opointer += 2;
86 break;
88 opointer += 2;
96 break;
98 opointer += 1;
101 opointer += dhcpm->
options[opointer] + 1;
102 default:
103
104 opointer++;
105 break;
106 }
107 }
109 break;
180
181 fprintf(
stdout,
"parse_dhcp_options: END option found! [end]!\n");
182 return 0;
183 default:
184
186 break;
187 }
188 }
190 return 0;
191}
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
GLsizei const GLvoid * pointer
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
Referenced by main().
◆ process_dhcp_packet()
Definition at line 193 of file parser.c.
194{
198
200
201 if( (!dhcpm) || (!dhcpo) )
202 return -1;
203
205 switch( dhcpo->
type ){
206
208
210 {
213 return -1;
214 }
266 break;
267
269
274 {
286 return -1;
287 }
335 sprintf(
name,
"%u.%u.%u.%u", (dhcpl.
ip & 0xFF), ((dhcpl.
ip>>8) & 0xFF), ((dhcpl.
ip>>16)&0xFF), (dhcpl.
ip>>24));
336 break;
337
338 default:
339 break;
340 }
345 return 0;
346}
char * strcpy(char *DstString, const char *SrcString)
int find_lease(DHCPLEASE *, u32b, u8b *)
int confirm_lease(DHCPLEASE *, u32b)
int display_dhcp_packet(DHCPMESSAGE *dhcpm, DHCPOPTIONS *dhcpo)
int write_packet(DHCPMESSAGE *dhcpm, char *name)
#define sprintf(buf, format,...)
Referenced by main().
◆ write_packet()
Definition at line 348 of file parser.c.
349{
350 int sockfd;
353 int numbytes;
355
357
358 if( !dhcpm )
359 return -1;
360
364 }
365
367 {
370 }
371
373 {
377 return -1;
378 }
379 their_addr.sin_family =
AF_INET;
380 their_addr.sin_port =
htons(68);
381 their_addr.sin_addr = *((
struct in_addr *)he->h_addr);
382 } else {
383 their_addr.sin_family =
AF_INET;
384 their_addr.sin_port =
htons(68);
385 their_addr.sin_addr.s_addr = 0xFFFFFFFF;
386 }
387
389 memset(&(their_addr.sin_zero),
'\0', 8);
390
395 }
396
397 printf(
"sent %d bytes to %s\n", numbytes,
399
401
403
404 return 0;
405}
int strcmp(const char *String1, const char *String2)
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)
PHOSTENT WSAAPI gethostbyname(IN const char FAR *name)
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Referenced by process_dhcp_packet().