Commits
Landon Fuller authored f3893cd99c5
1 + | --- slirp.man |
2 + | +++ slirp.man |
3 + | |
4 + | -.TH SLIRP 1 "9 Jan 1996" "Version 1.0b" |
5 + | +.TH SLIRP 1 "8 Jan 2006" "Version 1.0.17" |
6 + | .\" Start displayed text macro |
7 + | .de DS |
8 + | |
9 + | |
10 + | second gap between each. This will disconnect Slirp from your shell's |
11 + | terminal and put Slirp in the background. Later, you can type |
12 + | .DS |
13 + | - slirp -l 0 |
14 + | + slirp \-l 0 |
15 + | .DE |
16 + | to "reconnect" Slirp again. |
17 + | .PP |
18 + | |
19 + | (Notice the quotes, they ARE significant). The reverse is also true. E.g., |
20 + | if you run slirp as: |
21 + | .DS |
22 + | - slirp -P -b 14400 |
23 + | + slirp \-P \-b 14400 |
24 + | .DE |
25 + | you can create your .slirprc file too look like the following: |
26 + | .DS |
27 + | - -P |
28 + | - -b 14400 |
29 + | + \-P |
30 + | + \-b 14400 |
31 + | .DE |
32 + | (Notice that only ONE command per line is allowed in configuration files). |
33 + | The 2 types of options can also be mixed. For example: |
34 + | .DS |
35 + | In .slirprc: |
36 + | - -P |
37 + | - -b 14400 |
38 + | + \-P |
39 + | + \-b 14400 |
40 + | redir 5022 21 |
41 + | |
42 + | Command line: |
43 + | - slirp -P -b 14400 "redir 5022 21" |
44 + | + slirp \-P \-b 14400 "redir 5022 21" |
45 + | .DE |
46 + | Note that on the command line, any command/option that does not begin |
47 + | with a '-' or '+', and has spaces in it, MUST be enclosed in quotes. |
48 + | E.g., The following are all legal: |
49 + | .DS |
50 + | - slirp -P "redir udp 5022 25" -vj -b 14400 |
51 + | + slirp \-P "redir udp 5022 25" \-vj \-b 14400 |
52 + | slirp "ppp" "baudrate 14400" |
53 + | slirp ppp "baudrate 14400" |
54 + | .DE |
55 + | |
56 + | The following are NOT legal: |
57 + | .DS |
58 + | slirp baudrate 14400 |
59 + | - slirp "-b 14400" |
60 + | + slirp "\-b 14400" |
61 + | .DE |
62 + | -(Because "-b" starts with a '-' you must NOT enclose it in quotes.) |
63 + | +(Because "\-b" starts with a '-' you must NOT enclose it in quotes.) |
64 + | Easy, eh? |
65 + | .PP |
66 + | Note: Whenever Slirp expects an IP address as an argument (E.g., in |
67 + | |
68 + | A few notes on configuration: |
69 + | .RS 2 |
70 + | .IP * 2 |
71 + | -You should have "ppp" or "-P" before any PPP options (because when |
72 + | -Slirp parses -P or ppp, it will initialize all related fields, hence |
73 + | +You should have "ppp" or "\-P" before any PPP options (because when |
74 + | +Slirp parses \-P or ppp, it will initialize all related fields, hence |
75 + | clearing anything that was parsed before it). |
76 + | .IP * 2 |
77 + | Upon startup, the configuration is done in this order: |
78 + | |
79 + | .RE |
80 + | .IP \ 2 |
81 + | This is important because, for example, if you have "initiate-options" |
82 + | -(a PPP option) in ~/.slirprc-0, and you run slirp with -P, |
83 + | -"initiate-options" will not be valid, because -P will clear the fact |
84 + | -that you want options initiated by Slirp (remember, -P should always |
85 + | +(a PPP option) in ~/.slirprc-0, and you run slirp with \-P, |
86 + | +"initiate-options" will not be valid, because \-P will clear the fact |
87 + | +that you want options initiated by Slirp (remember, \-P should always |
88 + | come before any PPP options). |
89 + | .RE |
90 + | .SH "COMMANDS AND OPTIONS" |
91 + | |
92 + | .br |
93 + | Usable: anywhere |
94 + | .br |
95 + | -Command-line: -X |
96 + | +Command-line: \-X |
97 + | .br |
98 + | Options: |
99 + | .RS 2 |
100 + | |
101 + | .br |
102 + | Usable: anywhere |
103 + | .br |
104 + | -Command-line: -b |
105 + | +Command-line: \-b |
106 + | .PP |
107 + | Example: baudrate 14400 |
108 + | .PP |
109 + | |
110 + | wipes out the session, whereas "close N" closes it properly, as a good |
111 + | little tcpip-emulator should :) |
112 + | .PP |
113 + | -"kill -1" shouldn't be used, it will kill the first session it finds |
114 + | -with -1, which usually is the command-line connection. |
115 + | +"kill \-1" shouldn't be used, it will kill the first session it finds |
116 + | +with \-1, which usually is the command-line connection. |
117 + | .RE |
118 + | .IP "close N" |
119 + | .RS 4 |
120 + | |
121 + | If your PPP software is unable to escape these characters, or you're |
122 + | using (C)SLIP (which must have an 8bit clean link), your best bet is to |
123 + | try and make the link 8bit clean. For example, on some systems you can |
124 + | -give telnet the -8 flag to make the link 8bit, and -E to stop it from |
125 + | -interpreting the ^] character. Similarly for rlogin; -8 to make the |
126 + | -link 8bit, -E to stop rlogin from interpreting the ~ character. You |
127 + | +give telnet the \-8 flag to make the link 8bit, and \-E to stop it from |
128 + | +interpreting the ^] character. Similarly for rlogin; \-8 to make the |
129 + | +link 8bit, \-E to stop rlogin from interpreting the ~ character. You |
130 + | should look at the telnet and rlogin manual pages ("man telnet" and |
131 + | "man rlogin" respectively) to see if your telnet/rlogin has similar |
132 + | options. |
133 + | |
134 + | Now, when you telnet to the host you wish to run the X programs from, |
135 + | you should do as Slirp suggest above; type either of the two commands, |
136 + | depending on which shell you are using. You could also run the X |
137 + | -program as "xprog -display IP.ADDRESS:X.Y" as printed above. |
138 + | +program as "xprog \-display IP.ADDRESS:X.Y" as printed above. |
139 + | .IP |
140 + | If you missed what Slirp displayed on startup, you can telnet to |
141 + | 10.0.2.0 and give Slirp the command "show X", and the above will be |
142 + | |
143 + | with the following information: |
144 + | .RS 2 |
145 + | .IP * 2 |
146 + | -Output of the command "uname -a" on the remote system; |
147 + | +Output of the command "uname \-a" on the remote system; |
148 + | .IP * 2 |
149 + | Operating System name and version you run on your PC; |
150 + | .IP * 2 |
151 + | Version of Slirp you are using (IMPORTANT!!!); |
152 + | .IP * 2 |
153 + | -If you managed to get Slirp running, run Slirp as "slirp -S" then try |
154 + | +If you managed to get Slirp running, run Slirp as "slirp \-S" then try |
155 + | whatever failed. When you exit Slirp, you should have a file called |
156 + | "slirp_stats". Send me this file; and |
157 + | .IP * 2 |
158 + | --- ppp.c |
159 + | +++ ppp.c |
160 + | |
161 + | #include <syslog.h> |
162 + | #include <utmp.h> |
163 + | #include <pwd.h> |
164 + | +#include <ctype.h> |
165 + | |
166 + | #include <sys/param.h> |
167 + | #include <sys/types.h> |
168 + | --- udp.c |
169 + | +++ udp.c |
170 + | |
171 + | struct mbuf *m; |
172 + | { |
173 + | struct sockaddr_in addr; |
174 + | - int addrlen = sizeof(addr); |
175 + | + socklen_t addrlen = sizeof(addr); |
176 + | #ifdef EMULATE_TALK |
177 + | CTL_MSG_OLD *omsg; |
178 + | CTL_MSG *nmsg; |
179 + | |
180 + | { |
181 + | struct sockaddr_in addr; |
182 + | struct socket *so; |
183 + | - int addrlen = sizeof(struct sockaddr_in), opt = 1; |
184 + | + socklen_t addrlen = sizeof(struct sockaddr_in), opt = 1; |
185 + | |
186 + | if ((so = socreate()) == NULL) { |
187 + | free(so); |
188 + | --- tcp_subr.c |
189 + | +++ tcp_subr.c |
190 + | |
191 + | { |
192 + | struct socket *so; |
193 + | struct sockaddr_in addr; |
194 + | - int addrlen = sizeof(struct sockaddr_in); |
195 + | + socklen_t addrlen = sizeof(struct sockaddr_in); |
196 + | struct tcpcb *tp; |
197 + | int s, opt; |
198 + | |
199 + | |
200 + | { |
201 + | struct socket *tmpso; |
202 + | struct sockaddr_in addr; |
203 + | - int addrlen = sizeof(struct sockaddr_in); |
204 + | + socklen_t addrlen = sizeof(struct sockaddr_in); |
205 + | struct sbuf *so_rcv = &so->so_rcv; |
206 + | |
207 + | memcpy(so_rcv->sb_wptr, m->m_data, m->m_len); |
208 + | --- Makefile.in |
209 + | +++ Makefile.in |
210 + | |
211 + | .c.o: $(COMMON_H) |
212 + | $(CC) $(CFLAGS) -c $< -o $@ |
213 + | |
214 + | +nothing: |
215 + | --- main.c |
216 + | +++ main.c |
217 + | |
218 + | #define WANT_SYS_IOCTL_H |
219 + | #define WANT_TERMIOS_H |
220 + | #include <slirp.h> |
221 + | +#include <ctype.h> |
222 + | #include "main.h" |
223 + | |
224 + | struct timeval tt; |
225 + | |
226 + | |
227 + | /* It's an internet socket */ |
228 + | if (sscanf(*argv, "%d,%[^:]:%d,%s", &unit, hn, &port, pwd) != 4) { |
229 + | - lprint("Error: bad arguements to -l\n"); |
230 + | + lprint("Error: bad arguments to -l\n"); |
231 + | slirp_exit(1); |
232 + | } |
233 + | if (strcmp(pwd, "-") == 0) { |
234 + | |
235 + | char *device = dev; |
236 + | #ifndef NO_UNIX_SOCKETS |
237 + | struct sockaddr_un sock_un; |
238 + | - int sock_len = sizeof(struct sockaddr_un); |
239 + | + socklen_t sock_len = sizeof(struct sockaddr_un); |
240 + | #endif |
241 + | struct sockaddr_in sock_in; |
242 + | - int sock_len2 = sizeof(struct sockaddr_in); |
243 + | + socklen_t sock_len2 = sizeof(struct sockaddr_in); |
244 + | |
245 + | fd = -1; |
246 + | if (slirp_socket_passwd) |
247 + | |
248 + | sleep(1); |
249 + | if (read(fd, buff, 256) < 0) { |
250 + | /* Nuke both connections */ |
251 + | - sprintf(buff, "0 Connection timed out"); |
252 + | + snprintf(buff, sizeof(buff), "0 Connection timed out"); |
253 + | write(fd, buff, strlen(buff)+1); |
254 + | slirp_socket_wait = curtime; |
255 + | close(fd); |
256 + | |
257 + | |
258 + | if (sscanf(buff, "%d %d %256s", &unit, &pid, device) == 3) { |
259 + | if (unit >= MAX_INTERFACES || unit < 0) { |
260 + | - sprintf(buff, "0 Unit out of range (must be between 0 and %d, inclusive)", MAX_INTERFACES-1); |
261 + | + snprintf(buff, sizeof(buff), "0 Unit out of range (must be between 0 and %d, inclusive)", MAX_INTERFACES-1); |
262 + | write(fd, buff, strlen(buff)+1); |
263 + | slirp_socket_wait = curtime; |
264 + | close(fd); |
265 + | |
266 + | * (pid is invalid) */ |
267 + | if (slirp_socket_passwd) { |
268 + | if (strcmp(slirp_socket_passwd, device) != 0) { |
269 + | - sprintf(buff, "0 Incorrect password"); |
270 + | + snprintf(buff, sizeof(buff), "0 Incorrect password"); |
271 + | write(fd, buff, strlen(buff)+1); |
272 + | slirp_socket_wait = curtime; |
273 + | close(fd); |
274 + | |
275 + | * failure, 1 for exit, and message is printed |
276 + | */ |
277 + | if (ttyp) { |
278 + | - sprintf(buff, "0 Unit already attached"); |
279 + | + snprintf(buff, sizeof(buff), "0 Unit already attached"); |
280 + | write(fd, buff, strlen(buff)+1); |
281 + | slirp_socket_wait = curtime; |
282 + | close(fd); |
283 + | |
284 + | strcpy(buff2, "PPP"); |
285 + | else |
286 + | #endif |
287 + | - sprintf(buff2, "SLIP, MTU %d, MRU %d", if_mtu, if_mru); |
288 + | + snprintf(buff2, sizeof(buff2), "SLIP, MTU %d, MRU %d", if_mtu, if_mru); |
289 + | #ifndef FULL_BOLT |
290 + | snprintf(buff, sizeof(buff), |
291 + | "1 Attached as unit %d, device %s\r\n\r\n[talking %s, %d baud]\r\n\r\nSLiRP Ready ...", |
292 + | |
293 + | ttyp->fd = fd; |
294 + | } |
295 + | } else { |
296 + | - sprintf(buff, "0 %s", strerror(errno)); |
297 + | + snprintf(buff, sizeof(buff), "0 %s", strerror(errno)); |
298 + | write(fd, buff, strlen(buff)+1); |
299 + | slirp_socket_wait = curtime; |
300 + | close(fd); |
301 + | --- mbuf.h |
302 + | +++ mbuf.h |
303 + | |
304 + | extern struct mbstat mbstat; |
305 + | extern int mbuf_alloced; |
306 + | extern struct mbuf m_freelist, m_usedlist; |
307 + | -extern mbuf_max; |
308 + | +extern int mbuf_max; |
309 + | |
310 + | #endif |
311 + | --- misc.c |
312 + | +++ misc.c |
313 + | |
314 + | { |
315 + | int s; |
316 + | struct sockaddr_in addr; |
317 + | - int addrlen = sizeof(addr); |
318 + | + socklen_t addrlen = sizeof(addr); |
319 + | int opt; |
320 + | int master; |
321 + | char *argv[256]; |
322 + | |
323 + | { |
324 + | char buff[256]; |
325 + | |
326 + | - sprintf(buff, "Error: execvp of %s failed: %s\n", |
327 + | + snprintf(buff, sizeof(buff), "Error: execvp of %s failed: %s\n", |
328 + | argv[0], strerror(errno)); |
329 + | write(2, buff, strlen(buff)+1); |
330 + | } |
331 + | |
332 + | if (connect(s, (struct sockaddr *)&sock_un, |
333 + | sizeof(sock_un.sun_family) + sizeof(sock_un.sun_path)) != 0) |
334 + | slirp_exit(1); |
335 + | - sprintf(buff, "kill none:%d", slirp_socket_unit); |
336 + | + snprintf(buff, sizeof(buff), "kill none:%d", slirp_socket_unit); |
337 + | write(s, buff, strlen(buff)+1); |
338 + | } |
339 + | #endif |
340 + | |
341 + | |
342 + | /* Ooops, failed, let's tell the user why */ |
343 + | |
344 + | - sprintf(buff, "Error: execlp of %s failed: %s\n", |
345 + | + snprintf(buff, sizeof(buff), "Error: execlp of %s failed: %s\n", |
346 + | "rsh", strerror(errno)); |
347 + | write(2, buff, strlen(buff)+1); |
348 + | close(0); close(1); close(2); /* XXX */ |
349 + | --- options.c |
350 + | +++ options.c |
351 + | |
352 + | #define GIDSET_TYPE int |
353 + | #endif |
354 + | |
355 + | +#include <ctype.h> |
356 + | + |
357 + | void readable _P((int fd)); |
358 + | |
359 + | /* |
360 + | --- ttys.c |
361 + | +++ ttys.c |
362 + | |
363 + | #endif |
364 + | #include <slirp.h> |
365 + | |
366 + | +void lcp_lowerdown(int unit); |
367 + | + |
368 + | struct ttys *ttys_unit[MAX_INTERFACES]; |
369 + | |
370 + | int slirp_forked; |
371 + | |
372 + | |
373 + | /* Config the new tty */ |
374 + | if ((bptr = (char *)getenv("HOME"))) |
375 + | - sprintf(buff, "%s/.slirprc-%d", bptr, unit); |
376 + | + snprintf(buff, sizeof(buff), "%s/.slirprc-%d", bptr, unit); |
377 + | else |
378 + | - sprintf(buff, ".slirprc-%d", unit); |
379 + | + snprintf(buff, sizeof(buff), ".slirprc-%d", unit); |
380 + | config(buff, ttyp->unit); |
381 + | |
382 + | return ttyp; |
383 + | --- tcp_output.c |
384 + | +++ tcp_output.c |
385 + | |
386 + | tcp_setpersist(tp) |
387 + | register struct tcpcb *tp; |
388 + | { |
389 + | - register t = ((tp->t_srtt >> 2) + tp->t_rttvar) >> 1; |
390 + | + register int t = ((tp->t_srtt >> 2) + tp->t_rttvar) >> 1; |
391 + | |
392 + | /* if (tp->t_timer[TCPT_REXMT]) |
393 + | * panic("tcp_output REXMT"); |
394 + | --- socket.c |
395 + | +++ socket.c |
396 + | |
397 + | struct socket *so; |
398 + | { |
399 + | struct sockaddr_in addr; |
400 + | - int addrlen = sizeof(struct sockaddr_in); |
401 + | + socklen_t addrlen = sizeof(struct sockaddr_in); |
402 + | |
403 + | DEBUG_CALL("sorecvfrom"); |
404 + | DEBUG_ARG("so = %lx", (long)so); |
405 + | |
406 + | { |
407 + | struct sockaddr_in addr; |
408 + | struct socket *so; |
409 + | - int s, addrlen = sizeof(addr), opt = 1; |
410 + | + int s, opt = 1; |
411 + | + socklen_t addrlen = sizeof(addr); |
412 + | |
413 + | DEBUG_CALL("solisten"); |
414 + | DEBUG_ARG("port = %d", port); |
415 + | --- ppp/ccp.c |
416 + | +++ ppp/ccp.c |
417 + | |
418 + | |
419 + | if (newret == CONFNAK && dont_nak) |
420 + | newret = CONFREJ; |
421 + | - if (!(newret == CONFACK || newret == CONFNAK && ret == CONFREJ)) { |
422 + | + if (!(newret == CONFACK || (newret == CONFNAK && ret == CONFREJ))) { |
423 + | /* we're returning this option */ |
424 + | if (newret == CONFREJ && ret == CONFNAK) |
425 + | retp = p0; |
426 + | --- ppp/lcp.c |
427 + | +++ ppp/lcp.c |
428 + | |
429 + | #include "chap.h" |
430 + | #include "upap.h" |
431 + | #include "ipcp.h" |
432 + | +#include "ccp.h" |
433 + | |
434 + | /* global vars */ |
435 + | fsm lcp_fsm[NUM_PPP]; /* LCP fsm structure (global)*/ |
436 + | --- ppp/ppp.h |
437 + | +++ ppp/ppp.h |
438 + | |
439 + | |
440 + | void print_string _P((char *, int, void (*) _P((void *, char *, ...)), void *)); |
441 + | |
442 + | +int bad_ip_adrs(u_int32_t addr); |
443 + | +void novm __P((char *)); |
444 + | +void auth_peer_fail(int unit, int protocol); |
445 + | +void auth_withpeer_fail(int unit, int protocol); |
446 + | +void auth_peer_success(int unit, int protocol); |
447 + | +void auth_withpeer_success(int unit, int protocol); |
448 + | +int auth_ip_addr(int unit, u_int32_t addr); |
449 + | +void link_established(int unit); |
450 + | +void link_down(int unit); |
451 + | +void link_required(int unit); |
452 + | +void link_terminated(int unit); |
453 + | +void check_auth_options(); |
454 + | +void check_access(FILE *f, char *filename); |
455 + | + |
456 + | #endif /* __PPP_H__ */ |
457 + | --- ppp/ipcp.c |
458 + | +++ ppp/ipcp.c |
459 + | |
460 + | no.neg_vj = 1; |
461 + | break; |
462 + | case CI_ADDRS: |
463 + | - if (go->neg_addr && go->old_addrs || no.old_addrs |
464 + | + if ((go->neg_addr && go->old_addrs) || no.old_addrs |
465 + | || cilen != CILEN_ADDRS) |
466 + | goto bad; |
467 + | try.neg_addr = 1; |