/*
* ipvsadm - IP Virtual Server ADMinistration program
* for IPVS NetFilter Module in kernel 2.4
*
* Version: $Id: ipvsadm.c,v 1.27 2005/12/10 16:00:07 wensong Exp $
*
* Authors: Wensong Zhang <wensong@linuxvirtualserver.org>
* Peter Kese <peter.kese@ijs.si>
*
* This program is based on ippfvsadm.
*
* Changes:
* Wensong Zhang : added the editting service & destination support
* Wensong Zhang : added the feature to specify persistent port
* Jacob Rief : found the bug that masquerading dest of
* different vport and dport cannot be deleted.
* Wensong Zhang : fixed it and changed some cosmetic things
* Wensong Zhang : added the timeout setting for persistent service
* Wensong Zhang : added specifying the dest weight zero
* Wensong Zhang : fixed the -E and -e options
* Wensong Zhang : added the long options
* Wensong Zhang : added the hostname and portname input
* Wensong Zhang : added the hostname and portname output
* Lars Marowsky-Br�e : added persistence granularity support
* Julian Anastasov : fixed the (null) print for unknown services
* Wensong Zhang : added the port_to_anyname function
* Horms : added option to read commands from stdin
* Horms : modified usage function so it prints to
* : stdout if an exit value of 0 is used and
* : stdout otherwise. Program is then terminated
* : with the supplied exit value.
* Horms : updated manpage and usage funtion so
* : the reflect the options available
* Wensong Zhang : added option to write rules to stdout
* Horms : added ability to specify a fwmark
* : instead of a server and port for
* : a virtual service
* Horms : tightened up checking of services
* : in parse_service
* Horms : ensure that a -r is passed when needed
* Wensong Zhang : fixed the output of fwmark rules
* Horms : added kernel version verification
* Horms : Specifying command and option options
* (e.g. -Ln or -At) in one short option
* with popt problem fixed.
* Wensong Zhang : split the process_options and make
* two versions of parse_options.
* Horms : attempting to save or restore when
* compiled against getopt_long now results
* in an informative error message rather
* than the usage information
* Horms : added -v option
* Wensong Zhang : rewrite most code of parsing options and
* processing options.
* Alexandre Cassen : added ipvs_syncd SyncdID support to filter
* incoming sync messages.
* Guy Waugh & Ratz : added --exact option and spelling cleanup
*
*
* ippfvsadm - Port Fowarding & Virtual Server ADMinistration program
*
* Copyright (c) 1998 Wensong Zhang
* All rights reserved.
*
* Author: Wensong Zhang <wensong@iinchina.net>
*
* This ippfvsadm is derived from Steven Clarke's ipportfw program.
*
* portfw - Port Forwarding Table Editing v1.1
*
* Copyright (c) 1997 Steven Clarke
* All rights reserved.
*
* Author: Steven Clarke <steven@monmouth.demon.co.uk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#undef __KERNEL__ /* Makefile lazyness ;) */
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <netdb.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
#include <stdarg.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/wait.h> /* For waitpid */
#include <arpa/inet.h>
#include <net/if.h>
#include <netinet/ip_icmp.h>
#include <netinet/udp.h>
#include <netinet/tcp.h>
#ifdef HAVE_POPT
#include "popt.h"
#define IPVS_OPTION_PROCESSING "popt"
#else
#define IPVS_OPTION_PROCESSING "getopt_long"
#endif
#include "config_stream.h"
#include "libipvs/libipvs.h"
#define IPVSADM_VERSION_NO "v" VERSION
#define IPVSADM_VERSION_DATE "2005/12/10"
#define IPVSADM_VERSION IPVSADM_VERSION_NO " " IPVSADM_VERSION_DATE
#define MAX_TIMEOUT (86400*31) /* 31 days */
#define CMD_NONE 0
#define CMD_ADD (CMD_NONE+1)
#define CMD_EDIT (CMD_NONE+2)
#define CMD_DEL (CMD_NONE+3)
#define CMD_FLUSH (CMD_NONE+4)
#define CMD_LIST (CMD_NONE+5)
#define CMD_ADDDEST (CMD_NONE+6)
#define CMD_DELDEST (CMD_NONE+7)
#define CMD_EDITDEST (CMD_NONE+8)
#define CMD_TIMEOUT (CMD_NONE+9)
#define CMD_STARTDAEMON (CMD_NONE+10)
#define CMD_STOPDAEMON (CMD_NONE+11)
#define CMD_RESTORE (CMD_NONE+12)
#define CMD_SAVE (CMD_NONE+13)
#define CMD_ZERO (CMD_NONE+14)
#define CMD_MAX CMD_ZERO
#define NUMBER_OF_CMD (CMD_MAX - CMD_NONE)
static const char* cmdnames[] = {
"add-service",
"edit-service",
"delete-service",
"flush",
"list",
"add-server",
"delete-server",
"edit-server",
"set",
"start-daemon",
"stop-daemon",
"restore",
"save",
"zero",
};
#define OPT_NONE 0x000000
#define OPT_NUMERIC 0x000001
#define OPT_CONNECTION 0x000002
#define OPT_SERVICE 0x000004
#define OPT_SCHEDULER 0x000008
#define OPT_PERSISTENT 0x000010
#define OPT_NETMASK 0x000020
#define OPT_SERVER 0x000040
#define OPT_FORWARD 0x000080
#define OPT_WEIGHT 0x000100
#define OPT_UTHRESHOLD 0x000200
#define OPT_LTHRESHOLD 0x000400
#define OPT_MCAST 0x000800
#define OPT_TIMEOUT 0x001000
#define OPT_DAEMON 0x002000
#define OPT_STATS 0x004000
#define OPT_RATE 0x008000
#define OPT_THRESHOLDS 0x010000
#define OPT_PERSISTENTCONN 0x020000
#define OPT_SORT 0x040000
#define OPT_SYNCID 0x080000
#define OPT_EXACT 0x100000
#define NUMBER_OF_OPT 21
static const char* optnames[] = {
"numeric",
"connection",
"service-address",
"scheduler",
"persistent",
"netmask",
"real-server",
"forwarding-method",
"weight",
"u-threshold",
"l-threshold",
"mcast-interface",
"timeout",
"daemon",
"stats",
"rate",
"thresholds",
"persistent-conn",
"sort",
"syncid",
"exact",
};
/*
* Table of legal combinations of commands and options.
* Key:
* '+' compulsory
* 'x' illegal
* '1' exclusive (only one '1' option can be supplied)
* ' ' optional
*/
static const char commands_v_options[NUMBER_OF_CMD][NUMBER_OF_OPT] =
{
/* -n -c svc -s -p -M -r fwd -w -x -y -mc tot dmn -st -rt thr -pc srt sid -ex */
/*ADD*/ {'x', 'x', '+', ' ', ' ', ' ', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'},
/*EDIT*/ {'x', 'x', '+', ' ', ' ', ' ', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x
ipvsadm-1.24.tar.gz
3星 · 超过75%的资源 需积分: 11 57 浏览量
2008-10-09
22:58:23
上传
评论
收藏 36KB GZ 举报
ggram
- 粉丝: 1
- 资源: 7
最新资源
- ### 1、项目介绍 本项目Scrapy进行数据爬取,并使用Django框架+PyEcharts实现可视化大屏 效果如下:
- # 微信小程序-健康菜谱 基于微信小程序的一个查找检索菜谱的应用 ### 效果 !动态图(./res/gif/demo
- zabbix-get命令包资源
- 毕业设计,基于PyQt5实现的可视化界面的Python车牌自动识别系统源码
- 26-朴素贝叶斯分类.rar
- 没有安Matlab 也可以 生成FIR抽头系数工具.py
- python烟花代码.rar
- 实验目的: 1.构建基于verilog语言的组合逻辑电路和时序逻辑电路; 2.掌握verilog语言的电路设计技巧 3.完成如
- 扩展卡尔曼滤波matlab仿真
- 3_base.apk.1
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈