Initial release !
This commit is contained in:
parent
c93cebc583
commit
5aa455be3f
146
eql_cfg.c
Normal file
146
eql_cfg.c
Normal file
@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <linux/sockios.h>
|
||||
#include <linux/if.h>
|
||||
|
||||
#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 <master> [<max slaves> <min slaves>]\n %s <master> <slave> [<priority>]\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:
|
||||
*/
|
97
eql_emancipate.c
Normal file
97
eql_emancipate.c
Normal file
@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <linux/sockios.h>
|
||||
#include <linux/if.h>
|
||||
|
||||
#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 <master> <slave>\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:
|
||||
*/
|
Loading…
Reference in New Issue
Block a user