/* vi: set sw=4 ts=4: */
/*
 * Small implementation of brctl for busybox.
 *
 * Copyright (C) 2008 by Bernhard Reutner-Fischer
 *
 * Some helper functions from bridge-utils are
 * Copyright (C) 2000 Lennert Buytenhek
 *
 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
 */
//config:config BRCTL
//config:	bool "brctl (4.7 kb)"
//config:	default y
//config:	select PLATFORM_LINUX
//config:	help
//config:	Manage ethernet bridges.
//config:	Supports addbr/delbr and addif/delif.
//config:
//config:config FEATURE_BRCTL_FANCY
//config:	bool "Fancy options"
//config:	default y
//config:	depends on BRCTL
//config:	help
//config:	Add support for extended option like:
//config:		setageing, setfd, sethello, setmaxage,
//config:		setpathcost, setportprio, setbridgeprio,
//config:		stp
//config:	This adds about 600 bytes.
//config:
//config:config FEATURE_BRCTL_SHOW
//config:	bool "Support show"
//config:	default y
//config:	depends on BRCTL && FEATURE_BRCTL_FANCY
//config:	help
//config:	Add support for option which prints the current config:
//config:		show

//applet:IF_BRCTL(APPLET_NOEXEC(brctl, brctl, BB_DIR_USR_SBIN, BB_SUID_DROP, brctl))

//kbuild:lib-$(CONFIG_BRCTL) += brctl.o

//usage:#define brctl_trivial_usage
//usage:       "COMMAND [BRIDGE [ARGS]]"
//usage:#define brctl_full_usage "\n\n"
//usage:       "Manage ethernet bridges"
//usage:     "\nCommands:"
//usage:	IF_FEATURE_BRCTL_SHOW(
//usage:     "\n	show [BRIDGE]...	Show bridges"
//usage:	)
//usage:     "\n	addbr BRIDGE		Create BRIDGE"
//usage:     "\n	delbr BRIDGE		Delete BRIDGE"
//usage:     "\n	addif BRIDGE IFACE	Add IFACE to BRIDGE"
//usage:     "\n	delif BRIDGE IFACE	Delete IFACE from BRIDGE"
//usage:	IF_FEATURE_BRCTL_FANCY(
//usage:     "\n	showmacs BRIDGE			List MAC addresses"
//usage:     "\n	showstp	BRIDGE			Show STP info"
//usage:     "\n	stp BRIDGE 1/yes/on|0/no/off	Set STP on/off"
//usage:     "\n	setageing BRIDGE SECONDS	Set ageing time"
//usage:     "\n	setfd BRIDGE SECONDS		Set bridge forward delay"
//usage:     "\n	sethello BRIDGE SECONDS		Set hello time"
//usage:     "\n	setmaxage BRIDGE SECONDS	Set max message age"
//usage:     "\n	setbridgeprio BRIDGE PRIO	Set bridge priority"
//usage:     "\n	setportprio BRIDGE IFACE PRIO	Set port priority"
//usage:     "\n	setpathcost BRIDGE IFACE COST	Set path cost"
//usage:	)
// Not yet implemented:
//			hairpin BRIDGE IFACE on|off	Set hairpin on/off

#include "libbb.h"
#include "common_bufsiz.h"
#include <linux/sockios.h>
#include <net/if.h>

#ifndef SIOCBRADDBR
# define SIOCBRADDBR BRCTL_ADD_BRIDGE
#endif
#ifndef SIOCBRDELBR
# define SIOCBRDELBR BRCTL_DEL_BRIDGE
#endif
#ifndef SIOCBRADDIF
# define SIOCBRADDIF BRCTL_ADD_IF
#endif
#ifndef SIOCBRDELIF
# define SIOCBRDELIF BRCTL_DEL_IF
#endif

#if ENABLE_FEATURE_BRCTL_FANCY
static unsigned str_to_jiffies(const char *time_str)
{
	double dd;
	char *endptr;
//TODO: needs setlocale(LC_NUMERIC, "C")?
	dd = /*bb_*/strtod(time_str, &endptr);
	if (endptr == time_str || dd < 0)
		bb_error_msg_and_die(bb_msg_invalid_arg_to, time_str, "timespec");

	dd *= 100;
	/* For purposes of brctl,
	 * capping SECONDS by ~20 million seconds is quite enough:
	 */
	if (dd > INT_MAX)
		dd = INT_MAX;

	return dd;
}
#endif

#define filedata bb_common_bufsiz1

#if ENABLE_FEATURE_BRCTL_SHOW || ENABLE_FEATURE_BRCTL_FANCY
static int read_file(const char *name)
{
	int n = open_read_close(name, filedata, COMMON_BUFSIZE - 1);
	if (n < 0) {
		filedata[0] = '\0';
	} else {
		filedata[n] = '\0';
		if (n != 0 && filedata[n - 1] == '\n')
			filedata[--n] = '\0';
	}
	return n;
}
#endif

#if ENABLE_FEATURE_BRCTL_SHOW
/* NB: we are in /sys/class/net
 */
static int show_bridge(const char *name, int need_hdr)
{
/* Output:
 *bridge name	bridge id		STP enabled	interfaces
 *br0		8000.000000000000	no		eth0
 */
	char pathbuf[IFNAMSIZ + sizeof("/bridge/bridge_id") + 8];
	int tabs;
	DIR *ifaces;
	struct dirent *ent;
	char *sfx;

#if IFNAMSIZ == 16
	sfx = pathbuf + sprintf(pathbuf, "%.16s/bridge/", name);
#else
	sfx = pathbuf + sprintf(pathbuf, "%.*s/bridge/", (int)IFNAMSIZ, name);
#endif
	strcpy(sfx, "bridge_id");
	if (read_file(pathbuf) < 0)
		return -1; /* this iface is not a bridge */

	if (need_hdr)
		puts("bridge name\tbridge id\t\tSTP enabled\tinterfaces");
	printf("%s\t\t%s\t", name, filedata);

	strcpy(sfx, "stp_state");
	read_file(pathbuf);
	if (LONE_CHAR(filedata, '0'))
		strcpy(filedata, "no");
	else
	if (LONE_CHAR(filedata, '1'))
		strcpy(filedata, "yes");
	fputs_stdout(filedata);

	/* sfx points past "BR/bridge/", turn it into "BR/brif": */
	sfx[-4] = 'f'; sfx[-3] = '\0';
	tabs = 0;
	ifaces = opendir(pathbuf);
	if (ifaces) {
		while ((ent = readdir(ifaces)) != NULL) {
			if (DOT_OR_DOTDOT(ent->d_name))
				continue; /* . or .. */
			if (tabs)
				printf("\t\t\t\t\t");
			else
				tabs = 1;
			printf("\t\t%s\n", ent->d_name);
		}
		closedir(ifaces);
	}
	if (!tabs)  /* bridge has no interfaces */
		bb_putchar('\n');
	return 0;
}
#endif

#if ENABLE_FEATURE_BRCTL_FANCY
static void write_uint(const char *name, const char *leaf, unsigned val)
{
	char pathbuf[IFNAMSIZ + sizeof("/bridge/bridge_id") + 32];
	int fd, n;

#if IFNAMSIZ == 16
	sprintf(pathbuf, "%.16s/%s", name, leaf);
#else
	sprintf(pathbuf, "%.*s/%s", (int)IFNAMSIZ, name, leaf);
#endif
	fd = xopen(pathbuf, O_WRONLY);
	n = sprintf(filedata, "%u\n", val);
	if (write(fd, filedata, n) < 0)
		bb_simple_perror_msg_and_die(name);
	/* So far all callers exit very soon after calling us.
	 * Do not bother closing fd (unless debugging):
	 */
	if (ENABLE_FEATURE_CLEAN_UP)
		close(fd);
}

struct fdb_entry {
	uint8_t mac_addr[6];
	uint8_t port_no;
	uint8_t is_local;
	uint32_t ageing_timer_value;
	uint8_t port_hi;
	uint8_t pad0;
	uint16_t unused;
};

static int compare_fdbs(const void *_f0, const void *_f1)
{
	const struct fdb_entry *f0 = _f0;
	const struct fdb_entry *f1 = _f1;

	return memcmp(f0->mac_addr, f1->mac_addr, 6);
}

static size_t read_bridge_forward_db(const char *name, struct fdb_entry **_fdb)
{
	char pathbuf[IFNAMSIZ + sizeof("/brforward") + 8];
	struct fdb_entry *fdb;
	size_t nentries;
	int fd;
	ssize_t cc;

#if IFNAMSIZ == 16
	sprintf(pathbuf, "%.16s/brforward", name);
#else
	sprintf(pathbuf, "%.*s/brforward", (int)IFNAMSIZ, name);
#endif
	fd = open(pathbuf, O_RDONLY);
	if (fd < 0)
		bb_error_msg_and_die("bridge %s does not exist", name);

	fdb = NULL;
	nentries = 0;
	for (;;) {
		fdb = xrealloc_vector(fdb, 4, nentries);
		cc = full_read(fd, &fdb[nentries], sizeof(*fdb));
		if (cc == 0) {
			break;
		}
		if (cc != sizeof(*fdb)) {
			bb_perror_msg_and_die("can't read bridge %s forward db", name);
		}
		++nentries;
	}

	if (ENABLE_FEATURE_CLEAN_UP)
		close(fd);

	qsort(fdb, nentries, sizeof(*fdb), compare_fdbs);

	*_fdb = fdb;
	return nentries;
}

static void show_bridge_macs(const char *name)
{
	struct fdb_entry *fdb;
	size_t nentries;
	size_t i;

	nentries = read_bridge_forward_db(name, &fdb);

	printf("port no\tmac addr\t\tis local?\tageing timer\n");
	for (i = 0; i < nentries; ++i) {
		const struct fdb_entry *f = &fdb[i];
		unsigned tv_sec = f->ageing_timer_value / 100;
		unsigned tv_csec = f->ageing_timer_value % 100;
		printf("%3u\t"
			"%.2x:%.2x:%.2x:%.2x:%.2x:%.2x\t"
			"%s\t\t"
			"%4u.%.2u\n",
			f->port_no,
			f->mac_addr[0], f->mac_addr[1], f->mac_addr[2],
			f->mac_addr[3], f->mac_addr[4], f->mac_addr[5],
			(f->is_local ? "yes" : "no"),
			tv_sec, tv_csec
		);
	}

	if (ENABLE_FEATURE_CLEAN_UP)
		free(fdb);
}

static void show_bridge_timer(const char *msg)
{
	unsigned long long centisec = xstrtoull(filedata, 0);
	unsigned tv_sec = centisec / 100;
	unsigned tv_csec = centisec % 100;
	printf("%s%4u.%.2u", msg, tv_sec, tv_csec);
}

static const char *show_bridge_state(unsigned state)
{
	/* See linux/if_bridge.h, BR_STATE_ constants */
	static const char state_names[] ALIGN1 =
		"disabled\0"	//BR_STATE_DISABLED   0
		"listening\0"   //BR_STATE_LISTENING  1
		"learning\0"    //BR_STATE_LEARNING   2
		"forwarding\0"  //BR_STATE_FORWARDING 3
		"blocking"      //BR_STATE_BLOCKING   4
	;
	if (state < 5)
		return nth_string(state_names, state);
	return utoa(state);
}

static void printf_xstrtou(const char *fmt)
{
	printf(fmt, xstrtou(filedata, 0));
}

static NOINLINE void show_bridge_port(const char *name)
{
	char pathbuf[IFNAMSIZ + sizeof("/brport/forward_delay_timer") + 8];
	char *sfx;

#if IFNAMSIZ == 16
	sfx = pathbuf + sprintf(pathbuf, "%.16s/brport/", name);
#else
	sfx = pathbuf + sprintf(pathbuf, "%.*s/brport/", (int)IFNAMSIZ, name);
#endif

	strcpy(sfx, "port_no");
	read_file(pathbuf);
	printf("%s (%u)\n", name, xstrtou(filedata, 0));

	strcpy(sfx + 5, "id"); // "port_id"
	read_file(pathbuf);
	printf_xstrtou(" port id\t\t%.4x");

	strcpy(sfx, "state");
	read_file(pathbuf);
	printf("\t\t\tstate\t\t%15s\n", show_bridge_state(xstrtou(filedata, 0)));

	strcpy(sfx, "designated_root");
	read_file(pathbuf);
	printf(" designated root\t%s", filedata);

	strcpy(sfx, "path_cost");
	read_file(pathbuf);
	printf_xstrtou("\tpath cost\t\t%4u\n");

	strcpy(sfx, "designated_bridge");
	read_file(pathbuf);
	printf(" designated bridge\t%s", filedata);

	strcpy(sfx, "message_age_timer");
	read_file(pathbuf);
	show_bridge_timer("\tmessage age timer\t");

	strcpy(sfx, "designated_port");
	read_file(pathbuf);
	printf_xstrtou("\n designated port\t%.4x");

	strcpy(sfx, "forward_delay_timer");
	read_file(pathbuf);
	show_bridge_timer("\t\t\tforward delay timer\t");

	strcpy(sfx, "designated_cost");
	read_file(pathbuf);
	printf_xstrtou("\n designated cost\t%4u");

	strcpy(sfx, "hold_timer");
	read_file(pathbuf);
	show_bridge_timer("\t\t\thold timer\t\t");

	printf("\n flags\t\t\t");

	strcpy(sfx, "config_pending");
	read_file(pathbuf);
	if (!LONE_CHAR(filedata, '0'))
		printf("CONFIG_PENDING ");

	strcpy(sfx, "change_ack");
	read_file(pathbuf);
	if (!LONE_CHAR(filedata, '0'))
		printf("TOPOLOGY_CHANGE_ACK ");

	strcpy(sfx, "hairpin_mode");
	read_file(pathbuf);
	if (!LONE_CHAR(filedata, '0'))
		printf_xstrtou("\n hairpin mode\t\t%4u");

	printf("\n\n");
}

static void show_bridge_stp(const char *name)
{
	char pathbuf[IFNAMSIZ + sizeof("/bridge/topology_change_timer") + 8];
	char *sfx;

#if IFNAMSIZ == 16
	sfx = pathbuf + sprintf(pathbuf, "%.16s/bridge/", name);
#else
	sfx = pathbuf + sprintf(pathbuf, "%.*s/bridge/", (int)IFNAMSIZ, name);
#endif

	strcpy(sfx, "bridge_id");
	if (read_file(pathbuf) < 0)
		bb_error_msg_and_die("bridge %s does not exist", name);

	printf("%s\n"
		" bridge id\t\t%s", name, filedata);

	strcpy(sfx, "root_id");
	read_file(pathbuf);
	printf("\n designated root\t%s", filedata);

	strcpy(sfx + 5, "port"); // "root_port"
	read_file(pathbuf);
	printf_xstrtou("\n root port\t\t%4u\t\t\t");

	strcpy(sfx + 6, "ath_cost"); // "root_path_cost"
	read_file(pathbuf);
	printf_xstrtou("path cost\t\t%4u\n");

	strcpy(sfx, "max_age");
	read_file(pathbuf);
	show_bridge_timer(" max age\t\t");
	show_bridge_timer("\t\t\tbridge max age\t\t");

	strcpy(sfx, "hello_time");
	read_file(pathbuf);
	show_bridge_timer("\n hello time\t\t");
	show_bridge_timer("\t\t\tbridge hello time\t");

	strcpy(sfx, "forward_delay");
	read_file(pathbuf);
	show_bridge_timer("\n forward delay\t\t");
	show_bridge_timer("\t\t\tbridge forward delay\t");

	strcpy(sfx, "ageing_time");
	read_file(pathbuf);
	show_bridge_timer("\n ageing time\t\t");

	strcpy(sfx, "hello_timer");
	read_file(pathbuf);
	show_bridge_timer("\n hello timer\t\t");

	strcpy(sfx, "tcn_timer");
	read_file(pathbuf);
	show_bridge_timer("\t\t\ttcn timer\t\t");

	strcpy(sfx, "topology_change_timer");
	read_file(pathbuf);
	show_bridge_timer("\n topology change timer\t");

	strcpy(sfx, "gc_timer");
	read_file(pathbuf);
	show_bridge_timer("\t\t\tgc timer\t\t");

	printf("\n flags\t\t\t");

	strcpy(sfx, "topology_change");
	read_file(pathbuf);
	if (!LONE_CHAR(filedata, '0'))
		printf("TOPOLOGY_CHANGE ");

	strcpy(sfx, "topology_change_detected");
	read_file(pathbuf);
	if (!LONE_CHAR(filedata, '0'))
		printf("TOPOLOGY_CHANGE_DETECTED ");
	printf("\n\n\n");

	/* Show bridge ports */
	{
		DIR *ifaces;

		/* sfx points past "BR/bridge/", turn it into "BR/brif": */
		sfx[-4] = 'f'; sfx[-3] = '\0';
		ifaces = opendir(pathbuf);
		if (ifaces) {
			struct dirent *ent;
			while ((ent = readdir(ifaces)) != NULL) {
				if (DOT_OR_DOTDOT(ent->d_name))
					continue; /* . or .. */
				show_bridge_port(ent->d_name);
			}
			if (ENABLE_FEATURE_CLEAN_UP)
				closedir(ifaces);
		}
	}
}
#endif

int brctl_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int brctl_main(int argc UNUSED_PARAM, char **argv)
{
	static const char keywords[] ALIGN1 =
		"addbr\0" "delbr\0" "addif\0" "delif\0"
	IF_FEATURE_BRCTL_FANCY(
		"stp\0"
		"showstp\0"
		"setageing\0" "setfd\0" "sethello\0" "setmaxage\0"
		"setpathcost\0" "setportprio\0"
		"setbridgeprio\0"
		"showmacs\0"
	)
	IF_FEATURE_BRCTL_SHOW("show\0");
	enum { ARG_addbr = 0, ARG_delbr, ARG_addif, ARG_delif
		IF_FEATURE_BRCTL_FANCY(,
			ARG_stp,
			ARG_showstp,
			ARG_setageing, ARG_setfd, ARG_sethello, ARG_setmaxage,
			ARG_setpathcost, ARG_setportprio,
			ARG_setbridgeprio,
			ARG_showmacs
		)
		IF_FEATURE_BRCTL_SHOW(, ARG_show)
	};
	int key;
	char *br;

	argv++;
	if (!*argv) {
		/* bare "brctl" shows --help */
		bb_show_usage();
	}

	xchdir("/sys/class/net");

	key = index_in_strings(keywords, *argv);
	if (key == -1) /* no match found in keywords array, bail out. */
		bb_error_msg_and_die(bb_msg_invalid_arg_to, *argv, applet_name);
	argv++;

#if ENABLE_FEATURE_BRCTL_SHOW
	if (key == ARG_show) { /* show [BR]... */
		DIR *net;
		struct dirent *ent;
		int need_hdr = 1;
		int exitcode = EXIT_SUCCESS;

		if (*argv) {
			/* "show BR1 BR2 BR3" */
			do {
				if (show_bridge(*argv, need_hdr) >= 0) {
					need_hdr = 0;
				} else {
					bb_error_msg("bridge %s does not exist", *argv);
//TODO: if device exists, but is not a BR, brctl from bridge-utils 1.6
//says this instead: "device eth0 is not a bridge"
					exitcode = EXIT_FAILURE;
				}
			} while (*++argv != NULL);
			return exitcode;
		}

		/* "show" (if no ifaces, shows nothing, not even header) */
		net = xopendir(".");
		while ((ent = readdir(net)) != NULL) {
			if (DOT_OR_DOTDOT(ent->d_name))
				continue; /* . or .. */
			if (show_bridge(ent->d_name, need_hdr) >= 0)
				need_hdr = 0;
		}
		if (ENABLE_FEATURE_CLEAN_UP)
			closedir(net);
		return exitcode;
	}
#endif

	if (!*argv) /* All of the below need at least one argument */
		bb_show_usage();

	br = *argv++;

	if (key == ARG_addbr || key == ARG_delbr) {
		/* brctl from bridge-utils 1.6 still uses ioctl
		 * for SIOCBRADDBR / SIOCBRDELBR, not /sys accesses
		 */
		int fd = xsocket(AF_INET, SOCK_STREAM, 0);
		ioctl_or_perror_and_die(fd,
			key == ARG_addbr ? SIOCBRADDBR : SIOCBRDELBR,
			br, "bridge %s", br
		);
		//close(fd);
		//goto done;
		/* bridge-utils 1.6 simply ignores trailing args:
		 * "brctl addbr BR1 ARGS" ignores ARGS
		 */
		if (ENABLE_FEATURE_CLEAN_UP)
			close(fd);
		return EXIT_SUCCESS;
	}

#if ENABLE_FEATURE_BRCTL_FANCY
	if (key == ARG_showmacs) {
		show_bridge_macs(br);
		return EXIT_SUCCESS;
	}
	if (key == ARG_showstp) {
		show_bridge_stp(br);
		return EXIT_SUCCESS;
	}
#endif

	if (!*argv) /* All of the below need at least two arguments */
		bb_show_usage();

#if ENABLE_FEATURE_BRCTL_FANCY
	if (key == ARG_stp) {
		static const char no_yes[] ALIGN1 =
			"0\0" "off\0" "n\0" "no\0"   /* 0 .. 3 */
			"1\0" "on\0"  "y\0" "yes\0"; /* 4 .. 7 */
		int onoff = index_in_strings(no_yes, *argv);
		if (onoff < 0)
			bb_error_msg_and_die(bb_msg_invalid_arg_to, *argv, applet_name);
		onoff = (unsigned)onoff / 4;
		write_uint(br, "bridge/stp_state", onoff);
		return EXIT_SUCCESS;
	}

	if ((unsigned)(key - ARG_setageing) < 4) { /* time related ops */
		/* setageing BR N: "N*100\n" to /sys/class/net/BR/bridge/ageing_time
		 * setfd BR N:     "N*100\n" to /sys/class/net/BR/bridge/forward_delay
		 * sethello BR N:  "N*100\n" to /sys/class/net/BR/bridge/hello_time
		 * setmaxage BR N: "N*100\n" to /sys/class/net/BR/bridge/max_age
		 */
		write_uint(br,
			nth_string(
				"bridge/ageing_time"  "\0" /* ARG_setageing */
				"bridge/forward_delay""\0" /* ARG_setfd     */
				"bridge/hello_time"   "\0" /* ARG_sethello  */
				"bridge/max_age",          /* ARG_setmaxage */
				key - ARG_setageing
			),
			str_to_jiffies(*argv)
		);
		return EXIT_SUCCESS;
	}

	if (key == ARG_setbridgeprio) {
		write_uint(br, "bridge/priority", xatoi_positive(*argv));
		return EXIT_SUCCESS;
	}

	if (key == ARG_setpathcost
	 || key == ARG_setportprio
	) {
		if (!argv[1])
			bb_show_usage();
		/* BR is not used (and ignored!) for these commands:
		 * "setpathcost BR PORT N" writes "N\n" to
		 * /sys/class/net/PORT/brport/path_cost
		 * "setportprio BR PORT N" writes "N\n" to
		 * /sys/class/net/PORT/brport/priority
		 */
		write_uint(argv[0],
			nth_string(
				"brport/path_cost" "\0" /* ARG_setpathcost */
				"brport/priority",      /* ARG_setportprio */
				key - ARG_setpathcost
			),
			xatoi_positive(argv[1])
		);
		return EXIT_SUCCESS;
	}
#endif
	/* always true: if (key == ARG_addif || key == ARG_delif) */ {
		struct ifreq ifr;
		int fd = xsocket(AF_INET, SOCK_STREAM, 0);

		strncpy_IFNAMSIZ(ifr.ifr_name, br);
		ifr.ifr_ifindex = if_nametoindex(*argv);
		if (ifr.ifr_ifindex == 0) {
			bb_perror_msg_and_die("iface %s", *argv);
		}
		ioctl_or_perror_and_die(fd,
			key == ARG_addif ? SIOCBRADDIF : SIOCBRDELIF,
			&ifr, "bridge %s", br
		);
		if (ENABLE_FEATURE_CLEAN_UP)
			close(fd);
	}

	return EXIT_SUCCESS;
}
