diff --git a/eql_cfg.c b/eql_cfg.c new file mode 100644 index 0000000..2b586fe --- /dev/null +++ b/eql_cfg.c @@ -0,0 +1,146 @@ +/* + * eql_cfg + * + * modeled from eql_enslave.c by Simon Janes + * + * (c) Copyright 2001 Arnaud G. Gibert + * Misys + * + * (c) Copyright 1995 Simon Janes + * NCM: Network and Communications Management, Inc. + */ + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include "/usr/src/linux/include/linux/if_eql.h" + + + + + +void check_running(char *device_name); + +int s; + +int +main(int argc, char **argv) +{ + struct ifreq ifr; + master_config_t master_config; + slave_config_t slave_config; + char master_name[16]; + int slave_mtu; + int master_mtu; + + if ((argc < 2) || (argc > 4)) + { + fprintf (stderr, "usage: %s [ ]\n %s []\n", argv[0],argv[0]); + exit (1); + } + + strcpy (master_name, argv[1]); + + s = socket (AF_INET, SOCK_DGRAM, 0); + if ( s == -1) + { + perror ("socket"); + exit (1); + } + + check_running (master_name); + + strcpy (ifr.ifr_name, master_name); + + switch( argc) + { + case 2: + ifr.ifr_data = (caddr_t) &master_config; + + if(ioctl (s,EQL_GETMASTRCFG, &ifr)==-1) + { + perror("EQL_GETMASTRCFG failed"); + exit (1); + } + + printf( "%s\tmax slaves:%d min slaves:%d\n",master_name,master_config.max_slaves,master_config.min_slaves); + break; + + case 3: + ifr.ifr_data = (caddr_t) &slave_config; + strcpy(slave_config.slave_name, argv[2]); + + if(ioctl (s,EQL_GETSLAVECFG, &ifr)==-1) + { + perror("EQL_GETSLAVECFG failed"); + exit (1); + } + + printf( "%s:%s\tpriority:%d\n",master_name,slave_config.slave_name,slave_config.priority); + break; + + case 4: + if( isdigit(argv[2][0])) + { + ifr.ifr_data = (caddr_t) &master_config; + + master_config.max_slaves = atoi(argv[2]); + master_config.min_slaves = atoi(argv[3]); + + if(ioctl (s,EQL_SETMASTRCFG, &ifr)==-1) + { + perror("EQL_SETMASTRCFG failed"); + exit (1); + } + break; + } + else + { + ifr.ifr_data = (caddr_t) &slave_config; + strcpy(slave_config.slave_name, argv[2]); + slave_config.priority = atoi(argv[3]); + + if(ioctl (s,EQL_SETSLAVECFG, &ifr)==-1) + { + perror("EQL_SETSLAVECFG failed"); + exit (1); + } + break; + } + } + + 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_emancipate eql_emancipate.c" + * End: + */ diff --git a/eql_emancipate.c b/eql_emancipate.c new file mode 100644 index 0000000..0845196 --- /dev/null +++ b/eql_emancipate.c @@ -0,0 +1,97 @@ +/* + * eql_emancipate + * + * modeled from eql_enslave.c by Simon Janes + * + * (c) Copyright 2001 Arnaud G. Gibert + * Misys + * + * (c) Copyright 1995 Simon Janes + * NCM: Network and Communications Management, Inc. + */ + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include "/usr/src/linux/include/linux/if_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 != 3) + { + fprintf (stderr, "usage: %s \n", argv[0]); + exit (1); + } + + strcpy (master_name, argv[1]); + strcpy (slaving_request.slave_name, argv[2]); + + 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, master_name); + ifr.ifr_data = (caddr_t) &slaving_request; + + if(ioctl (s,EQL_EMANCIPATE, &ifr)==-1) + { + perror("EQL_EMANCIPATE 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_emancipate eql_emancipate.c" + * End: + */