ReactOS 0.4.15-dev-8417-gb6b82fe
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
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
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define DHCPREQUEST
Definition: dhcp.h:164
#define DHCPRELEASE
Definition: dhcp.h:168
#define DHCPNAK
Definition: dhcp.h:167
#define DHCPACK
Definition: dhcp.h:166
#define DHCPDISCOVER
Definition: dhcp.h:162
#define DHCPOFFER
Definition: dhcp.h:163
#define DHCPDECLINE
Definition: dhcp.h:165
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define stdout
Definition: stdio.h:99
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
int display_dhcp_packet(DHCPMESSAGE *dhcpm, DHCPOPTIONS *dhcpo)
Definition: display.c:6
u32b yiaddr
Definition: datatypes.h:17
u32b ciaddr
Definition: datatypes.h:16
u16b secs
Definition: datatypes.h:14
u32b siaddr
Definition: datatypes.h:18
u8b sname[64]
Definition: datatypes.h:21
u32b xid
Definition: datatypes.h:13
u8b chaddr[16]
Definition: datatypes.h:20
u16b flags
Definition: datatypes.h:15
u8b file[128]
Definition: datatypes.h:22
u32b giaddr
Definition: datatypes.h:19