ReactOS
0.4.16-dev-205-g7b2bb7e
display.c
Go to the documentation of this file.
1
#include <
headers.h
>
2
#include <
datatypes.h
>
3
#include <display.h>
4
#include <options.h>
5
6
int
display_dhcp_packet
(
DHCPMESSAGE
*dhcpm,
DHCPOPTIONS
*dhcpo )
7
{
8
char
*mtype;
9
if
( dhcpm ==
NULL
)
10
return
-1;
11
12
fprintf
(
stdout
,
"op: %s\t|htype: %s\t|hlen: %u\t|hops: %u\n"
, (dhcpm->
op
== 1)?
"BOOTREQUEST"
:
"BOOTREPLY"
, (dhcpm->
htype
==1)?
"Ethernet 10Mb"
:
"unknown"
, dhcpm->
hlen
, dhcpm->
hops
);
13
fprintf
(
stdout
,
"xid: %u \n"
, dhcpm->
xid
);
14
fprintf
(
stdout
,
"secs: %u\t\t|flags: %u\n"
, dhcpm->
secs
, dhcpm->
flags
);
15
fprintf
(
stdout
,
"ciaddr: %u.%u.%u.%u \n"
, (dhcpm->
ciaddr
>> 24), ((dhcpm->
ciaddr
>>16)&0xFF), ((dhcpm->
ciaddr
>>8)&0xFF), ((dhcpm->
ciaddr
)&0xFF));
16
fprintf
(
stdout
,
"yiaddr: %u.%u.%u.%u \n"
, (dhcpm->
yiaddr
>> 24), ((dhcpm->
yiaddr
>>16)&0xFF), ((dhcpm->
yiaddr
>>8)&0xFF), ((dhcpm->
yiaddr
)&0xFF));
17
fprintf
(
stdout
,
"siaddr: %u.%u.%u.%u \n"
, (dhcpm->
siaddr
>> 24), ((dhcpm->
siaddr
>>16)&0xFF), ((dhcpm->
siaddr
>>8)&0xFF), ((dhcpm->
siaddr
)&0xFF));
18
fprintf
(
stdout
,
"giaddr: %u.%u.%u.%u \n"
, (dhcpm->
giaddr
>> 24), ((dhcpm->
giaddr
>>16)&0xFF), ((dhcpm->
giaddr
>>8)&0xFF), ((dhcpm->
giaddr
)&0xFF));
19
fprintf
(
stdout
,
"chaddr: %X::%X::%X::%X::%X::%X \n"
, dhcpm->
chaddr
[0], dhcpm->
chaddr
[1], dhcpm->
chaddr
[2], dhcpm->
chaddr
[3], dhcpm->
chaddr
[4], dhcpm->
chaddr
[5] );
20
fprintf
(
stdout
,
"sname: %s \n"
, dhcpm->
sname
);
21
fprintf
(
stdout
,
"file: %s \n"
, dhcpm->
file
);
22
/* options come here */
23
switch
( dhcpo->
type
)
24
{
25
case
DHCPDISCOVER
:
26
mtype = (
char
*)
malloc
(
strlen
(
"DHCPDISCOVER"
) +1);
27
strcpy
( mtype,
"DHCPDISCOVER"
);
28
break
;
29
case
DHCPREQUEST
:
30
mtype = (
char
*)
malloc
(
strlen
(
"DHCPREQUEST"
) +1);
31
strcpy
( mtype,
"DHCPREQUEST"
);
32
break
;
33
case
DHCPACK
:
34
mtype = (
char
*)
malloc
(
strlen
(
"DHCPACK"
) +1);
35
strcpy
( mtype,
"DHCPACK"
);
36
break
;
37
case
DHCPNAK
:
38
mtype = (
char
*)
malloc
(
strlen
(
"DHCPNAK"
) +1);
39
strcpy
( mtype,
"DHCPNAK"
);
40
break
;
41
case
DHCPRELEASE
:
42
mtype = (
char
*)
malloc
(
strlen
(
"DHCPRELEASE"
) +1);
43
strcpy
( mtype,
"DHCPRELEASE"
);
44
break
;
45
case
DHCPDECLINE
:
46
mtype = (
char
*)
malloc
(
strlen
(
"DHCPDECLINE"
) +1);
47
strcpy
( mtype,
"DHCPDECLINE"
);
48
break
;
49
case
DHCPOFFER
:
50
mtype = (
char
*)
malloc
(
strlen
(
"DHCPOFFER"
) +1);
51
strcpy
( mtype,
"DHCPOFFER"
);
52
break
;
53
default
:
54
mtype = (
char
*)
malloc
(
strlen
(
"Unknown Type"
) +1);
55
strcpy
( mtype,
"Unknown Type"
);
56
break
;
57
}
58
fprintf
(
stdout
,
"Message Type: %s \n"
, mtype );
59
free
( mtype );
60
return
0;
61
}
62
strlen
ACPI_SIZE strlen(const char *String)
Definition:
utclib.c:269
strcpy
char * strcpy(char *DstString, const char *SrcString)
Definition:
utclib.c:388
DHCPREQUEST
#define DHCPREQUEST
Definition:
dhcp.h:164
DHCPRELEASE
#define DHCPRELEASE
Definition:
dhcp.h:168
DHCPNAK
#define DHCPNAK
Definition:
dhcp.h:167
DHCPACK
#define DHCPACK
Definition:
dhcp.h:166
DHCPDISCOVER
#define DHCPDISCOVER
Definition:
dhcp.h:162
DHCPOFFER
#define DHCPOFFER
Definition:
dhcp.h:163
DHCPDECLINE
#define DHCPDECLINE
Definition:
dhcp.h:165
datatypes.h
free
#define free
Definition:
debug_ros.c:5
malloc
#define malloc
Definition:
debug_ros.c:4
NULL
#define NULL
Definition:
types.h:112
headers.h
stdout
#define stdout
Definition:
stdio.h:99
fprintf
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
display_dhcp_packet
int display_dhcp_packet(DHCPMESSAGE *dhcpm, DHCPOPTIONS *dhcpo)
Definition:
display.c:6
DHCPMESSAGE
Definition:
datatypes.h:8
DHCPMESSAGE::yiaddr
u32b yiaddr
Definition:
datatypes.h:17
DHCPMESSAGE::ciaddr
u32b ciaddr
Definition:
datatypes.h:16
DHCPMESSAGE::secs
u16b secs
Definition:
datatypes.h:14
DHCPMESSAGE::siaddr
u32b siaddr
Definition:
datatypes.h:18
DHCPMESSAGE::sname
u8b sname[64]
Definition:
datatypes.h:21
DHCPMESSAGE::xid
u32b xid
Definition:
datatypes.h:13
DHCPMESSAGE::hlen
u8b hlen
Definition:
datatypes.h:11
DHCPMESSAGE::chaddr
u8b chaddr[16]
Definition:
datatypes.h:20
DHCPMESSAGE::flags
u16b flags
Definition:
datatypes.h:15
DHCPMESSAGE::op
u8b op
Definition:
datatypes.h:9
DHCPMESSAGE::file
u8b file[128]
Definition:
datatypes.h:22
DHCPMESSAGE::hops
u8b hops
Definition:
datatypes.h:12
DHCPMESSAGE::giaddr
u32b giaddr
Definition:
datatypes.h:19
DHCPMESSAGE::htype
u8b htype
Definition:
datatypes.h:10
DHCPOPTIONS
Definition:
datatypes.h:26
DHCPOPTIONS::type
u8b type
Definition:
datatypes.h:27
modules
rosapps
applications
net
dhcpd
src
display
display.c
Generated on Sat Nov 2 2024 06:05:56 for ReactOS by
1.9.6