--- slirp.man +++ slirp.man @@ -1,4 +1,4 @@ -.TH SLIRP 1 "9 Jan 1996" "Version 1.0b" +.TH SLIRP 1 "8 Jan 2006" "Version 1.0.17" .\" Start displayed text macro .de DS @@ -58,7 +58,7 @@ second gap between each. This will disconnect Slirp from your shell's terminal and put Slirp in the background. Later, you can type .DS - slirp -l 0 + slirp \-l 0 .DE to "reconnect" Slirp again. .PP @@ -93,29 +93,29 @@ (Notice the quotes, they ARE significant). The reverse is also true. E.g., if you run slirp as: .DS - slirp -P -b 14400 + slirp \-P \-b 14400 .DE you can create your .slirprc file too look like the following: .DS - -P - -b 14400 + \-P + \-b 14400 .DE (Notice that only ONE command per line is allowed in configuration files). The 2 types of options can also be mixed. For example: .DS In .slirprc: - -P - -b 14400 + \-P + \-b 14400 redir 5022 21 Command line: - slirp -P -b 14400 "redir 5022 21" + slirp \-P \-b 14400 "redir 5022 21" .DE Note that on the command line, any command/option that does not begin with a '-' or '+', and has spaces in it, MUST be enclosed in quotes. E.g., The following are all legal: .DS - slirp -P "redir udp 5022 25" -vj -b 14400 + slirp \-P "redir udp 5022 25" \-vj \-b 14400 slirp "ppp" "baudrate 14400" slirp ppp "baudrate 14400" .DE @@ -125,9 +125,9 @@ The following are NOT legal: .DS slirp baudrate 14400 - slirp "-b 14400" + slirp "\-b 14400" .DE -(Because "-b" starts with a '-' you must NOT enclose it in quotes.) +(Because "\-b" starts with a '-' you must NOT enclose it in quotes.) Easy, eh? .PP Note: Whenever Slirp expects an IP address as an argument (E.g., in @@ -149,8 +149,8 @@ A few notes on configuration: .RS 2 .IP * 2 -You should have "ppp" or "-P" before any PPP options (because when -Slirp parses -P or ppp, it will initialize all related fields, hence +You should have "ppp" or "\-P" before any PPP options (because when +Slirp parses \-P or ppp, it will initialize all related fields, hence clearing anything that was parsed before it). .IP * 2 Upon startup, the configuration is done in this order: @@ -164,9 +164,9 @@ .RE .IP \ 2 This is important because, for example, if you have "initiate-options" -(a PPP option) in ~/.slirprc-0, and you run slirp with -P, -"initiate-options" will not be valid, because -P will clear the fact -that you want options initiated by Slirp (remember, -P should always +(a PPP option) in ~/.slirprc-0, and you run slirp with \-P, +"initiate-options" will not be valid, because \-P will clear the fact +that you want options initiated by Slirp (remember, \-P should always come before any PPP options). .RE .SH "COMMANDS AND OPTIONS" @@ -202,7 +202,7 @@ .br Usable: anywhere .br -Command-line: -X +Command-line: \-X .br Options: .RS 2 @@ -287,7 +287,7 @@ .br Usable: anywhere .br -Command-line: -b +Command-line: \-b .PP Example: baudrate 14400 .PP @@ -433,8 +433,8 @@ wipes out the session, whereas "close N" closes it properly, as a good little tcpip-emulator should :) .PP -"kill -1" shouldn't be used, it will kill the first session it finds -with -1, which usually is the command-line connection. +"kill \-1" shouldn't be used, it will kill the first session it finds +with \-1, which usually is the command-line connection. .RE .IP "close N" .RS 4 @@ -792,9 +792,9 @@ If your PPP software is unable to escape these characters, or you're using (C)SLIP (which must have an 8bit clean link), your best bet is to try and make the link 8bit clean. For example, on some systems you can -give telnet the -8 flag to make the link 8bit, and -E to stop it from -interpreting the ^] character. Similarly for rlogin; -8 to make the -link 8bit, -E to stop rlogin from interpreting the ~ character. You +give telnet the \-8 flag to make the link 8bit, and \-E to stop it from +interpreting the ^] character. Similarly for rlogin; \-8 to make the +link 8bit, \-E to stop rlogin from interpreting the ~ character. You should look at the telnet and rlogin manual pages ("man telnet" and "man rlogin" respectively) to see if your telnet/rlogin has similar options. @@ -815,7 +815,7 @@ Now, when you telnet to the host you wish to run the X programs from, you should do as Slirp suggest above; type either of the two commands, depending on which shell you are using. You could also run the X -program as "xprog -display IP.ADDRESS:X.Y" as printed above. +program as "xprog \-display IP.ADDRESS:X.Y" as printed above. .IP If you missed what Slirp displayed on startup, you can telnet to 10.0.2.0 and give Slirp the command "show X", and the above will be @@ -886,13 +886,13 @@ with the following information: .RS 2 .IP * 2 -Output of the command "uname -a" on the remote system; +Output of the command "uname \-a" on the remote system; .IP * 2 Operating System name and version you run on your PC; .IP * 2 Version of Slirp you are using (IMPORTANT!!!); .IP * 2 -If you managed to get Slirp running, run Slirp as "slirp -S" then try +If you managed to get Slirp running, run Slirp as "slirp \-S" then try whatever failed. When you exit Slirp, you should have a file called "slirp_stats". Send me this file; and .IP * 2 --- ppp.c +++ ppp.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include --- udp.c +++ udp.c @@ -371,7 +371,7 @@ struct mbuf *m; { struct sockaddr_in addr; - int addrlen = sizeof(addr); + socklen_t addrlen = sizeof(addr); #ifdef EMULATE_TALK CTL_MSG_OLD *omsg; CTL_MSG *nmsg; @@ -596,7 +596,7 @@ { struct sockaddr_in addr; struct socket *so; - int addrlen = sizeof(struct sockaddr_in), opt = 1; + socklen_t addrlen = sizeof(struct sockaddr_in), opt = 1; if ((so = socreate()) == NULL) { free(so); --- tcp_subr.c +++ tcp_subr.c @@ -463,7 +463,7 @@ { struct socket *so; struct sockaddr_in addr; - int addrlen = sizeof(struct sockaddr_in); + socklen_t addrlen = sizeof(struct sockaddr_in); struct tcpcb *tp; int s, opt; @@ -658,7 +658,7 @@ { struct socket *tmpso; struct sockaddr_in addr; - int addrlen = sizeof(struct sockaddr_in); + socklen_t addrlen = sizeof(struct sockaddr_in); struct sbuf *so_rcv = &so->so_rcv; memcpy(so_rcv->sb_wptr, m->m_data, m->m_len); --- Makefile.in +++ Makefile.in @@ -209,3 +209,4 @@ .c.o: $(COMMON_H) $(CC) $(CFLAGS) -c $< -o $@ +nothing: --- main.c +++ main.c @@ -9,6 +9,7 @@ #define WANT_SYS_IOCTL_H #define WANT_TERMIOS_H #include +#include #include "main.h" struct timeval tt; @@ -237,7 +242,7 @@ /* It's an internet socket */ if (sscanf(*argv, "%d,%[^:]:%d,%s", &unit, hn, &port, pwd) != 4) { - lprint("Error: bad arguements to -l\n"); + lprint("Error: bad arguments to -l\n"); slirp_exit(1); } if (strcmp(pwd, "-") == 0) { @@ -990,10 +995,10 @@ char *device = dev; #ifndef NO_UNIX_SOCKETS struct sockaddr_un sock_un; - int sock_len = sizeof(struct sockaddr_un); + socklen_t sock_len = sizeof(struct sockaddr_un); #endif struct sockaddr_in sock_in; - int sock_len2 = sizeof(struct sockaddr_in); + socklen_t sock_len2 = sizeof(struct sockaddr_in); fd = -1; if (slirp_socket_passwd) @@ -1029,7 +1034,7 @@ sleep(1); if (read(fd, buff, 256) < 0) { /* Nuke both connections */ - sprintf(buff, "0 Connection timed out"); + snprintf(buff, sizeof(buff), "0 Connection timed out"); write(fd, buff, strlen(buff)+1); slirp_socket_wait = curtime; close(fd); @@ -1041,7 +1046,7 @@ if (sscanf(buff, "%d %d %256s", &unit, &pid, device) == 3) { if (unit >= MAX_INTERFACES || unit < 0) { - sprintf(buff, "0 Unit out of range (must be between 0 and %d, inclusive)", MAX_INTERFACES-1); + snprintf(buff, sizeof(buff), "0 Unit out of range (must be between 0 and %d, inclusive)", MAX_INTERFACES-1); write(fd, buff, strlen(buff)+1); slirp_socket_wait = curtime; close(fd); @@ -1052,7 +1057,7 @@ * (pid is invalid) */ if (slirp_socket_passwd) { if (strcmp(slirp_socket_passwd, device) != 0) { - sprintf(buff, "0 Incorrect password"); + snprintf(buff, sizeof(buff), "0 Incorrect password"); write(fd, buff, strlen(buff)+1); slirp_socket_wait = curtime; close(fd); @@ -1076,7 +1081,7 @@ * failure, 1 for exit, and message is printed */ if (ttyp) { - sprintf(buff, "0 Unit already attached"); + snprintf(buff, sizeof(buff), "0 Unit already attached"); write(fd, buff, strlen(buff)+1); slirp_socket_wait = curtime; close(fd); @@ -1090,7 +1095,7 @@ strcpy(buff2, "PPP"); else #endif - sprintf(buff2, "SLIP, MTU %d, MRU %d", if_mtu, if_mru); + snprintf(buff2, sizeof(buff2), "SLIP, MTU %d, MRU %d", if_mtu, if_mru); #ifndef FULL_BOLT snprintf(buff, sizeof(buff), "1 Attached as unit %d, device %s\r\n\r\n[talking %s, %d baud]\r\n\r\nSLiRP Ready ...", @@ -1111,7 +1116,7 @@ ttyp->fd = fd; } } else { - sprintf(buff, "0 %s", strerror(errno)); + snprintf(buff, sizeof(buff), "0 %s", strerror(errno)); write(fd, buff, strlen(buff)+1); slirp_socket_wait = curtime; close(fd); --- mbuf.h +++ mbuf.h @@ -132,6 +132,6 @@ extern struct mbstat mbstat; extern int mbuf_alloced; extern struct mbuf m_freelist, m_usedlist; -extern mbuf_max; +extern int mbuf_max; #endif --- misc.c +++ misc.c @@ -298,7 +298,7 @@ { int s; struct sockaddr_in addr; - int addrlen = sizeof(addr); + socklen_t addrlen = sizeof(addr); int opt; int master; char *argv[256]; @@ -403,7 +403,7 @@ { char buff[256]; - sprintf(buff, "Error: execvp of %s failed: %s\n", + snprintf(buff, sizeof(buff), "Error: execvp of %s failed: %s\n", argv[0], strerror(errno)); write(2, buff, strlen(buff)+1); } @@ -490,7 +490,7 @@ if (connect(s, (struct sockaddr *)&sock_un, sizeof(sock_un.sun_family) + sizeof(sock_un.sun_path)) != 0) slirp_exit(1); - sprintf(buff, "kill none:%d", slirp_socket_unit); + snprintf(buff, sizeof(buff), "kill none:%d", slirp_socket_unit); write(s, buff, strlen(buff)+1); } #endif @@ -917,7 +917,7 @@ /* Ooops, failed, let's tell the user why */ - sprintf(buff, "Error: execlp of %s failed: %s\n", + snprintf(buff, sizeof(buff), "Error: execlp of %s failed: %s\n", "rsh", strerror(errno)); write(2, buff, strlen(buff)+1); close(0); close(1); close(2); /* XXX */ --- options.c +++ options.c @@ -27,6 +27,8 @@ #define GIDSET_TYPE int #endif +#include + void readable _P((int fd)); /* --- ttys.c +++ ttys.c @@ -11,6 +11,8 @@ #endif #include +void lcp_lowerdown(int unit); + struct ttys *ttys_unit[MAX_INTERFACES]; int slirp_forked; @@ -92,9 +94,9 @@ /* Config the new tty */ if ((bptr = (char *)getenv("HOME"))) - sprintf(buff, "%s/.slirprc-%d", bptr, unit); + snprintf(buff, sizeof(buff), "%s/.slirprc-%d", bptr, unit); else - sprintf(buff, ".slirprc-%d", unit); + snprintf(buff, sizeof(buff), ".slirprc-%d", unit); config(buff, ttyp->unit); return ttyp; --- tcp_output.c +++ tcp_output.c @@ -592,7 +592,7 @@ tcp_setpersist(tp) register struct tcpcb *tp; { - register t = ((tp->t_srtt >> 2) + tp->t_rttvar) >> 1; + register int t = ((tp->t_srtt >> 2) + tp->t_rttvar) >> 1; /* if (tp->t_timer[TCPT_REXMT]) * panic("tcp_output REXMT"); --- socket.c +++ socket.c @@ -377,7 +377,7 @@ struct socket *so; { struct sockaddr_in addr; - int addrlen = sizeof(struct sockaddr_in); + socklen_t addrlen = sizeof(struct sockaddr_in); DEBUG_CALL("sorecvfrom"); DEBUG_ARG("so = %lx", (long)so); @@ -530,7 +530,8 @@ { struct sockaddr_in addr; struct socket *so; - int s, addrlen = sizeof(addr), opt = 1; + int s, opt = 1; + socklen_t addrlen = sizeof(addr); DEBUG_CALL("solisten"); DEBUG_ARG("port = %d", port); --- ppp/ccp.c +++ ppp/ccp.c @@ -464,7 +464,7 @@ if (newret == CONFNAK && dont_nak) newret = CONFREJ; - if (!(newret == CONFACK || newret == CONFNAK && ret == CONFREJ)) { + if (!(newret == CONFACK || (newret == CONFNAK && ret == CONFREJ))) { /* we're returning this option */ if (newret == CONFREJ && ret == CONFNAK) retp = p0; --- ppp/lcp.c +++ ppp/lcp.c @@ -39,6 +39,7 @@ #include "chap.h" #include "upap.h" #include "ipcp.h" +#include "ccp.h" /* global vars */ fsm lcp_fsm[NUM_PPP]; /* LCP fsm structure (global)*/ --- ppp/ppp.h +++ ppp/ppp.h @@ -54,4 +54,18 @@ void print_string _P((char *, int, void (*) _P((void *, char *, ...)), void *)); +int bad_ip_adrs(u_int32_t addr); +void novm __P((char *)); +void auth_peer_fail(int unit, int protocol); +void auth_withpeer_fail(int unit, int protocol); +void auth_peer_success(int unit, int protocol); +void auth_withpeer_success(int unit, int protocol); +int auth_ip_addr(int unit, u_int32_t addr); +void link_established(int unit); +void link_down(int unit); +void link_required(int unit); +void link_terminated(int unit); +void check_auth_options(); +void check_access(FILE *f, char *filename); + #endif /* __PPP_H__ */ --- ppp/ipcp.c +++ ppp/ipcp.c @@ -568,7 +568,7 @@ no.neg_vj = 1; break; case CI_ADDRS: - if (go->neg_addr && go->old_addrs || no.old_addrs + if ((go->neg_addr && go->old_addrs) || no.old_addrs || cilen != CILEN_ADDRS) goto bad; try.neg_addr = 1;