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