shithub: riscv

Download patch

ref: c76cc12a1799ce214b07882eb6f4ab0906c0151b
parent: 0a7279b3aff262493e5c80f17a540a4b5e8987a5
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun May 12 09:42:26 EDT 2024

ip/ipconfig: add "null" verb to bind nullmedium

Example usage:

ip/ipconfig null /dev/mordor 8.8.8.8 /128

--- a/sys/src/cmd/ip/ipconfig/ipconfig.h
+++ b/sys/src/cmd/ip/ipconfig/ipconfig.h
@@ -16,6 +16,7 @@
 	Vtorus,
 	Vtree,
 	Vpkt,
+	Vnull,
 };
 
 typedef struct Conf Conf;
--- a/sys/src/cmd/ip/ipconfig/main.c
+++ b/sys/src/cmd/ip/ipconfig/main.c
@@ -182,6 +182,7 @@
 		[Vtorus]	"torus",
 		[Vtree]		"tree",
 		[Vpkt]		"pkt",
+		[Vnull]		"null",
 	};
 	int i;
 
@@ -226,6 +227,7 @@
 		case Vppp:
 		case Vtorus:
 		case Vtree:
+		case Vnull:
 			conf.type = *argv++;
 			argc--;
 			if(argc > 0){
@@ -236,8 +238,11 @@
 			break;
 		}
 	}
-	if(conf.dev == nil)
+	if(conf.dev == nil){
+		if(!isether())
+			sysfatal("no device specified for medium %s", conf.type);
 		conf.dev = finddev(conf.mpoint, "ether", "/net/ether0");
+	}
 
 	/* get optional verb */
 	if (argc > 0){
@@ -250,6 +255,7 @@
 		case Vtorus:
 		case Vtree:
 		case Vpkt:
+		case Vnull:
 			sysfatal("medium %s already specified", conf.type);
 		case Vadd:
 		case Vdel: