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