shithub: riscv

Download patch

ref: 7d88d76bc42e2b3f3cabde82673af4107e951797
parent: ffc267c831a8f31591d5ee35dfb0796cf0efee79
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat May 27 17:23:43 EDT 2023

ip/ppp: update the test-program

--- a/sys/src/cmd/ip/ppp/testppp.c
+++ b/sys/src/cmd/ip/ppp/testppp.c
@@ -6,15 +6,17 @@
 long	errrate;
 long	droprate;
 int	framing;
+int	noauth;
 int	nocompress;
 int	noipcompress;
-char	*ppp = "8.out";
+int	proxy;
+char	*ppp = "6.out";
 char	*mtu;
 
 void
 pppopen(int fd, char *net, char *local, char *remote)
 {
-	char *argv[16];
+	char *argv[32];
 	int argc;
 
 	switch(fork()){
@@ -29,11 +31,19 @@
 
 	dup(fd, 0);
 	dup(fd, 1);
-
 	argc = 0;
 	argv[argc++] = ppp;
 	if(debug)
 		argv[argc++] = "-d";
+	if(local){
+		/* server */
+		argv[argc++] = "-S";
+		if(noauth)
+			argv[argc++] = "-a";
+	} else {
+		/* client */
+		argv[argc++] = "-P";
+	}
 	if(framing)
 		argv[argc++] = "-f";
 	if(nocompress)
@@ -46,12 +56,15 @@
 	}
 	argv[argc++] = "-x";
 	argv[argc++] = net;
+	if(proxy){
+		argv[argc++] = "-y";
+	}
 	if(local){
 		argv[argc++] = local;
 		if(remote)
 			argv[argc++] = remote;
 	}
-	argv[argc] = 0;
+	argv[argc] = nil;
 	exec(ppp, argv);
 }
 
@@ -129,7 +142,7 @@
 void
 usage(void)
 {
-	fprint(2, "usage: testppp [-cCDf] [-e errrate] [-d droprate] [-m mtu] [-p ppp]\n");
+	fprint(2, "usage: testppp [-cCDf] [-e errrate] [-d droprate] [-m mtu] [-p ppp] local remote\n");
 	exits("usage");
 }
 
@@ -143,6 +156,9 @@
 	errrate = 0;
 	droprate = 0;
 	ARGBEGIN{
+	case 'a':
+		noauth = 1;
+		break;
 	case 'c':
 		nocompress = 1;
 		break;
@@ -173,19 +189,21 @@
 		if(ppp == nil)
 			usage();
 		break;
+	case 'y':
+		proxy = 1;
+		break;
 	default:
 		usage();
 		break;
 	}ARGEND
-	if(argc)
+
+	if(argc != 2)
 		usage();
 
 	pipe(pfd1);
 	pipe(pfd2);
 
-	bind("#I2", "/net.alt2", MCREATE);
-	bind("#I1", "/net.alt", MCREATE);
-	pppopen(pfd1[0], "/net.alt2", "135.104.99.1", "135.104.99.2");
+	pppopen(pfd1[0], "/net", argv[0], argv[1]);
 	pppopen(pfd2[0], "/net.alt", 0, 0);
 
 	close(pfd1[0]);