Date: Tue, 03 Jul 2018 09:42:27 +0200 From: "Kristof Provost" <kristof@sigsegv.be> To: "Antoine Brodin" <antoine@freebsd.org> Cc: "Will Andrews" <will@freebsd.org>, src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r335833 - in head: share/man/man4 sys/net sys/netpfil/pf Message-ID: <081170FC-D433-4FE6-87E1-D5470480B971@sigsegv.be> In-Reply-To: <CAALwa8nSgZ_nMKSGXaCj8Zbt%2BWZ47UwDQedZPPedVGeGQs7Ycw@mail.gmail.com> References: <201807010116.w611G35w008185@repo.freebsd.org> <CAALwa8nSgZ_nMKSGXaCj8Zbt%2BWZ47UwDQedZPPedVGeGQs7Ycw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 3 Jul 2018, at 7:38, Antoine Brodin wrote: > On Sun, Jul 1, 2018 at 3:16 AM, Will Andrews <will@freebsd.org> wrote: >> Author: will >> Date: Sun Jul 1 01:16:03 2018 >> New Revision: 335833 >> URL: https://svnweb.freebsd.org/changeset/base/335833 >> >> Log: >> pf: remove unused ioctls. >> >> Several ioctls are unused in pf, in the sense that no base utility >> references them. Additionally, a cursory review of pf-based ports >> indicates they're not used elsewhere either. Some of them have >> been >> unused since the original import. As far as I can tell, they're >> also >> unused in OpenBSD. Finally, removing this code removes the need >> for >> future pf work to take them into account. >> >> Reviewed by: kp >> Differential Revision: https://reviews.freebsd.org/D16076 >> >> Modified: >> head/share/man/man4/pf.4 >> head/sys/net/pfvar.h >> head/sys/netpfil/pf/pf_ioctl.c > > Hi, > > This breaks some ports like net/libdnet, please revert or fix the > ports fallout. > It also uses DIOCCHANGERULE (like sshuttle). Do you know of any other failures? It’d be good to know if reverting just the DIOCCHANGERULE removal would be enough to fix all failures, or if there are others that are used as well. Regards, Kristof From owner-svn-src-head@freebsd.org Tue Jul 3 08:44:46 2018 Return-Path: <owner-svn-src-head@freebsd.org> Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2D431102A9B9; Tue, 3 Jul 2018 08:44:46 +0000 (UTC) (envelope-from harti@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C5E06746ED; Tue, 3 Jul 2018 08:44:45 +0000 (UTC) (envelope-from harti@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A6DE519D4C; Tue, 3 Jul 2018 08:44:45 +0000 (UTC) (envelope-from harti@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w638ijZo020334; Tue, 3 Jul 2018 08:44:45 GMT (envelope-from harti@FreeBSD.org) Received: (from harti@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w638ierp020305; Tue, 3 Jul 2018 08:44:40 GMT (envelope-from harti@FreeBSD.org) Message-Id: <201807030844.w638ierp020305@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: harti set sender to harti@FreeBSD.org using -f From: Hartmut Brandt <harti@FreeBSD.org> Date: Tue, 3 Jul 2018 08:44:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335885 - in head: contrib/bsnmp contrib/bsnmp/gensnmptree contrib/bsnmp/lib contrib/bsnmp/snmp_mibII contrib/bsnmp/snmp_ntp contrib/bsnmp/snmp_target contrib/bsnmp/snmp_usm contrib/bsn... X-SVN-Group: head X-SVN-Commit-Author: harti X-SVN-Commit-Paths: in head: contrib/bsnmp contrib/bsnmp/gensnmptree contrib/bsnmp/lib contrib/bsnmp/snmp_mibII contrib/bsnmp/snmp_ntp contrib/bsnmp/snmp_target contrib/bsnmp/snmp_usm contrib/bsnmp/snmp_vacm contrib/bsnm... X-SVN-Commit-Revision: 335885 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current <svn-src-head.freebsd.org> List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-head>, <mailto:svn-src-head-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/svn-src-head/> List-Post: <mailto:svn-src-head@freebsd.org> List-Help: <mailto:svn-src-head-request@freebsd.org?subject=help> List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-head>, <mailto:svn-src-head-request@freebsd.org?subject=subscribe> X-List-Received-Date: Tue, 03 Jul 2018 08:44:46 -0000 Author: harti Date: Tue Jul 3 08:44:40 2018 New Revision: 335885 URL: https://svnweb.freebsd.org/changeset/base/335885 Log: Update bsnmp to version 1.13. This does not bring user-visible changes. For developers gensnmptree can now generate functions for enums to convert between enums and strings and to check the validity of a value. The sources in FreeBSD are now in sync with the upstream which allows to bring in IPv6 modifications. Modified: head/contrib/bsnmp/VERSION head/contrib/bsnmp/gensnmptree/gensnmptree.1 head/contrib/bsnmp/gensnmptree/gensnmptree.c head/contrib/bsnmp/lib/snmp.h head/contrib/bsnmp/lib/tc.def head/contrib/bsnmp/snmp_mibII/mibII.c head/contrib/bsnmp/snmp_mibII/mibII_route.c head/contrib/bsnmp/snmp_ntp/snmp_ntp.c head/contrib/bsnmp/snmp_target/target_snmp.c head/contrib/bsnmp/snmp_target/target_tree.def head/contrib/bsnmp/snmp_usm/usm_snmp.c head/contrib/bsnmp/snmp_usm/usm_tree.def head/contrib/bsnmp/snmp_vacm/vacm_snmp.c head/contrib/bsnmp/snmp_vacm/vacm_tree.def head/contrib/bsnmp/snmpd/main.c head/contrib/bsnmp/snmpd/trans_udp.c head/contrib/bsnmp/snmpd/trap.c head/contrib/bsnmp/snmpd/tree.def head/contrib/libbegemot/rpoll.c head/contrib/libbegemot/rpoll.h head/lib/libbsnmp/libbsnmp/Makefile head/share/mk/bsd.snmpmod.mk head/usr.sbin/bsnmpd/bsnmpd/Makefile head/usr.sbin/bsnmpd/modules/snmp_bridge/Makefile head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_addrs.c head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_if.c head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_pf.c head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_port.c head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_snmp.c head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c head/usr.sbin/bsnmpd/modules/snmp_hast/Makefile head/usr.sbin/bsnmpd/modules/snmp_pf/Makefile head/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c head/usr.sbin/bsnmpd/modules/snmp_target/Makefile head/usr.sbin/bsnmpd/modules/snmp_usm/Makefile head/usr.sbin/bsnmpd/modules/snmp_vacm/Makefile head/usr.sbin/bsnmpd/modules/snmp_wlan/Makefile head/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_snmp.c head/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_sys.c Modified: head/contrib/bsnmp/VERSION ============================================================================== --- head/contrib/bsnmp/VERSION Tue Jul 3 05:56:23 2018 (r335884) +++ head/contrib/bsnmp/VERSION Tue Jul 3 08:44:40 2018 (r335885) @@ -1 +1 @@ -1.12 +1.13 Modified: head/contrib/bsnmp/gensnmptree/gensnmptree.1 ============================================================================== --- head/contrib/bsnmp/gensnmptree/gensnmptree.1 Tue Jul 3 05:56:23 2018 (r335884) +++ head/contrib/bsnmp/gensnmptree/gensnmptree.1 Tue Jul 3 08:44:40 2018 (r335885) @@ -2,7 +2,7 @@ .\" Copyright (c) 2001-2005 .\" Fraunhofer Institute for Open Communication Systems (FhG Fokus). .\" All rights reserved. -.\" Copyright (c) 2006 +.\" Copyright (c) 2006,2018 .\" Hartmut Brandt .\" All rights reserved. .\" @@ -31,7 +31,7 @@ .\" .\" $Begemot: gensnmptree.1 383 2006-05-30 07:40:49Z brandt_h $ .\" -.Dd May 26, 2006 +.Dd June 29, 2018 .Dt GENSNMPTREE 1 .Os .Sh NAME @@ -39,7 +39,7 @@ .Nd "generate C and header files from a MIB description file" .Sh SYNOPSIS .Nm -.Op Fl dEehlt +.Op Fl dEeFfhlt .Op Fl I Ar directory .Op Fl i Ar infile .Op Fl p Ar prefix @@ -99,6 +99,26 @@ is the length of the OID. .It Va OID_ Ns Ar name is the last component of the OID. .El +.It Fl F +Together with +.Fl E +causes +.Nm +instead of the generation of enum definitions the generation of +functions for checking a value to be one of the enumeration variants and +for conversion between strings and the enum. The file is sent to standard +output and is meant to be included into a C-file for compilation. +.It Fl f +This flag can be used together with +.Fl E +or when generating the tree files. It causes +.Nm +to emit static inline functions for checking a value to be one of the +enumeration values and for conversion between strings and the enum. +If used when generating the tree files, the preprocessor symbol +.Ar SNMPTREE_TYPES +must be defined when including the tree header file for these definitions +to become visible. .It Fl h Print a short help page. .It Fl I Ar directory @@ -116,6 +136,36 @@ Instead of normal output print the resulting tree. Prefix the file names and the table name with .Ar prefix . .El +.Pp +The following functions are generated by +.Fl f +or +.Fl F : +.Pp +.Ft static inline int +.Fn isok_EnumName "enum EnumName" ; +.Pp +.Ft static inline const char * +.Fn tostr_EnumName "enum EnumName" ; +.Pp +.Ft static inline int +.Fn fromstr_EnumName "const char *" "enum EnumName *" ; +.Pp +The +.Fa EnumName +is replaced with the enumeration name. +.Fn isok_EnumName +returns 1 if the argument is one of the valid enum values and 0 otherwise. +.Fn tostr_EnumName +returns a string representation of the enumeration value. +If the values is not one of the legal values +.Ar EnumName??? +is returned. +.Fn fromstr_EnumName +returns 1 if the string represents one of the legal enumeration values and +0 otherwise. +If 1 is return the variable pointed to by the second argument is set to +the enumeration value. .Sh MIBS The syntax of the MIB description file can formally be specified as follows: .Bd -unfilled -offset indent Modified: head/contrib/bsnmp/gensnmptree/gensnmptree.c ============================================================================== --- head/contrib/bsnmp/gensnmptree/gensnmptree.c Tue Jul 3 05:56:23 2018 (r335884) +++ head/contrib/bsnmp/gensnmptree/gensnmptree.c Tue Jul 3 08:44:40 2018 (r335885) @@ -3,7 +3,7 @@ * Fraunhofer Institute for Open Communication Systems (FhG Fokus). * All rights reserved. * - * Copyright (c) 2004-2006 + * Copyright (c) 2004-2006,2018 * Hartmut Brandt. * All rights reserved. * @@ -110,18 +110,21 @@ static int debug; static const char usgtxt[] = "\ Generate SNMP tables.\n\ -usage: gensnmptree [-dEehlt] [-I directory] [-i infile] [-p prefix]\n\ +$Id$\n\ +usage: gensnmptree [-dEeFfhlt] [-I directory] [-i infile] [-p prefix]\n\ [name]...\n\ options:\n\ -d debug mode\n\ - -E extract the named enums and bits only\n\ + -E extract the named or all enums and bits only\n\ -e extract the named oids or enums\n\ + -F generate functions for -E into a .c file\n\ + -f generate functions for -E into the header\n\ -h print this info\n\ -I directory add directory to include path\n\ -i ifile read from the named file instead of stdin\n\ -l generate local include directives\n\ -p prefix prepend prefix to file and variable names\n\ - -t generated a .def file\n\ + -t generate a .def file\n\ "; /* @@ -420,10 +423,9 @@ static const struct { /* arbitrary upper limit on node names and function names */ #define MAXSTR 1000 -char str[MAXSTR]; -u_long val; /* integer values */ -int all_cond; /* all conditions are true */ -int saved_token = -1; +static char str[MAXSTR]; +static u_long val; /* integer values */ +static int saved_token = -1; /* * Report an error and exit. @@ -1065,6 +1067,7 @@ gen_table(FILE *fp, struct node *node) #ifdef HAVE_STDINT_H fprintf(fp, "#include <stdint.h>\n"); #endif + fprintf(fp, "#include <string.h>\n"); if (localincs) { fprintf(fp, "#include \"asn1.h\"\n"); fprintf(fp, "#include \"snmp.h\"\n"); @@ -1191,6 +1194,15 @@ extract(FILE *fp, const struct node *np, struct asn_oi return (1); } +/** + * Extract the named OID. + * + * \param fp file to extract to + * \param root root of the tree + * \param object name of the object to extract + * + * \return 0 on success, -1 if the object was not found + */ static int gen_extract(FILE *fp, const struct node *root, char *object) { @@ -1378,6 +1390,13 @@ unminus(FILE *fp, const char *s) } } +/** + * Generate a definition for the enum packed into a guard against multiple + * definitions. + * + * \param fp file to write definition to + * \param t type + */ static void gen_enum(FILE *fp, const struct type *t) { @@ -1402,7 +1421,7 @@ gen_enum(FILE *fp, const struct type *t) fprintf(fp, "#define STROFF_%s %ld\n", t->name, min); fprintf(fp, "#define STRING_%s \\\n", t->name); TAILQ_FOREACH(e, &t->enums, link) { - fprintf(fp, "\t[%ld] \"%s_", e->value - min, t->name); + fprintf(fp, "\t[%ld] = \"%s_", e->value - min, t->name); unminus(fp, e->name); fprintf(fp, "\",\\\n"); } @@ -1410,35 +1429,189 @@ gen_enum(FILE *fp, const struct type *t) fprintf(fp, "#endif /* %s_defined__ */\n", t->name); } +/** + * Generate helper functions for an enum. + * + * We always generate a switch statement for the isok function. The compiler + * optimizes this into range checks if possible. + * + * \param fp file to write to + * \param t type + * \param ccode generate externally visible non-inline functions + */ static void -gen_enums(FILE *fp) +gen_enum_funcs(FILE *fp, const struct type *t, int ccode) { + fprintf(fp, "\n"); + + if (!ccode) + fprintf(fp, "static inline "); + fprintf(fp, "int\n"); + fprintf(fp, "isok_%s(enum %s s)\n", t->name, t->name); + fprintf(fp, "{\n"); + fprintf(fp, " switch (s) {\n"); + + const struct enums *e; + TAILQ_FOREACH(e, &t->enums, link) { + fprintf(fp, "\t case %s_", t->name); + unminus(fp, e->name); + fprintf(fp, ":\n"); + } + + fprintf(fp, " return (1);\n"); + fprintf(fp, " }\n"); + fprintf(fp, " return (0);\n"); + fprintf(fp, "}\n\n"); + + if (!ccode) + fprintf(fp, "static inline "); + fprintf(fp, "const char *\n"); + fprintf(fp, "tostr_%s(enum %s s)\n", t->name, t->name); + fprintf(fp, "{\n"); + fprintf(fp, " static const char *vals[] = { STRING_%s };\n", t->name); + fprintf(fp, "\n"); + fprintf(fp, " if (isok_%s(s))\n", t->name); + fprintf(fp, " return (vals[(int)s - STROFF_%s]);\n", t->name); + fprintf(fp, " return (\"%s???\");\n", t->name); + fprintf(fp, "}\n\n"); + + if (!ccode) + fprintf(fp, "static inline "); + fprintf(fp, "int\n"); + fprintf(fp, "fromstr_%s(const char *str, enum %s *s)\n", + t->name, t->name); + fprintf(fp, "{\n"); + fprintf(fp, " static const char *vals[] = { STRING_%s };\n", t->name); + fprintf(fp, "\n"); + fprintf(fp, " for (size_t i = 0; i < sizeof(vals)/sizeof(vals[0]); i++) {\n"); + fprintf(fp, " if (vals[i] != NULL && strcmp(vals[i], str) == 0) {\n"); + fprintf(fp, " *s = i + STROFF_%s;\n", t->name); + fprintf(fp, " return (1);\n"); + fprintf(fp, " }\n"); + fprintf(fp, " }\n"); + fprintf(fp, " return (0);\n"); + fprintf(fp, "}\n"); +} + +/** + * Generate helper functions for an enum. This generates code for a c file. + * + * \param fp file to write to + * \param name enum name + */ +static int +gen_enum_funcs_str(FILE *fp, const char *name) +{ const struct type *t; LIST_FOREACH(t, &types, link) + if ((t->is_enum || t->is_bits) && strcmp(t->name, name) == 0) { + gen_enum_funcs(fp, t, 1); + return (0); + } + + return (-1); +} + +/** + * Generate helper functions for all enums. + * + * \param fp file to write to + * \param ccode generate externally visible non-inline functions + */ +static void +gen_all_enum_funcs(FILE *fp, int ccode) +{ + const struct type *t; + + LIST_FOREACH(t, &types, link) if (t->is_enum || t->is_bits) - gen_enum(fp, t); + gen_enum_funcs(fp, t, ccode); } +/** + * Extract a given enum to the specified file and optionally generate static + * inline helper functions for them. + * + * \param fp file to print on + * \param name name of the enum + * \param gen_funcs generate the functions too + * + * \return 0 if found, -1 otherwise + */ static int -extract_enum(FILE *fp, const char *name) +extract_enum(FILE *fp, const char *name, int gen_funcs) { const struct type *t; LIST_FOREACH(t, &types, link) if ((t->is_enum || t->is_bits) && strcmp(t->name, name) == 0) { gen_enum(fp, t); + if (gen_funcs) + gen_enum_funcs(fp, t, 0); return (0); } return (-1); } +/** + * Extract all enums to the given file and optionally generate static inline + * helper functions for them. + * + * \param fp file to print on + * \param gen_funcs generate the functions too + */ +static void +extract_all_enums(FILE *fp, int gen_funcs) +{ + const struct type *t; + + LIST_FOREACH(t, &types, link) + if (t->is_enum || t->is_bits) { + gen_enum(fp, t); + if (gen_funcs) + gen_enum_funcs(fp, t, 0); + } +} + +/** + * Extract enums and optionally generate some helper functions for them. + * + * \param argc number of arguments + * \param argv arguments (enum names) + * \param gen_funcs_h generate functions into the header file + * \param gen_funcs_c generate a .c file with functions + */ +static void +make_enums(int argc, char *argv[], int gen_funcs_h, int gen_funcs_c) +{ + if (gen_funcs_c) { + if (argc == 0) + gen_all_enum_funcs(stdout, 1); + else { + for (int i = 0; i < argc; i++) + if (gen_enum_funcs_str(stdout, argv[i])) + errx(1, "enum not found: %s", argv[i]); + } + } else { + if (argc == 0) + extract_all_enums(stdout, gen_funcs_h); + else { + for (int i = 0; i < argc; i++) + if (extract_enum(stdout, argv[i], gen_funcs_h)) + errx(1, "enum not found: %s", argv[i]); + } + } +} + int main(int argc, char *argv[]) { int do_extract = 0; int do_tree = 0; int do_enums = 0; + int gen_funcs_h = 0; + int gen_funcs_c = 0; int opt; struct node *root; char fname[MAXPATHLEN + 1]; @@ -1446,17 +1619,13 @@ main(int argc, char *argv[]) FILE *fp; char *infile = NULL; - while ((opt = getopt(argc, argv, "dEehI:i:lp:t")) != EOF) + while ((opt = getopt(argc, argv, "dEeFfhI:i:lp:t")) != EOF) switch (opt) { case 'd': debug = 1; break; - case 'h': - fprintf(stderr, "%s", usgtxt); - exit(0); - case 'E': do_enums = 1; break; @@ -1465,6 +1634,18 @@ main(int argc, char *argv[]) do_extract = 1; break; + case 'F': + gen_funcs_c = 1; + break; + + case 'f': + gen_funcs_h = 1; + break; + + case 'h': + fprintf(stderr, "%s", usgtxt); + exit(0); + case 'I': path_new(optarg); break; @@ -1493,9 +1674,16 @@ main(int argc, char *argv[]) errx(1, "conflicting options -e/-t/-E"); if (!do_extract && !do_enums && argc != optind) errx(1, "no arguments allowed"); - if ((do_extract || do_enums) && argc == optind) + if (do_extract && argc == optind) errx(1, "no objects specified"); + if ((gen_funcs_h || gen_funcs_c) && (do_extract || do_tree)) + errx(1, "-f and -F not allowed with -e or -t"); + if (gen_funcs_c && !do_enums) + errx(1, "-F requires -E"); + if (gen_funcs_h && gen_funcs_c) + errx(1, "-f and -F are mutually exclusive"); + if (infile == NULL) { input_new(stdin, NULL, "<stdin>"); } else { @@ -1508,7 +1696,8 @@ main(int argc, char *argv[]) while ((tok = gettoken()) != TOK_EOF) merge(&root, parse_top(tok)); - check_tree(root); + if (root) + check_tree(root); if (do_extract) { while (optind < argc) { @@ -1519,11 +1708,8 @@ main(int argc, char *argv[]) return (0); } if (do_enums) { - while (optind < argc) { - if (extract_enum(stdout, argv[optind])) - errx(1, "enum not found: %s", argv[optind]); - optind++; - } + make_enums(argc - optind, argv + optind, + gen_funcs_h, gen_funcs_c); return (0); } if (do_tree) { @@ -1536,7 +1722,7 @@ main(int argc, char *argv[]) gen_header(fp, root, PREFIX_LEN, NULL); fprintf(fp, "\n#ifdef SNMPTREE_TYPES\n"); - gen_enums(fp); + extract_all_enums(fp, gen_funcs_h); fprintf(fp, "\n#endif /* SNMPTREE_TYPES */\n\n"); fprintf(fp, "#define %sCTREE_SIZE %u\n", file_prefix, tree_size); Modified: head/contrib/bsnmp/lib/snmp.h ============================================================================== --- head/contrib/bsnmp/lib/snmp.h Tue Jul 3 05:56:23 2018 (r335884) +++ head/contrib/bsnmp/lib/snmp.h Tue Jul 3 08:44:40 2018 (r335885) @@ -42,6 +42,9 @@ #include <sys/types.h> +#define BSNMP_MAJOR 1 +#define BSNMP_MINOR 13 + #define SNMP_COMMUNITY_MAXLEN 128 #define SNMP_MAX_BINDINGS 100 #define SNMP_CONTEXT_NAME_SIZ (32 + 1) Modified: head/contrib/bsnmp/lib/tc.def ============================================================================== --- head/contrib/bsnmp/lib/tc.def Tue Jul 3 05:56:23 2018 (r335884) +++ head/contrib/bsnmp/lib/tc.def Tue Jul 3 08:44:40 2018 (r335885) @@ -38,3 +38,11 @@ typedef RowStatus ENUM ( 6 destroy ) +typedef StorageType ENUM ( + 1 other + 2 volatile + 3 nonVolatile + 4 permanent + 5 readOnly +) + Modified: head/contrib/bsnmp/snmp_mibII/mibII.c ============================================================================== --- head/contrib/bsnmp/snmp_mibII/mibII.c Tue Jul 3 05:56:23 2018 (r335884) +++ head/contrib/bsnmp/snmp_mibII/mibII.c Tue Jul 3 08:44:40 2018 (r335885) @@ -1772,6 +1772,7 @@ mibII_loading(const struct lmodule *mod, int loaded) mib_unregister_newif(mod); } +extern const struct snmp_module config; const struct snmp_module config = { "This module implements the interface and ip groups.", mibII_init, Modified: head/contrib/bsnmp/snmp_mibII/mibII_route.c ============================================================================== --- head/contrib/bsnmp/snmp_mibII/mibII_route.c Tue Jul 3 05:56:23 2018 (r335884) +++ head/contrib/bsnmp/snmp_mibII/mibII_route.c Tue Jul 3 08:44:40 2018 (r335885) @@ -47,7 +47,7 @@ struct sroute { uint8_t type; uint8_t proto; }; -RB_HEAD(sroutes, sroute) sroutes = RB_INITIALIZER(&sroutes); +static RB_HEAD(sroutes, sroute) sroutes = RB_INITIALIZER(&sroutes); RB_PROTOTYPE(sroutes, sroute, link, sroute_compare); Modified: head/contrib/bsnmp/snmp_ntp/snmp_ntp.c ============================================================================== --- head/contrib/bsnmp/snmp_ntp/snmp_ntp.c Tue Jul 3 05:56:23 2018 (r335884) +++ head/contrib/bsnmp/snmp_ntp/snmp_ntp.c Tue Jul 3 08:44:40 2018 (r335885) @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005 + * Copyright (c) 2005,2018 * Hartmut Brandt. * All rights reserved. * @@ -53,6 +53,8 @@ #include "support.h" #include "snmpmod.h" + +#define SNMPTREE_TYPES #include "ntp_tree.h" #include "ntp_oid.h" Modified: head/contrib/bsnmp/snmp_target/target_snmp.c ============================================================================== --- head/contrib/bsnmp/snmp_target/target_snmp.c Tue Jul 3 05:56:23 2018 (r335884) +++ head/contrib/bsnmp/snmp_target/target_snmp.c Tue Jul 3 08:44:40 2018 (r335885) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2010 The FreeBSD Foundation + * Copyright (c) 2010,2018 The FreeBSD Foundation * All rights reserved. * * This software was developed by Shteryana Sotirova Shopova under @@ -43,6 +43,7 @@ #include "snmp.h" #include "snmpmod.h" +#define SNMPTREE_TYPES #include "target_tree.h" #include "target_oid.h" @@ -826,9 +827,10 @@ target_dump(void) /* XXX: dump the module stats & list of mgmt targets */ } -const char target_comment[] = \ +static const char target_comment[] = \ "This module implements SNMP Management Target MIB Module defined in RFC 3413."; +extern const struct snmp_module config; const struct snmp_module config = { .comment = target_comment, .init = target_init, Modified: head/contrib/bsnmp/snmp_target/target_tree.def ============================================================================== --- head/contrib/bsnmp/snmp_target/target_tree.def Tue Jul 3 05:56:23 2018 (r335884) +++ head/contrib/bsnmp/snmp_target/target_tree.def Tue Jul 3 08:44:40 2018 (r335885) @@ -29,24 +29,7 @@ # $FreeBSD$ # -#include "tc.def" - -typedef RowStatus ENUM ( - 1 active - 2 notInService - 3 notReady - 4 createAndGo - 5 createAndWait - 6 destroy -) - -typedef StorageType ENUM ( - 1 other - 2 volatile - 3 nonVolatile - 4 permanent - 5 readOnly -) +include "tc.def" (1 internet (6 snmpV2 Modified: head/contrib/bsnmp/snmp_usm/usm_snmp.c ============================================================================== --- head/contrib/bsnmp/snmp_usm/usm_snmp.c Tue Jul 3 05:56:23 2018 (r335884) +++ head/contrib/bsnmp/snmp_usm/usm_snmp.c Tue Jul 3 08:44:40 2018 (r335885) @@ -43,6 +43,7 @@ #include "snmp.h" #include "snmpmod.h" +#define SNMPTREE_TYPES #include "usm_tree.h" #include "usm_oid.h" @@ -604,9 +605,10 @@ usm_dump(void) privstr[uuser->suser.priv_proto]); } -const char usm_comment[] = \ +static const char usm_comment[] = \ "This module implements SNMP User-based Security Model defined in RFC 3414."; +extern const struct snmp_module config; const struct snmp_module config = { .comment = usm_comment, .init = usm_init, Modified: head/contrib/bsnmp/snmp_usm/usm_tree.def ============================================================================== --- head/contrib/bsnmp/snmp_usm/usm_tree.def Tue Jul 3 05:56:23 2018 (r335884) +++ head/contrib/bsnmp/snmp_usm/usm_tree.def Tue Jul 3 08:44:40 2018 (r335885) @@ -29,24 +29,7 @@ # $FreeBSD$ # -#include "tc.def" - -typedef RowStatus ENUM ( - 1 active - 2 notInService - 3 notReady - 4 createAndGo - 5 createAndWait - 6 destroy -) - -typedef StorageType ENUM ( - 1 other - 2 volatile - 3 nonVolatile - 4 permanent - 5 readOnly -) +include "tc.def" (1 internet (6 snmpV2 Modified: head/contrib/bsnmp/snmp_vacm/vacm_snmp.c ============================================================================== --- head/contrib/bsnmp/snmp_vacm/vacm_snmp.c Tue Jul 3 05:56:23 2018 (r335884) +++ head/contrib/bsnmp/snmp_vacm/vacm_snmp.c Tue Jul 3 08:44:40 2018 (r335885) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2010 The FreeBSD Foundation + * Copyright (c) 2010,2018 The FreeBSD Foundation * All rights reserved. * * This software was developed by Shteryana Sotirova Shopova under @@ -43,6 +43,7 @@ #include "snmp.h" #include "snmpmod.h" +#define SNMPTREE_TYPES #include "vacm_tree.h" #include "vacm_oid.h" @@ -1012,9 +1013,10 @@ vacm_dump(void) "excluded":"included"); } -const char vacm_comment[] = \ +static const char vacm_comment[] = \ "This module implements SNMP View-based Access Control Model defined in RFC 3415."; +extern const struct snmp_module config; const struct snmp_module config = { .comment = vacm_comment, .init = vacm_init, Modified: head/contrib/bsnmp/snmp_vacm/vacm_tree.def ============================================================================== --- head/contrib/bsnmp/snmp_vacm/vacm_tree.def Tue Jul 3 05:56:23 2018 (r335884) +++ head/contrib/bsnmp/snmp_vacm/vacm_tree.def Tue Jul 3 08:44:40 2018 (r335885) @@ -29,24 +29,7 @@ # $FreeBSD$ # -#include "tc.def" - -typedef RowStatus ENUM ( - 1 active - 2 notInService - 3 notReady - 4 createAndGo - 5 createAndWait - 6 destroy -) - -typedef StorageType ENUM ( - 1 other - 2 volatile - 3 nonVolatile - 4 permanent - 5 readOnly -) +include "tc.def" (1 internet (6 snmpV2 Modified: head/contrib/bsnmp/snmpd/main.c ============================================================================== --- head/contrib/bsnmp/snmpd/main.c Tue Jul 3 05:56:23 2018 (r335884) +++ head/contrib/bsnmp/snmpd/main.c Tue Jul 3 08:44:40 2018 (r335885) @@ -927,7 +927,7 @@ fd_resume(void *p) #ifdef USE_LIBBEGEMOT if (f->id >= 0) return (0); - if ((f->id = poll_register(f->fd, input, f, POLL_IN)) < 0) { + if ((f->id = poll_register(f->fd, input, f, RPOLL_IN)) < 0) { err = errno; syslog(LOG_ERR, "select fd %d: %m", f->fd); errno = err; Modified: head/contrib/bsnmp/snmpd/trans_udp.c ============================================================================== --- head/contrib/bsnmp/snmpd/trans_udp.c Tue Jul 3 05:56:23 2018 (r335884) +++ head/contrib/bsnmp/snmpd/trans_udp.c Tue Jul 3 08:44:40 2018 (r335885) @@ -328,7 +328,7 @@ udp_recv(struct tport *tp, struct port_input *pi) sizeof(struct in_addr)); if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_CREDS) - cred = (struct sockcred *)CMSG_DATA(cmsg); + cred = (struct sockcred *)(void *)CMSG_DATA(cmsg); } if (pi->cred) Modified: head/contrib/bsnmp/snmpd/trap.c ============================================================================== --- head/contrib/bsnmp/snmpd/trap.c Tue Jul 3 05:56:23 2018 (r335884) +++ head/contrib/bsnmp/snmpd/trap.c Tue Jul 3 08:44:40 2018 (r335885) @@ -54,6 +54,8 @@ #include "snmpmod.h" #include "snmpd.h" + +#define SNMPTREE_TYPES #include "tree.h" #include "oid.h" Modified: head/contrib/bsnmp/snmpd/tree.def ============================================================================== --- head/contrib/bsnmp/snmpd/tree.def Tue Jul 3 05:56:23 2018 (r335884) +++ head/contrib/bsnmp/snmpd/tree.def Tue Jul 3 08:44:40 2018 (r335885) @@ -31,16 +31,7 @@ # System group and private Begemot SNMPd MIB. # -#include "tc.def" - -typedef RowStatus ENUM ( - 1 active - 2 notInService - 3 notReady - 4 createAndGo - 5 createAndWait - 6 destroy -) +include "tc.def" (1 internet (2 mgmt Modified: head/contrib/libbegemot/rpoll.c ============================================================================== --- head/contrib/libbegemot/rpoll.c Tue Jul 3 05:56:23 2018 (r335884) +++ head/contrib/libbegemot/rpoll.c Tue Jul 3 08:44:40 2018 (r335885) @@ -44,17 +44,6 @@ # include <unistd.h> # include <sys/time.h> -/* - * There happens to be linuxes which read siginfo.h when including - * signal.h, which, for no appearent reason, defines these symbols. - */ -# ifdef POLL_IN -# undef POLL_IN -# endif -# ifdef POLL_OUT -# undef POLL_OUT -# endif - # include "rpoll.h" /* @@ -339,11 +328,11 @@ poll_build(void) if(p->fd >= 0) { f->fd = p->fd; f->events = 0; - if(p->mask & POLL_IN) + if(p->mask & RPOLL_IN) f->events |= poll_in; - if(p->mask & POLL_OUT) + if(p->mask & RPOLL_OUT) f->events |= poll_out; - if(p->mask & POLL_EXCEPT) + if(p->mask & RPOLL_EXCEPT) f->events |= poll_except; f->revents = 0; p->pfd = f++; @@ -360,11 +349,11 @@ poll_build(void) if(p->fd >= 0) { if(p->fd > maxfd) maxfd = p->fd; - if(p->mask & POLL_IN) + if(p->mask & RPOLL_IN) FD_SET(p->fd, &rset); - if(p->mask & POLL_OUT) + if(p->mask & RPOLL_OUT) FD_SET(p->fd, &wset); - if(p->mask & POLL_EXCEPT) + if(p->mask & RPOLL_EXCEPT) FD_SET(p->fd, &xset); } # endif @@ -582,27 +571,27 @@ poll_dispatch(int wait) # ifdef USE_POLL if(regs[idx].pfd) { - if ((regs[idx].mask & POLL_IN) && + if ((regs[idx].mask & RPOLL_IN) && (regs[idx].pfd->revents & poll_in)) - mask |= POLL_IN; - if ((regs[idx].mask & POLL_OUT) && + mask |= RPOLL_IN; + if ((regs[idx].mask & RPOLL_OUT) && (regs[idx].pfd->revents & poll_out)) - mask |= POLL_OUT; - if((regs[idx].mask & POLL_EXCEPT) && + mask |= RPOLL_OUT; + if((regs[idx].mask & RPOLL_EXCEPT) && (regs[idx].pfd->revents & poll_except)) - mask |= POLL_EXCEPT; + mask |= RPOLL_EXCEPT; } # endif # ifdef USE_SELECT - if ((regs[idx].mask & POLL_IN) && + if ((regs[idx].mask & RPOLL_IN) && FD_ISSET(regs[idx].fd, &nrset)) - mask |= POLL_IN; - if ((regs[idx].mask & POLL_OUT) && + mask |= RPOLL_IN; + if ((regs[idx].mask & RPOLL_OUT) && FD_ISSET(regs[idx].fd, &nwset)) - mask |= POLL_OUT; - if ((regs[idx].mask & POLL_EXCEPT) && + mask |= RPOLL_OUT; + if ((regs[idx].mask & RPOLL_EXCEPT) && FD_ISSET(regs[idx].fd, &nxset)) - mask |= POLL_EXCEPT; + mask |= RPOLL_EXCEPT; # endif assert(idx < regs_alloc); @@ -723,7 +712,7 @@ main(int argc, char *argv[]) { argv = argv; gettimeofday(&start, NULL); - poll_register(0, infunc, NULL, POLL_IN); + poll_register(0, infunc, NULL, RPOLL_IN); if (argc < 2) { t0 = poll_start_timer(1000, 1, tfunc0, "1 second"); Modified: head/contrib/libbegemot/rpoll.h ============================================================================== --- head/contrib/libbegemot/rpoll.h Tue Jul 3 05:56:23 2018 (r335884) +++ head/contrib/libbegemot/rpoll.h Tue Jul 3 08:44:40 2018 (r335885) @@ -47,16 +47,11 @@ int poll_start_utimer(unsigned long long usecs, int re void *arg); void poll_stop_timer(int); -# if defined(POLL_IN) -# undef POLL_IN -# endif -# if defined(POLL_OUT) -# undef POLL_OUT -# endif - -# define POLL_IN 1 -# define POLL_OUT 2 -# define POLL_EXCEPT 4 +enum { + RPOLL_IN = 1, + RPOLL_OUT = 2, + RPOLL_EXCEPT = 4, +}; extern int rpoll_policy; extern int rpoll_trace; Modified: head/lib/libbsnmp/libbsnmp/Makefile ============================================================================== --- head/lib/libbsnmp/libbsnmp/Makefile Tue Jul 3 05:56:23 2018 (r335884) +++ head/lib/libbsnmp/libbsnmp/Makefile Tue Jul 3 08:44:40 2018 (r335885) @@ -20,8 +20,22 @@ LIBADD= crypto .endif SRCS= asn1.c snmp.c snmpagent.c snmpclient.c snmpcrypto.c support.c +SRCS+= snmptc.h INCS= asn1.h snmp.h snmpagent.h snmpclient.h MAN= asn1.3 bsnmpagent.3 bsnmpclient.3 bsnmplib.3 + +snmptc.h : tc.def + (\ + echo -n "/* autogenerated from tc.def; ";\ + ls -l -D "%F %T" ${.ALLSRC} | awk '{printf("%s %s", $$6, $$7)}';\ + echo "*/";\ + echo "#ifndef snmptc_h_1529923773";\ + echo "#define snmptc_h_1529923773";\ + gensnmptree -E -f <${.ALLSRC};\ + echo "#endif" ; \ + ) >${.TARGET} + +CLEANFILES+= snmptc.h MLINKS+= asn1.3 asn_append_oid.3 MLINKS+= asn1.3 asn_commit_header.3 Modified: head/share/mk/bsd.snmpmod.mk ============================================================================== --- head/share/mk/bsd.snmpmod.mk Tue Jul 3 05:56:23 2018 (r335884) +++ head/share/mk/bsd.snmpmod.mk Tue Jul 3 08:44:40 2018 (r335885) @@ -6,14 +6,16 @@ SHLIB_NAME= snmp_${MOD}.so.${SHLIB_MAJOR} SRCS+= ${MOD}_oid.h ${MOD}_tree.c ${MOD}_tree.h CLEANFILES+= ${MOD}_oid.h ${MOD}_tree.c ${MOD}_tree.h CFLAGS+= -I. +GENSNMPTREEFLAGS+= -I${SHAREDIR}/snmpdefs + ${MOD}_oid.h: ${MOD}_tree.def ${EXTRAMIBDEFS} ${EXTRAMIBSYMS} - cat ${.ALLSRC} | gensnmptree -e ${XSYM} > ${.TARGET} + cat ${.ALLSRC} | gensnmptree ${GENSNMPTREEFLAGS} -e ${XSYM} > ${.TARGET} .ORDER: ${MOD}_tree.c ${MOD}_tree.h ${MOD}_tree.h: .NOMETA ${MOD}_tree.c ${MOD}_tree.h: ${MOD}_tree.def ${EXTRAMIBDEFS} - cat ${.ALLSRC} | gensnmptree -p ${MOD}_ + cat ${.ALLSRC} | gensnmptree -f ${GENSNMPTREEFLAGS} -p ${MOD}_ .if defined(DEFS) FILESGROUPS+= DEFS Modified: head/usr.sbin/bsnmpd/bsnmpd/Makefile ============================================================================== --- head/usr.sbin/bsnmpd/bsnmpd/Makefile Tue Jul 3 05:56:23 2018 (r335884) +++ head/usr.sbin/bsnmpd/bsnmpd/Makefile Tue Jul 3 08:44:40 2018 (r335885) @@ -123,7 +123,6 @@ BMIBSDIR= ${SHAREDIR}/snmp/mibs DEFS= tree.def DEFSDIR= ${SHAREDIR}/snmp/defs -CFLAGS+= -DSNMPTREE_TYPES CFLAGS+= -I${CONTRIB}/lib -I${CONTRIB}/snmpd -I. -DUSE_LIBBEGEMOT CFLAGS+= -DHAVE_STDINT_H -DHAVE_INTTYPES_H -DHAVE_ERR_H -DHAVE_STRLCPY LIBADD= begemot bsnmp @@ -140,18 +139,15 @@ LIBADD+= wrap .endif oid.h: tree.def Makefile - gensnmptree -e ${XSYM} < ${.ALLSRC:M*.def} > ${.TARGET} + gensnmptree -I${CONTRIB}/lib -e ${XSYM} < ${.ALLSRC:M*.def} > ${.TARGET} .ORDER: tree.c tree.h tree.h: .NOMETA tree.c tree.h: tree.def - gensnmptree -l < ${.ALLSRC} + gensnmptree -I${CONTRIB}/lib -l -f < ${.ALLSRC} MANFILTER= sed -e 's%@MODPATH@%${LIBDIR}/%g' \ -e 's%@DEFPATH@%${DEFSDIR}/%g' \ -e 's%@MIBSPATH@%${BMIBSDIR}/%g' - -NO_WCAST_ALIGN= yes -WARNS?= 6 .include <bsd.prog.mk> Modified: head/usr.sbin/bsnmpd/modules/snmp_bridge/Makefile ============================================================================== --- head/usr.sbin/bsnmpd/modules/snmp_bridge/Makefile Tue Jul 3 05:56:23 2018 (r335884) +++ head/usr.sbin/bsnmpd/modules/snmp_bridge/Makefile Tue Jul 3 08:44:40 2018 (r335885) @@ -5,7 +5,6 @@ MOD= bridge SRCS= bridge_snmp.c bridge_if.c bridge_port.c bridge_addrs.c \ bridge_pf.c bridge_sys.c -CFLAGS+= -DSNMPTREE_TYPES XSYM= dot1dBridge newRoot topologyChange begemotBridgeNewRoot \ begemotBridgeTopologyChange begemotBridgeBaseName Modified: head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_addrs.c ============================================================================== --- head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_addrs.c Tue Jul 3 05:56:23 2018 (r335884) +++ head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_addrs.c Tue Jul 3 08:44:40 2018 (r335885) @@ -49,6 +49,7 @@ #include <bsnmp/snmpmod.h> #include <bsnmp/snmp_mibII.h> +#define SNMPTREE_TYPES #include "bridge_tree.h" #include "bridge_snmp.h" Modified: head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_if.c ============================================================================== --- head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_if.c Tue Jul 3 05:56:23 2018 (r335884) +++ head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_if.c Tue Jul 3 08:44:40 2018 (r335885) @@ -50,6 +50,7 @@ #include <bsnmp/snmpmod.h> #include <bsnmp/snmp_mibII.h> +#define SNMPTREE_TYPES #include "bridge_tree.h" #include "bridge_snmp.h" #include "bridge_oid.h" Modified: head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_pf.c ============================================================================== --- head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_pf.c Tue Jul 3 05:56:23 2018 (r335884) +++ head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_pf.c Tue Jul 3 08:44:40 2018 (r335885) @@ -48,6 +48,7 @@ #include <bsnmp/snmpmod.h> #include <bsnmp/snmp_mibII.h> +#define SNMPTREE_TYPES #include "bridge_tree.h" #include "bridge_snmp.h" Modified: head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_port.c ============================================================================== --- head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_port.c Tue Jul 3 05:56:23 2018 (r335884) *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?081170FC-D433-4FE6-87E1-D5470480B971>