X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tc%2Fm_pedit.c;h=7499846310ac33366e82ad353c4ffe4582f3e283;hb=7132284647c15ca30d942926bc506d6019d3b61c;hp=acfa581980712af0d112ebb62ea1b8db4203d39d;hpb=105da95218c9d30375efc43f9edd8ef32998fedb;p=iproute2.git diff --git a/tc/m_pedit.c b/tc/m_pedit.c index acfa581..7499846 100644 --- a/tc/m_pedit.c +++ b/tc/m_pedit.c @@ -1,18 +1,18 @@ /* - * m_pedit.c generic packet editor actions module + * m_pedit.c 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) - * - * TODO: + * Authors: J Hadi Salim (hadi@cyberus.ca) + * + * TODO: * 1) Big endian broken in some spots * 2) A lot of this stuff was added on the fly; get a big double-double * and clean it up at some point. - * + * */ #include @@ -33,28 +33,33 @@ static struct m_pedit_util *pedit_list; int pedit_debug = 1; static void -p_explain(void) +explain(void) { - fprintf(stderr, "Usage: ... pedit \n"); + fprintf(stderr, "Usage: ... pedit munge \n"); fprintf(stderr, - "Where: MUNGE := |\n" - ":= [ATC]\n " - "OFFSETC:= offset \n " - "ATC:= at offmask shift \n " - "NOTE: offval is byte offset, must be multiple of 4\n " - "NOTE: maskval is a 32 bit hex number\n " - "NOTE: shiftval is a is a shift value\n " - "CMD:= clear | invert | set | retain\n " - ":= ip | ip6 \n " - " | udp | tcp | icmp \n" - "For Example usage look at the examples directory"); + "Where: MUNGE := |\n" + "\t:= [ATC]\n " + "\t\tOFFSETC:= offset \n " + "\t\tATC:= at offmask shift \n " + "\t\tNOTE: offval is byte offset, must be multiple of 4\n " + "\t\tNOTE: maskval is a 32 bit hex number\n " + "\t\tNOTE: shiftval is a is a shift value\n " + "\t\tCMD:= clear | invert | set | retain\n " + "\t:= ip | ip6 \n " + " \t\t| udp | tcp | icmp \n" + "For Example usage look at the examples directory\n"); } -#define usage() return(-1) +static void +usage(void) +{ + explain(); + exit(-1); +} -static int -pedit_parse_nopopt (int *argc_p, char ***argv_p,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey) +static int +pedit_parse_nopopt (int *argc_p, char ***argv_p,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey) { int argc = *argc_p; char **argv = *argv_p; @@ -68,7 +73,7 @@ pedit_parse_nopopt (int *argc_p, char ***argv_p,struct tc_pedit_sel *sel,struct } -struct m_pedit_util +struct m_pedit_util *get_pedit_kind(char *str) { static void *pBODY; @@ -222,7 +227,7 @@ pack_key8(__u32 retain,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey) retain <<= stride; tkey->mask = retain|m[ind]; tkey->off &= ~3; - + if (pedit_debug) printf("pack_key8: Final word off %d val %08x mask %08x \n",tkey->off , tkey->val,tkey->mask); return pack_key(sel,tkey); @@ -288,7 +293,7 @@ parse_cmd(int *argc_p, char ***argv_p, __u32 len, int type,__u32 retain,struct t } else if (matches(*argv, "preserve") == 0) { retain = mask = o; } else { - if (matches(*argv, "clear") != 0) + if (matches(*argv, "clear") != 0) return -1; } @@ -385,7 +390,7 @@ done: tkey->at = atv; NEXT_ARG(); - + if (get_u32(&offmask, *argv, 16)) return -1; tkey->offmask = offmask; @@ -423,11 +428,6 @@ parse_munge(int *argc_p, char ***argv_p,struct tc_pedit_sel *sel) NEXT_ARG(); res = parse_offset(&argc, &argv,sel,&tkey); goto done; -#if jamal - } else if (strcmp(*argv, "help") == 0) { - p_explain(); - return -1; -#endif } else { char k[16]; struct m_pedit_util *p = NULL; @@ -479,16 +479,18 @@ parse_pedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, stru NEXT_ARG(); ok++; continue; + } else if (matches(*argv, "help") == 0) { + usage(); } else if (matches(*argv, "munge") == 0) { if (!ok) { fprintf(stderr, "Illegal pedit construct (%s) \n", *argv); - p_explain(); + explain(); return -1; } NEXT_ARG(); if (parse_munge(&argc, &argv,&sel.sel)) { fprintf(stderr, "Illegal pedit construct (%s) \n", *argv); - p_explain(); + explain(); return -1; } ok++; @@ -499,7 +501,7 @@ parse_pedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, stru } if (!ok) { - p_explain(); + explain(); return -1; } @@ -593,7 +595,7 @@ print_pedit(struct action_util *au,FILE * f, struct rtattr *arg) return 0; } -int +int pedit_print_xstats(struct action_util *au, FILE *f, struct rtattr *xstats) { return 0;