/* File: main.c * ------------ * 802.1X 转发器 */ #include #include #include /* 子函数声明 */ int Authentication(const char *DeviceName_1, const char *DeviceName_2); /** * 函数:main() * * 检查程序的执行权限,检查命令行参数格式。 * 允许的调用格式包括: * njit-client username password * njit-client username password eth0 * njit-client username password eth1 * 若没有从命令行指定网卡,则默认将使用eth0 */ int main(int argc, char *argv[]) { char *DeviceName_1; char *DeviceName_2; /* 检查当前是否具有root权限 */ if (getuid() != 0) { fprintf(stderr, "抱歉,运行本客户端程序需要root权限\n"); fprintf(stderr, "(RedHat/Fedora下使用su命令切换为root)\n"); fprintf(stderr, "(Ubuntu/Debian下在命令前添加sudo)\n"); exit(-1); } /* 检查命令行参数格式 */ if (argc<2 || argc>3) { fprintf(stderr, "命令行参数错误!\n"); fprintf(stderr, "正确的调用格式例子如下:\n"); fprintf(stderr, " %s eth0[LAN] eth1[WAN]\n", argv[0]); exit(-1); } DeviceName_1 = argv[1]; DeviceName_2 = argv[2]; Authentication(DeviceName_1,DeviceName_2); return (0); }