d9ca76e3fdfaab90c9d66fbec5e8bb54c7d79a00
[reactos.git] / reactos / subsys / system / dhcp / util.c
1 #include <stdarg.h>
2 #include "rosdhcp.h"
3
4 char *piaddr( struct iaddr addr ) {
5 struct sockaddr_in sa;
6 memcpy(&sa.sin_addr,addr.iabuf,sizeof(sa.sin_addr));
7 return inet_ntoa( sa.sin_addr );
8 }
9
10 int note( char *format, ... ) {
11 va_list arg_begin;
12 va_start( arg_begin, format );
13 char buf[0x100];
14 int ret;
15
16 ret = vsnprintf( buf, sizeof(buf), format, arg_begin );
17
18 DbgPrint("NOTE: %s\n", buf);
19
20 return ret;
21 }
22
23 int debug( char *format, ... ) {
24 va_list arg_begin;
25 va_start( arg_begin, format );
26 char buf[0x100];
27 int ret;
28
29 ret = vsnprintf( buf, sizeof(buf), format, arg_begin );
30
31 DbgPrint("DEBUG: %s\n", buf);
32
33 return ret;
34 }
35
36 int warn( char *format, ... ) {
37 va_list arg_begin;
38 va_start( arg_begin, format );
39 char buf[0x100];
40 int ret;
41
42 ret = vsnprintf( buf, sizeof(buf), format, arg_begin );
43
44 DbgPrint("WARN: %s\n", buf);
45
46 return ret;
47 }
48
49 int warning( char *format, ... ) {
50 va_list arg_begin;
51 va_start( arg_begin, format );
52 char buf[0x100];
53 int ret;
54
55 ret = vsnprintf( buf, sizeof(buf), format, arg_begin );
56
57 DbgPrint("WARNING: %s\n", buf);
58
59 return ret;
60 }
61
62 void error( char *format, ... ) {
63 va_list arg_begin;
64 va_start( arg_begin, format );
65 char buf[0x100];
66
67 vsnprintf( buf, sizeof(buf), format, arg_begin );
68
69 DbgPrint("ERROR: %s\n", buf);
70 }
71
72 int16_t getShort( unsigned char *data ) {
73 return (int16_t) ntohs(*(int16_t*) data);
74 }
75
76 u_int16_t getUShort( unsigned char *data ) {
77 return (u_int16_t) ntohs(*(u_int16_t*) data);
78 }
79
80 int32_t getLong( unsigned char *data ) {
81 return (int32_t) ntohl(*(u_int32_t*) data);
82 }
83
84 u_int32_t getULong( unsigned char *data ) {
85 return ntohl(*(u_int32_t*)data);
86 }
87
88 int addr_eq( struct iaddr a, struct iaddr b ) {
89 return a.len == b.len && !memcmp( a.iabuf, b.iabuf, a.len );
90 }
91
92 void *dmalloc( int size, char *name ) { return malloc( size ); }
93 void dfree( void *v, char *name ) { free( v ); }
94
95 int read_client_conf(void) {
96 error("util.c read_client_conf not implemented!");
97 return 0;
98 }
99
100 struct iaddr broadcast_addr( struct iaddr addr, struct iaddr mask ) {
101 struct iaddr bcast = { 0 };
102 return bcast;
103 }
104
105 struct iaddr subnet_number( struct iaddr addr, struct iaddr mask ) {
106 struct iaddr bcast = { 0 };
107 return bcast;
108 }