diff options
author | Hartmut Brandt <harti@FreeBSD.org> | 2018-07-03 08:44:40 +0000 |
---|---|---|
committer | Hartmut Brandt <harti@FreeBSD.org> | 2018-07-03 08:44:40 +0000 |
commit | 8e9b3e707151d136ec95e7f1d37556e39c1e228c (patch) | |
tree | 0bf4cf04b0aa2c25155c8b45a1704512517c9127 /contrib | |
parent | 4dc1b29b7169560aa0a16bb3488dac17325767f0 (diff) | |
download | src-8e9b3e707151d136ec95e7f1d37556e39c1e228c.tar.gz src-8e9b3e707151d136ec95e7f1d37556e39c1e228c.zip |
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.
Notes
Notes:
svn path=/head/; revision=335885
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/bsnmp/VERSION | 2 | ||||
-rw-r--r-- | contrib/bsnmp/gensnmptree/gensnmptree.1 | 56 | ||||
-rw-r--r-- | contrib/bsnmp/gensnmptree/gensnmptree.c | 236 | ||||
-rw-r--r-- | contrib/bsnmp/lib/snmp.h | 3 | ||||
-rw-r--r-- | contrib/bsnmp/lib/tc.def | 8 | ||||
-rw-r--r-- | contrib/bsnmp/snmp_mibII/mibII.c | 1 | ||||
-rw-r--r-- | contrib/bsnmp/snmp_mibII/mibII_route.c | 2 | ||||
-rw-r--r-- | contrib/bsnmp/snmp_ntp/snmp_ntp.c | 4 | ||||
-rw-r--r-- | contrib/bsnmp/snmp_target/target_snmp.c | 6 | ||||
-rw-r--r-- | contrib/bsnmp/snmp_target/target_tree.def | 19 | ||||
-rw-r--r-- | contrib/bsnmp/snmp_usm/usm_snmp.c | 4 | ||||
-rw-r--r-- | contrib/bsnmp/snmp_usm/usm_tree.def | 19 | ||||
-rw-r--r-- | contrib/bsnmp/snmp_vacm/vacm_snmp.c | 6 | ||||
-rw-r--r-- | contrib/bsnmp/snmp_vacm/vacm_tree.def | 19 | ||||
-rw-r--r-- | contrib/bsnmp/snmpd/main.c | 2 | ||||
-rw-r--r-- | contrib/bsnmp/snmpd/trans_udp.c | 2 | ||||
-rw-r--r-- | contrib/bsnmp/snmpd/trap.c | 2 | ||||
-rw-r--r-- | contrib/bsnmp/snmpd/tree.def | 11 | ||||
-rw-r--r-- | contrib/libbegemot/rpoll.c | 49 | ||||
-rw-r--r-- | contrib/libbegemot/rpoll.h | 15 |
20 files changed, 324 insertions, 142 deletions
diff --git a/contrib/bsnmp/VERSION b/contrib/bsnmp/VERSION index 809bdcb851df..d3456a90f7d7 100644 --- a/contrib/bsnmp/VERSION +++ b/contrib/bsnmp/VERSION @@ -1 +1 @@ -1.12 +1.13 diff --git a/contrib/bsnmp/gensnmptree/gensnmptree.1 b/contrib/bsnmp/gensnmptree/gensnmptree.1 index c0046b5c8343..0d6b5cda482d 100644 --- a/contrib/bsnmp/gensnmptree/gensnmptree.1 +++ b/contrib/bsnmp/gensnmptree/gensnmptree.1 @@ -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 diff --git a/contrib/bsnmp/gensnmptree/gensnmptree.c b/contrib/bsnmp/gensnmptree/gensnmptree.c index f2dc4fd68c6e..8ec253a604d0 100644 --- a/contrib/bsnmp/gensnmptree/gensnmptree.c +++ b/contrib/bsnmp/gensnmptree/gensnmptree.c @@ -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_oid *oid, const char *obj, 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); diff --git a/contrib/bsnmp/lib/snmp.h b/contrib/bsnmp/lib/snmp.h index 61e783e76bb0..7db21ae7d8d0 100644 --- a/contrib/bsnmp/lib/snmp.h +++ b/contrib/bsnmp/lib/snmp.h @@ -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) diff --git a/contrib/bsnmp/lib/tc.def b/contrib/bsnmp/lib/tc.def index 65f69723c0a6..1930346ecabb 100644 --- a/contrib/bsnmp/lib/tc.def +++ b/contrib/bsnmp/lib/tc.def @@ -38,3 +38,11 @@ typedef RowStatus ENUM ( 6 destroy ) +typedef StorageType ENUM ( + 1 other + 2 volatile + 3 nonVolatile + 4 permanent + 5 readOnly +) + diff --git a/contrib/bsnmp/snmp_mibII/mibII.c b/contrib/bsnmp/snmp_mibII/mibII.c index d6c3ce40b076..bffbd35793c9 100644 --- a/contrib/bsnmp/snmp_mibII/mibII.c +++ b/contrib/bsnmp/snmp_mibII/mibII.c @@ -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, diff --git a/contrib/bsnmp/snmp_mibII/mibII_route.c b/contrib/bsnmp/snmp_mibII/mibII_route.c index 2d449a364f0c..e8b2535ee88a 100644 --- a/contrib/bsnmp/snmp_mibII/mibII_route.c +++ b/contrib/bsnmp/snmp_mibII/mibII_route.c @@ -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); diff --git a/contrib/bsnmp/snmp_ntp/snmp_ntp.c b/contrib/bsnmp/snmp_ntp/snmp_ntp.c index fcc129a917fa..285168b1d982 100644 --- a/contrib/bsnmp/snmp_ntp/snmp_ntp.c +++ b/contrib/bsnmp/snmp_ntp/snmp_ntp.c @@ -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" diff --git a/contrib/bsnmp/snmp_target/target_snmp.c b/contrib/bsnmp/snmp_target/target_snmp.c index ed8df74fbfdb..7ea47db0491a 100644 --- a/contrib/bsnmp/snmp_target/target_snmp.c +++ b/contrib/bsnmp/snmp_target/target_snmp.c @@ -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, diff --git a/contrib/bsnmp/snmp_target/target_tree.def b/contrib/bsnmp/snmp_target/target_tree.def index 990bfac0b06e..14424b00bdc6 100644 --- a/contrib/bsnmp/snmp_target/target_tree.def +++ b/contrib/bsnmp/snmp_target/target_tree.def @@ -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 diff --git a/contrib/bsnmp/snmp_usm/usm_snmp.c b/contrib/bsnmp/snmp_usm/usm_snmp.c index a6c7b8634a1b..149d0f7c6f06 100644 --- a/contrib/bsnmp/snmp_usm/usm_snmp.c +++ b/contrib/bsnmp/snmp_usm/usm_snmp.c @@ -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, diff --git a/contrib/bsnmp/snmp_usm/usm_tree.def b/contrib/bsnmp/snmp_usm/usm_tree.def index 72c446e4cc55..84b52956e167 100644 --- a/contrib/bsnmp/snmp_usm/usm_tree.def +++ b/contrib/bsnmp/snmp_usm/usm_tree.def @@ -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 diff --git a/contrib/bsnmp/snmp_vacm/vacm_snmp.c b/contrib/bsnmp/snmp_vacm/vacm_snmp.c index 61142afe1ae9..576495a58889 100644 --- a/contrib/bsnmp/snmp_vacm/vacm_snmp.c +++ b/contrib/bsnmp/snmp_vacm/vacm_snmp.c @@ -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, diff --git a/contrib/bsnmp/snmp_vacm/vacm_tree.def b/contrib/bsnmp/snmp_vacm/vacm_tree.def index 45b3c335991c..5418a5a6cac1 100644 --- a/contrib/bsnmp/snmp_vacm/vacm_tree.def +++ b/contrib/bsnmp/snmp_vacm/vacm_tree.def @@ -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 diff --git a/contrib/bsnmp/snmpd/main.c b/contrib/bsnmp/snmpd/main.c index 939b350b4200..55c93dcba921 100644 --- a/contrib/bsnmp/snmpd/main.c +++ b/contrib/bsnmp/snmpd/main.c @@ -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; diff --git a/contrib/bsnmp/snmpd/trans_udp.c b/contrib/bsnmp/snmpd/trans_udp.c index 5c9a7fd470a2..fa25ee089795 100644 --- a/contrib/bsnmp/snmpd/trans_udp.c +++ b/contrib/bsnmp/snmpd/trans_udp.c @@ -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) diff --git a/contrib/bsnmp/snmpd/trap.c b/contrib/bsnmp/snmpd/trap.c index 30ff29304d58..396a45c3aeb8 100644 --- a/contrib/bsnmp/snmpd/trap.c +++ b/contrib/bsnmp/snmpd/trap.c @@ -54,6 +54,8 @@ #include "snmpmod.h" #include "snmpd.h" + +#define SNMPTREE_TYPES #include "tree.h" #include "oid.h" diff --git a/contrib/bsnmp/snmpd/tree.def b/contrib/bsnmp/snmpd/tree.def index 2b6a9b98d9a3..cb5d2ec474ce 100644 --- a/contrib/bsnmp/snmpd/tree.def +++ b/contrib/bsnmp/snmpd/tree.def @@ -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 diff --git a/contrib/libbegemot/rpoll.c b/contrib/libbegemot/rpoll.c index 408635e01799..c61b84057eba 100644 --- a/contrib/libbegemot/rpoll.c +++ b/contrib/libbegemot/rpoll.c @@ -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"); diff --git a/contrib/libbegemot/rpoll.h b/contrib/libbegemot/rpoll.h index 497a41ef5eaf..4f0c4e38ec7c 100644 --- a/contrib/libbegemot/rpoll.h +++ b/contrib/libbegemot/rpoll.h @@ -47,16 +47,11 @@ int poll_start_utimer(unsigned long long usecs, int repeat, timer_f func, 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; |