Fix includes for kernel 2.2.x complilation.

This commit is contained in:
agibert 2001-11-20 01:05:16 +00:00
parent 5aa455be3f
commit 4828d6cb6d

View File

@ -11,10 +11,18 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <linux/sockios.h> #include <linux/sockios.h>
#include <linux/if.h> #include <linux/if.h>
#include "/usr/src/linux/drivers/net/eql.h" #include "/usr/src/linux/include/linux/if_eql.h"
void check_running(char *device_name); void check_running(char *device_name);
@ -23,86 +31,87 @@ int s;
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
struct ifreq ifr; struct ifreq ifr;
slaving_request_t slaving_request; slaving_request_t slaving_request;
char master_name[16]; char master_name[16];
int slave_mtu; int slave_mtu;
int master_mtu; int master_mtu;
if (argc != 4) if (argc != 4)
{ {
fprintf (stderr, "usage: %s <master> <slave> <priority>\n", argv[0]); fprintf (stderr, "usage: %s <master> <slave> <priority>\n", argv[0]);
exit (1); exit (1);
} }
strcpy (master_name, argv[1]); strcpy (master_name, argv[1]);
strcpy (slaving_request.slave_name, argv[2]); strcpy (slaving_request.slave_name, argv[2]);
slaving_request.priority = atol (argv[3]); slaving_request.priority = atol (argv[3]);
s = socket (AF_INET, SOCK_DGRAM, 0); s = socket (AF_INET, SOCK_DGRAM, 0);
if ( s == -1) if ( s == -1)
{ {
perror ("socket"); perror ("socket");
exit (1); exit (1);
} }
check_running (master_name); check_running (master_name);
check_running (slaving_request.slave_name); check_running (slaving_request.slave_name);
strcpy (ifr.ifr_name, slaving_request.slave_name); strcpy (ifr.ifr_name, slaving_request.slave_name);
if (ioctl (s, SIOCGIFMTU, &ifr) == -1) if (ioctl (s, SIOCGIFMTU, &ifr) == -1)
{ {
perror("get MTU on slave failed"); perror("get MTU on slave failed");
exit (1); exit (1);
} }
slave_mtu = ifr.ifr_mtu; slave_mtu = ifr.ifr_mtu;
strcpy (ifr.ifr_name, master_name); strcpy (ifr.ifr_name, master_name);
if (ioctl (s, SIOCGIFMTU, &ifr) == -1) if (ioctl (s, SIOCGIFMTU, &ifr) == -1)
{ {
perror("get MTU on master failed"); perror("get MTU on master failed");
exit (1); exit (1);
} }
master_mtu = ifr.ifr_mtu; master_mtu = ifr.ifr_mtu;
if ( master_mtu != slave_mtu ) if ( master_mtu != slave_mtu )
{ {
fprintf (stderr, fprintf (stderr,
"master (%d) and slave (%d) MTU settings do not match\n", "master (%d) and slave (%d) MTU settings do not match\n",
master_mtu, slave_mtu); master_mtu, slave_mtu);
exit (1); exit (1);
} }
strcpy (ifr.ifr_name, master_name); strcpy (ifr.ifr_name, master_name);
ifr.ifr_data = (caddr_t) &slaving_request; ifr.ifr_data = (caddr_t) &slaving_request;
if(ioctl (s,EQL_ENSLAVE, &ifr)==-1) if(ioctl (s,EQL_ENSLAVE, &ifr)==-1)
{ {
perror("EQL_ENSLAVE failed"); perror("EQL_ENSLAVE failed");
exit (1); exit (1);
} }
return 0; return 0;
} }
void void
check_running(char *name) check_running(char *name)
{ {
struct ifreq ifr; struct ifreq ifr;
strcpy (ifr.ifr_name, name); strcpy (ifr.ifr_name, name);
if ( ioctl (s, SIOCGIFFLAGS, &ifr) == -1) if ( ioctl (s, SIOCGIFFLAGS, &ifr) == -1)
{ {
perror (name); perror (name);
exit (1); exit (1);
} }
if (ifr.ifr_flags & (IFF_RUNNING | IFF_UP) != (IFF_RUNNING | IFF_UP)) if (ifr.ifr_flags & (IFF_RUNNING | IFF_UP) != (IFF_RUNNING | IFF_UP))
{ {
fprintf (stderr, "Device '%s' is not up or running.\n", name); fprintf (stderr, "Device '%s' is not up or running.\n", name);
exit (1); exit (1);
} }
} }
/* /*
* Local Variables: * Local Variables:
* compile-command: "gcc -Wall -Wstrict-prototypes -o eql_enslave eql_enslave.c" * compile-command: "gcc -Wall -Wstrict-prototypes -o eql_enslave eql_enslave.c"