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