This source file includes following definitions.
- in_ntoa
- in_aton
- dprintf
- dbg_ioctl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #include <asm/segment.h>
24 #include <asm/system.h>
25 #include <linux/types.h>
26 #include <linux/kernel.h>
27 #include <linux/sched.h>
28 #include <linux/string.h>
29 #include <linux/mm.h>
30 #include <linux/socket.h>
31 #include <linux/in.h>
32 #include <linux/errno.h>
33 #include <linux/stat.h>
34 #include <stdarg.h>
35 #include "inet.h"
36 #include "devinet.h"
37 #include "eth.h"
38 #include "ip.h"
39 #include "protocol.h"
40 #include "tcp.h"
41 #include "skbuff.h"
42 #include "arp.h"
43
44
45
46
47
48
49 char *in_ntoa(unsigned long in)
50 {
51 static char buff[18];
52 register char *p;
53
54 p = (char *) ∈
55 sprintf(buff, "%d.%d.%d.%d",
56 (p[0] & 255), (p[1] & 255), (p[2] & 255), (p[3] & 255));
57 return(buff);
58 }
59
60
61
62
63
64
65 unsigned long in_aton(char *str)
66 {
67 unsigned long l;
68 unsigned int val;
69 int i;
70
71 l = 0;
72 for (i = 0; i < 4; i++)
73 {
74 l <<= 8;
75 if (*str != '\0')
76 {
77 val = 0;
78 while (*str != '\0' && *str != '.')
79 {
80 val *= 10;
81 val += *str - '0';
82 str++;
83 }
84 l |= val;
85 if (*str != '\0')
86 str++;
87 }
88 }
89 return(htonl(l));
90 }
91
92
93 void dprintf(int level, char *fmt, ...)
94 {
95 va_list args;
96 char *buff;
97 extern int vsprintf(char * buf, const char * fmt, va_list args);
98
99 if (level != inet_debug)
100 return;
101
102 buff = (char *) kmalloc(256, GFP_ATOMIC);
103 if (buff != NULL)
104 {
105 va_start(args, fmt);
106 vsprintf(buff, fmt, args);
107 va_end(args);
108 printk(buff);
109 kfree(buff);
110 }
111 }
112
113
114 int dbg_ioctl(void *arg, int level)
115 {
116 int val;
117 int err;
118
119 if (!suser())
120 return(-EPERM);
121 err=verify_area(VERIFY_READ, (void *)arg, sizeof(int));
122 if(err)
123 return err;
124 val = get_fs_long((int *)arg);
125 switch(val)
126 {
127 case 0:
128 inet_debug = DBG_OFF;
129 break;
130 case 1:
131 inet_debug = level;
132 break;
133
134 case DBG_RT:
135 case DBG_DEV:
136 case DBG_ETH:
137 case DBG_PROTO:
138 case DBG_TMR:
139 case DBG_PKT:
140 case DBG_RAW:
141
142 case DBG_LOOPB:
143 case DBG_SLIP:
144
145 case DBG_ARP:
146 case DBG_IP:
147 case DBG_ICMP:
148 case DBG_TCP:
149 case DBG_UDP:
150
151 inet_debug = val;
152 break;
153
154 default:
155 return(-EINVAL);
156 }
157
158 return(0);
159 }