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 <linux/inet.h>
36 #include <linux/netdevice.h>
37 #include <linux/etherdevice.h>
38 #include "ip.h"
39 #include "protocol.h"
40 #include "tcp.h"
41 #include <linux/skbuff.h>
42
43
44
45
46
47
48 char *in_ntoa(unsigned long in)
49 {
50 static char buff[18];
51 char *p;
52
53 p = (char *) ∈
54 sprintf(buff, "%d.%d.%d.%d",
55 (p[0] & 255), (p[1] & 255), (p[2] & 255), (p[3] & 255));
56 return(buff);
57 }
58
59
60
61
62
63
64 unsigned long in_aton(char *str)
65 {
66 unsigned long l;
67 unsigned int val;
68 int i;
69
70 l = 0;
71 for (i = 0; i < 4; i++)
72 {
73 l <<= 8;
74 if (*str != '\0')
75 {
76 val = 0;
77 while (*str != '\0' && *str != '.')
78 {
79 val *= 10;
80 val += *str - '0';
81 str++;
82 }
83 l |= val;
84 if (*str != '\0')
85 str++;
86 }
87 }
88 return(htonl(l));
89 }
90
91
92
93
94
95
96 void dprintf(int level, char *fmt, ...)
97 {
98 va_list args;
99 char *buff;
100 extern int vsprintf(char * buf, const char * fmt, va_list args);
101
102 if (level != inet_debug)
103 return;
104
105 buff = (char *) kmalloc(256, GFP_ATOMIC);
106 if (buff != NULL)
107 {
108 va_start(args, fmt);
109 vsprintf(buff, fmt, args);
110 va_end(args);
111 printk(buff);
112 kfree(buff);
113 }
114 else
115 printk("Debugging output lost: No free memory.\n");
116 }
117
118
119
120
121
122 int dbg_ioctl(void *arg, int level)
123 {
124 int val;
125 int err;
126
127 if (!suser())
128 return(-EPERM);
129 err=verify_area(VERIFY_READ, (void *)arg, sizeof(int));
130 if(err)
131 return err;
132 val = get_fs_long((int *)arg);
133 switch(val)
134 {
135 case 0:
136 inet_debug = DBG_OFF;
137 break;
138 case 1:
139 inet_debug = level;
140 break;
141
142 case DBG_RT:
143 case DBG_DEV:
144 case DBG_ETH:
145 case DBG_PROTO:
146 case DBG_TMR:
147 case DBG_PKT:
148 case DBG_RAW:
149
150 case DBG_LOOPB:
151 case DBG_SLIP:
152
153 case DBG_ARP:
154 case DBG_IP:
155 case DBG_ICMP:
156 case DBG_TCP:
157 case DBG_UDP:
158
159 inet_debug = val;
160 break;
161
162 default:
163 return(-EINVAL);
164 }
165
166 return(0);
167 }