Dr Andrew Scott G7VAV

My photo
 
June 2025
Mo Tu We Th Fr Sa Su
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 1 2 3 4 5 6


ip_set.h
001: #ifndef _IP_SET_H
002: #define _IP_SET_H
003: 
004: /* Copyright (C) 2000-2002 Joakim Axelsson <gozem@linux.nu>
005:  *                         Patrick Schaaf <bof@bof.de>
006:  *                         Martin Josefsson <gandalf@wlug.westbo.se>
007:  * Copyright (C) 2003-2011 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
008:  *
009:  * This program is free software; you can redistribute it and/or modify
010:  * it under the terms of the GNU General Public License version 2 as
011:  * published by the Free Software Foundation.
012:  */
013: 
014: /* The protocol version */
015: #define IPSET_PROTOCOL          6
016: 
017: /* The max length of strings including NUL: set and type identifiers */
018: #define IPSET_MAXNAMELEN        32
019: 
020: /* Message types and commands */
021: enum ipset_cmd {
022:         IPSET_CMD_NONE,
023:         IPSET_CMD_PROTOCOL,     /* 1: Return protocol version */
024:         IPSET_CMD_CREATE,       /* 2: Create a new (empty) set */
025:         IPSET_CMD_DESTROY,      /* 3: Destroy a (empty) set */
026:         IPSET_CMD_FLUSH,        /* 4: Remove all elements from a set */
027:         IPSET_CMD_RENAME,       /* 5: Rename a set */
028:         IPSET_CMD_SWAP,         /* 6: Swap two sets */
029:         IPSET_CMD_LIST,         /* 7: List sets */
030:         IPSET_CMD_SAVE,         /* 8: Save sets */
031:         IPSET_CMD_ADD,          /* 9: Add an element to a set */
032:         IPSET_CMD_DEL,          /* 10: Delete an element from a set */
033:         IPSET_CMD_TEST,         /* 11: Test an element in a set */
034:         IPSET_CMD_HEADER,       /* 12: Get set header data only */
035:         IPSET_CMD_TYPE,         /* 13: Get set type */
036:         IPSET_MSG_MAX,          /* Netlink message commands */
037: 
038:         /* Commands in userspace: */
039:         IPSET_CMD_RESTORE = IPSET_MSG_MAX, /* 14: Enter restore mode */
040:         IPSET_CMD_HELP,         /* 15: Get help */
041:         IPSET_CMD_VERSION,      /* 16: Get program version */
042:         IPSET_CMD_QUIT,         /* 17: Quit from interactive mode */
043: 
044:         IPSET_CMD_MAX,
045: 
046:         IPSET_CMD_COMMIT = IPSET_CMD_MAX, /* 18: Commit buffered commands */
047: };
048: 
049: /* Attributes at command level */
050: enum {
051:         IPSET_ATTR_UNSPEC,
052:         IPSET_ATTR_PROTOCOL,    /* 1: Protocol version */
053:         IPSET_ATTR_SETNAME,     /* 2: Name of the set */
054:         IPSET_ATTR_TYPENAME,    /* 3: Typename */
055:         IPSET_ATTR_SETNAME2 = IPSET_ATTR_TYPENAME, /* Setname at rename/swap */
056:         IPSET_ATTR_REVISION,    /* 4: Settype revision */
057:         IPSET_ATTR_FAMILY,      /* 5: Settype family */
058:         IPSET_ATTR_FLAGS,       /* 6: Flags at command level */
059:         IPSET_ATTR_DATA,        /* 7: Nested attributes */
060:         IPSET_ATTR_ADT,         /* 8: Multiple data containers */
061:         IPSET_ATTR_LINENO,      /* 9: Restore lineno */
062:         IPSET_ATTR_PROTOCOL_MIN, /* 10: Minimal supported version number */
063:         IPSET_ATTR_REVISION_MIN = IPSET_ATTR_PROTOCOL_MIN, /* type rev min */
064:         __IPSET_ATTR_CMD_MAX,
065: };
066: #define IPSET_ATTR_CMD_MAX      (__IPSET_ATTR_CMD_MAX - 1)
067: 
068: /* CADT specific attributes */
069: enum {
070:         IPSET_ATTR_IP = IPSET_ATTR_UNSPEC + 1,
071:         IPSET_ATTR_IP_FROM = IPSET_ATTR_IP,
072:         IPSET_ATTR_IP_TO,       /* 2 */
073:         IPSET_ATTR_CIDR,        /* 3 */
074:         IPSET_ATTR_PORT,        /* 4 */
075:         IPSET_ATTR_PORT_FROM = IPSET_ATTR_PORT,
076:         IPSET_ATTR_PORT_TO,     /* 5 */
077:         IPSET_ATTR_TIMEOUT,     /* 6 */
078:         IPSET_ATTR_PROTO,       /* 7 */
079:         IPSET_ATTR_CADT_FLAGS,  /* 8 */
080:         IPSET_ATTR_CADT_LINENO = IPSET_ATTR_LINENO,     /* 9 */
081:         /* Reserve empty slots */
082:         IPSET_ATTR_CADT_MAX = 16,
083:         /* Create-only specific attributes */
084:         IPSET_ATTR_GC,
085:         IPSET_ATTR_HASHSIZE,
086:         IPSET_ATTR_MAXELEM,
087:         IPSET_ATTR_NETMASK,
088:         IPSET_ATTR_PROBES,
089:         IPSET_ATTR_RESIZE,
090:         IPSET_ATTR_SIZE,
091:         /* Kernel-only */
092:         IPSET_ATTR_ELEMENTS,
093:         IPSET_ATTR_REFERENCES,
094:         IPSET_ATTR_MEMSIZE,
095: 
096:         __IPSET_ATTR_CREATE_MAX,
097: };
098: #define IPSET_ATTR_CREATE_MAX   (__IPSET_ATTR_CREATE_MAX - 1)
099: 
100: /* ADT specific attributes */
101: enum {
102:         IPSET_ATTR_ETHER = IPSET_ATTR_CADT_MAX + 1,
103:         IPSET_ATTR_NAME,
104:         IPSET_ATTR_NAMEREF,
105:         IPSET_ATTR_IP2,
106:         IPSET_ATTR_CIDR2,
107:         IPSET_ATTR_IP2_TO,
108:         IPSET_ATTR_IFACE,
109:         __IPSET_ATTR_ADT_MAX,
110: };
111: #define IPSET_ATTR_ADT_MAX      (__IPSET_ATTR_ADT_MAX - 1)
112: 
113: /* IP specific attributes */
114: enum {
115:         IPSET_ATTR_IPADDR_IPV4 = IPSET_ATTR_UNSPEC + 1,
116:         IPSET_ATTR_IPADDR_IPV6,
117:         __IPSET_ATTR_IPADDR_MAX,
118: };
119: #define IPSET_ATTR_IPADDR_MAX   (__IPSET_ATTR_IPADDR_MAX - 1)
120: 
121: /* Error codes */
122: enum ipset_errno {
123:         IPSET_ERR_PRIVATE = 4096,
124:         IPSET_ERR_PROTOCOL,
125:         IPSET_ERR_FIND_TYPE,
126:         IPSET_ERR_MAX_SETS,
127:         IPSET_ERR_BUSY,
128:         IPSET_ERR_EXIST_SETNAME2,
129:         IPSET_ERR_TYPE_MISMATCH,
130:         IPSET_ERR_EXIST,
131:         IPSET_ERR_INVALID_CIDR,
132:         IPSET_ERR_INVALID_NETMASK,
133:         IPSET_ERR_INVALID_FAMILY,
134:         IPSET_ERR_TIMEOUT,
135:         IPSET_ERR_REFERENCED,
136:         IPSET_ERR_IPADDR_IPV4,
137:         IPSET_ERR_IPADDR_IPV6,
138: 
139:         /* Type specific error codes */
140:         IPSET_ERR_TYPE_SPECIFIC = 4352,
141: };
142: 
143: /* Flags at command level */
144: enum ipset_cmd_flags {
145:         IPSET_FLAG_BIT_EXIST    = 0,
146:         IPSET_FLAG_EXIST        = (1 << IPSET_FLAG_BIT_EXIST),
147:         IPSET_FLAG_BIT_LIST_SETNAME = 1,
148:         IPSET_FLAG_LIST_SETNAME = (1 << IPSET_FLAG_BIT_LIST_SETNAME),
149:         IPSET_FLAG_BIT_LIST_HEADER = 2,
150:         IPSET_FLAG_LIST_HEADER  = (1 << IPSET_FLAG_BIT_LIST_HEADER),
151: };
152: 
153: /* Flags at CADT attribute level */
154: enum ipset_cadt_flags {
155:         IPSET_FLAG_BIT_BEFORE   = 0,
156:         IPSET_FLAG_BEFORE       = (1 << IPSET_FLAG_BIT_BEFORE),
157:         IPSET_FLAG_BIT_PHYSDEV  = 1,
158:         IPSET_FLAG_PHYSDEV      = (1 << IPSET_FLAG_BIT_PHYSDEV),
159: };
160: 
161: /* Commands with settype-specific attributes */
162: enum ipset_adt {
163:         IPSET_ADD,
164:         IPSET_DEL,
165:         IPSET_TEST,
166:         IPSET_ADT_MAX,
167:         IPSET_CREATE = IPSET_ADT_MAX,
168:         IPSET_CADT_MAX,
169: };
170: 
171: 
172: #endif /*_IP_SET_H */
173: 


for client (none)
© Andrew Scott 2006 - 2025,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/