/* * 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: */