else if (strcmp("flush", argv[0]) == 0) { error = bridge_flush(sock, brdg); if (error) return (error); } else if (strcmp("flushall", argv[0]) == 0) { error = bridge_flushall(sock, brdg); if (error) return (error); } else if (strcmp("static", argv[0]) == 0) { argc--; argv++; if (argc < 2) { warnx("static requires 2 arguments"); return (EX_USAGE); } error = bridge_addaddr(sock, brdg, argv[0], argv[1]); if (error) return (error); argc--; argv++; } else if (strcmp("deladdr", argv[0]) == 0) { argc--; argv++; if (argc == 0) { warnx("deladdr requires an argument"); return (EX_USAGE); } error = bridge_deladdr(sock, brdg, argv[0]); if (error) return (error); }
main(argc, argv)	int argc;	char *argv[];{	int error = 0, sock;	char *brdg;	if (argc < 2) {		usage();		return (EX_USAGE);	}	sock = socket(AF_INET, SOCK_DGRAM, 0);	if (sock < 0)		err(1, "socket");	argc--; argv++;	brdg = argv[0];	if (strcmp(brdg, "-a") == 0)		return bridge_show_all(sock);	if (!is_bridge(sock, brdg)) {		warnx("%s is not a bridge", brdg);		return (EX_USAGE);	}	if (argc == 1) {		error = bridge_status(sock, brdg);		return (error);	}	for (argc--, argv++; argc != 0; argc--, argv++) {		if (strcmp("add", argv[0]) == 0) {			argc--; argv++;			if (argc == 0) {				warnx("add requires an argument");				return (EX_USAGE);			}			error = bridge_add(sock, brdg, argv[0]);			if (error)				return (error);		}		else if (strcmp("delete", argv[0]) == 0 ||		    strcmp("del", argv[0]) == 0) {			argc--; argv++;			if (argc == 0) {				warnx("delete requires an argument");				return (EX_USAGE);			}			error = bridge_delete(sock, brdg, argv[0]);			if (error)				return (error);		}		else if (strcmp("up", argv[0]) == 0) {			error = bridge_setflag(sock, brdg, IFF_UP);			if (error)				return (error);		}		else if (strcmp("down", argv[0]) == 0) {			error = bridge_clrflag(sock, brdg, IFF_UP);			if (error)				return (error);		}		else if (strcmp("link0", argv[0]) == 0) {			error = bridge_setflag(sock, brdg, IFF_LINK0);			if (error)				return (error);		}		else if (strcmp("-link0", argv[0]) == 0) {			error = bridge_clrflag(sock, brdg, IFF_LINK0);			if (error)				return (error);		}		else if (strcmp("link1", argv[0]) == 0) {			error = bridge_setflag(sock, brdg, IFF_LINK1);			if (error)				return (error);		}		else if (strcmp("-link1", argv[0]) == 0) {			error = bridge_clrflag(sock, brdg, IFF_LINK1);			if (error)				return (error);		}		else if (strcmp("addr", argv[0]) == 0) {			error = bridge_addrs(sock, brdg, "");			if (error)				return (error);		}		else if (strcmp("maxaddr", argv[0]) == 0) {			argc--; argv++;			if (argc == 0) {				warnx("maxaddr requires an argument");				return (EX_USAGE);			}			error = bridge_maxaddr(sock, brdg, argv[0]);			if (error)				return (error);		}		else if (strcmp("timeout", argv[0]) == 0) {			argc--; argv++;			if (argc == 0) {				warnx("timeout requires an argument");				return (EX_USAGE);			}			error = bridge_timeout(sock, brdg, argv[0]);			if (error)				return (error);		}		else {			warnx("unrecognized option: %s", argv[0]);			return (EX_USAGE);		}	}	return (0);}