From c93cebc58393568d98ae2304ffce8b990155970d Mon Sep 17 00:00:00 2001 From: agibert Date: Tue, 20 Nov 2001 00:35:03 +0000 Subject: [PATCH] Initial revision --- eql_enslave.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 eql_enslave.c diff --git a/eql_enslave.c b/eql_enslave.c new file mode 100644 index 0000000..6eeace8 --- /dev/null +++ b/eql_enslave.c @@ -0,0 +1,110 @@ +/* + * eql_enslave + * + * modeled from ifslave.c by Alan Cox (presumably?) + * + * (c) Copyright 1995 Simon Janes + * NCM: Network and Communications Management, Inc. + */ + +#include +#include +#include +#include +#include +#include + +#include "/usr/src/linux/drivers/net/eql.h" + +void check_running(char *device_name); + +int s; + +int +main(int argc, char **argv) +{ + struct ifreq ifr; + slaving_request_t slaving_request; + char master_name[16]; + int slave_mtu; + int master_mtu; + + if (argc != 4) + { + fprintf (stderr, "usage: %s \n", argv[0]); + exit (1); + } + + strcpy (master_name, argv[1]); + strcpy (slaving_request.slave_name, argv[2]); + slaving_request.priority = atol (argv[3]); + + s = socket (AF_INET, SOCK_DGRAM, 0); + if ( s == -1) + { + perror ("socket"); + exit (1); + } + + check_running (master_name); + check_running (slaving_request.slave_name); + + strcpy (ifr.ifr_name, slaving_request.slave_name); + if (ioctl (s, SIOCGIFMTU, &ifr) == -1) + { + perror("get MTU on slave failed"); + exit (1); + } + slave_mtu = ifr.ifr_mtu; + + strcpy (ifr.ifr_name, master_name); + if (ioctl (s, SIOCGIFMTU, &ifr) == -1) + { + perror("get MTU on master failed"); + exit (1); + } + master_mtu = ifr.ifr_mtu; + + if ( master_mtu != slave_mtu ) + { + fprintf (stderr, + "master (%d) and slave (%d) MTU settings do not match\n", + master_mtu, slave_mtu); + exit (1); + } + + strcpy (ifr.ifr_name, master_name); + ifr.ifr_data = (caddr_t) &slaving_request; + + if(ioctl (s,EQL_ENSLAVE, &ifr)==-1) + { + perror("EQL_ENSLAVE failed"); + exit (1); + } + + return 0; +} + +void +check_running(char *name) +{ + struct ifreq ifr; + + strcpy (ifr.ifr_name, name); + if ( ioctl (s, SIOCGIFFLAGS, &ifr) == -1) + { + perror (name); + exit (1); + } + if (ifr.ifr_flags & (IFF_RUNNING | IFF_UP) != (IFF_RUNNING | IFF_UP)) + { + fprintf (stderr, "Device '%s' is not up or running.\n", name); + exit (1); + } +} + +/* + * Local Variables: + * compile-command: "gcc -Wall -Wstrict-prototypes -o eql_enslave eql_enslave.c" + * End: + */