Import patch iproute2.121

(Logical change 1.124)
parent 73602d66
2005-01-17 Jamal Hadi Salim <hadi@znyx.com>
* typo in m_mirred
* add support for pedit
2005-01-13 Jim Gifford <lfs@jg555.com>
* Fix allocation size error in nomal and paretonormal generation
programs.
2005-01-12 Masahide Nakamura <nakam@linux-ipv6.org>
* ipmonitor shows IPv6 prefix list notification
......
#ifndef __LINUX_TC_PED_H
#define __LINUX_TC_PED_H
#include <linux/pkt_cls.h>
#define TCA_ACT_PEDIT 7
enum
{
TCA_PEDIT_UNSPEC,
TCA_PEDIT_TM,
TCA_PEDIT_PARMS,
__TCA_PEDIT_MAX
};
#define TCA_PEDIT_MAX (__TCA_PEDIT_MAX - 1)
struct tc_pedit_key
{
__u32 mask; /* AND */
__u32 val; /*XOR */
__u32 off; /*offset */
__u32 at;
__u32 offmask;
__u32 shift;
};
struct tc_pedit_sel
{
tc_gen;
unsigned char nkeys;
unsigned char flags;
struct tc_pedit_key keys[0];
};
#define tc_pedit tc_pedit_sel
#endif
......@@ -23,6 +23,12 @@ TCMODULES += q_htb.o
TCMODULES += m_gact.o
TCMODULES += m_mirred.o
TCMODULES += m_ipt.o
TCMODULES += m_pedit.o
TCMODULES += p_ip.o
TCMODULES += p_icmp.o
TCMODULES += p_tcp.o
TCMODULES += p_udp.o
TCOBJ += $(TCMODULES)
......@@ -78,4 +84,3 @@ clean:
q_atm.so: q_atm.c
$(CC) $(CFLAGS) -shared -fpic -o q_atm.so q_atm.c -latm
......@@ -303,7 +303,7 @@ print_mirred(struct action_util *au,FILE * f, struct rtattr *arg)
return 0;
}
struct action_util mirred_util = {
struct action_util mirred_util_util = {
.id = "mirred",
.parse_aopt = parse_mirred,
.print_aopt = print_mirred,
......
This diff is collapsed.
/*
* m_pedit.h generic packet editor actions module
*
* This program is free software; you can distribute 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.
*
* Authors: J Hadi Salim (hadi@cyberus.ca)
*
*/
#ifndef _ACT_PEDIT_H_
#define _ACT_PEDIT_H_ 1
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <syslog.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include "utils.h"
#include "tc_util.h"
#include <linux/tc_act/tc_pedit.h>
#define MAX_OFFS 128
#define TIPV4 1
#define TIPV6 2
#define TINT 3
#define TU32 4
#define RU32 0xFFFFFFFF
#define RU16 0xFFFF
#define RU8 0xFF
struct m_pedit_util
{
struct m_pedit_util *next;
char id[16];
int (*parse_peopt)(int *argc_p, char ***argv_p,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey);
};
extern int parse_cmd(int *argc_p, char ***argv_p, __u32 len, int type,__u32 retain,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey);
extern int pack_key(struct tc_pedit_sel *sel,struct tc_pedit_key *tkey);
extern int pack_key32(__u32 retain,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey);
extern int pack_key16(__u32 retain,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey);
extern int pack_key8(__u32 retain,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey);
extern int parse_val(int *argc_p, char ***argv_p, __u32 * val, int type);
extern int parse_cmd(int *argc_p, char ***argv_p, __u32 len, int type,__u32 retain,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey);
extern int parse_offset(int *argc_p, char ***argv_p,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey);
int parse_pedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n);
extern int print_pedit(struct action_util *au,FILE * f, struct rtattr *arg);
extern int pedit_print_xstats(struct action_util *au, FILE *f, struct rtattr *xstats);
#endif
/*
* m_pedit_icmp.c packet editor: ICMP header
*
* This program is free software; you can distribute 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.
*
* Authors: J Hadi Salim (hadi@cyberus.ca)
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <syslog.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include "utils.h"
#include "tc_util.h"
#include "m_pedit.h"
static int
parse_icmp(int *argc_p, char ***argv_p,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey)
{
int res = -1;
#if 0
int argc = *argc_p;
char **argv = *argv_p;
if (argc < 2)
return -1;
if (strcmp(*argv, "type") == 0) {
NEXT_ARG();
res = parse_u8(&argc, &argv, 0);
goto done;
}
if (strcmp(*argv, "code") == 0) {
NEXT_ARG();
res = parse_u8(&argc, &argv, 1);
goto done;
}
return -1;
done:
*argc_p = argc;
*argv_p = argv;
#endif
return res;
}
struct m_pedit_util p_pedit_icmp = {
NULL,
"icmp",
parse_icmp,
};
/*
* m_pedit.c packet editor: IPV4/6 header
*
* This program is free software; you can distribute 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.
*
* Authors: J Hadi Salim (hadi@cyberus.ca)
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <syslog.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include "utils.h"
#include "tc_util.h"
#include "m_pedit.h"
static int
parse_ip(int *argc_p, char ***argv_p,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey)
{
int res = -1;
int argc = *argc_p;
char **argv = *argv_p;
if (argc < 2)
return -1;
if (strcmp(*argv, "src") == 0) {
NEXT_ARG();
tkey->off = 12;
res = parse_cmd(&argc, &argv, 4, TIPV4,RU32,sel,tkey);
goto done;
}
if (strcmp(*argv, "dst") == 0) {
NEXT_ARG();
tkey->off = 16;
res = parse_cmd(&argc, &argv, 4, TIPV4,RU32,sel,tkey);
goto done;
}
/* jamal - look at these and make them either old or new
** scheme given diffserv
** dont forget the CE bit
*/
if (strcmp(*argv, "tos") == 0 || matches(*argv, "dsfield") == 0) {
NEXT_ARG();
tkey->off = 1;
res = parse_cmd(&argc, &argv, 1, TU32,RU8,sel,tkey);
goto done;
}
if (strcmp(*argv, "ihl") == 0) {
NEXT_ARG();
tkey->off = 0;
res = parse_cmd(&argc, &argv, 1, TU32,RU8,sel,tkey);
goto done;
}
if (strcmp(*argv, "protocol") == 0) {
NEXT_ARG();
tkey->off = 9;
res = parse_cmd(&argc, &argv, 1, TU32,RU8,sel,tkey);
goto done;
}
/* jamal - fix this */
if (matches(*argv, "precedence") == 0) {
NEXT_ARG();
tkey->off = 1;
res = parse_cmd(&argc, &argv, 1, TU32,RU8,sel,tkey);
goto done;
}
/* jamal - validate this at some point */
if (strcmp(*argv, "nofrag") == 0) {
NEXT_ARG();
tkey->off = 6;
res = parse_cmd(&argc, &argv, 1, TU32,0x3F,sel,tkey);
goto done;
}
/* jamal - validate this at some point */
if (strcmp(*argv, "firstfrag") == 0) {
NEXT_ARG();
tkey->off = 6;
res = parse_cmd(&argc, &argv, 1, TU32,0x1F,sel,tkey);
goto done;
}
if (strcmp(*argv, "ce") == 0) {
NEXT_ARG();
tkey->off = 6;
res = parse_cmd(&argc, &argv, 1, TU32,0x80,sel,tkey);
goto done;
}
if (strcmp(*argv, "df") == 0) {
NEXT_ARG();
tkey->off = 6;
res = parse_cmd(&argc, &argv, 1, TU32,0x40,sel,tkey);
goto done;
}
if (strcmp(*argv, "mf") == 0) {
NEXT_ARG();
tkey->off = 6;
res = parse_cmd(&argc, &argv, 1, TU32,0x20,sel,tkey);
goto done;
}
if (strcmp(*argv, "dport") == 0) {
NEXT_ARG();
tkey->off = 22;
res = parse_cmd(&argc, &argv, 2, TU32,RU16,sel,tkey);
goto done;
}
if (strcmp(*argv, "sport") == 0) {
NEXT_ARG();
tkey->off = 20;
res = parse_cmd(&argc, &argv, 2, TU32,RU16,sel,tkey);
goto done;
}
if (strcmp(*argv, "icmp_type") == 0) {
NEXT_ARG();
tkey->off = 20;
res = parse_cmd(&argc, &argv, 1, TU32,RU8,sel,tkey);
goto done;
}
if (strcmp(*argv, "icmp_code") == 0) {
NEXT_ARG();
tkey->off = 20;
res = parse_cmd(&argc, &argv, 1, TU32,RU8,sel,tkey);
goto done;
}
return -1;
done:
*argc_p = argc;
*argv_p = argv;
return res;
}
static int
parse_ip6(int *argc_p, char ***argv_p,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey)
{
int res = -1;
return res;
}
struct m_pedit_util p_pedit_ip = {
NULL,
"ip",
parse_ip,
};
struct m_pedit_util p_pedit_ip6 = {
NULL,
"ip6",
parse_ip6,
};
/*
* m_pedit_tcp.c packet editor: TCP header
*
* This program is free software; you can distribute 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.
*
* Authors: J Hadi Salim (hadi@cyberus.ca)
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <syslog.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include "utils.h"
#include "tc_util.h"
#include "m_pedit.h"
static int
parse_tcp(int *argc_p, char ***argv_p,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey)
{
int res = -1;
return res;
}
struct m_pedit_util p_pedit_tcp = {
NULL,
"tcp",
parse_tcp,
};
/*
* m_pedit_udp.c packet editor: UDP header
*
* This program is free software; you can distribute 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.
*
* Authors: J Hadi Salim (hadi@cyberus.ca)
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <syslog.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include "utils.h"
#include "tc_util.h"
#include "m_pedit.h"
static int
parse_udp(int *argc_p, char ***argv_p,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey)
{
int res = -1;
return res;
}
struct m_pedit_util p_pedit_udp = {
NULL,
"udp",
parse_udp,
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment