diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-04-27 14:26:04 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-04-27 15:02:18 +0300 |
commit | 94973146c58df26b20e17e2e5b1274216ca88969 (patch) | |
tree | 17538cc2991af0acec5bebfe6a826ef67cd9fc95 | |
parent | 319c154c46214fdc5d8f8b498ae5a23bc8d03072 (diff) | |
download | varnish-mib-94973146c58df26b20e17e2e5b1274216ca88969.tar.gz varnish-mib-94973146c58df26b20e17e2e5b1274216ca88969.tar.bz2 |
Support for Varnish 4.1
* NEWS: Update.
* bootstrap: Rewrite as a Perl script; create m4/varnish_mib.m4
from src/varnish_mib.mib2c
* configure.ac: Version 1.1.90
Use AC_CHECK_VSC_C_MAIN_MEMBERS
Define VARNISHAPI_MAJOR, VARNISHAPI_MINOR and
VARNISHAPI_PATCH for use in preprocessor directives.
* src/betab.c [VARNISHAPI_MINOR] (VSC_POINT_FMT): Define
depending on Varnish API minor version.
* src/varnish_mib.mib2c (varnish_translate_table): New variable.
It is used both by varnish_translate in this module, and by
bootstrap to produce a list of macros checking for members of
struct VSC_C_main.
Output preprocessor conditionals in right places.
* src/vcli.c (vcli_connect): Fix cc warnings.
* src/varnish-mib.8: Update.
-rw-r--r-- | NEWS | 11 | ||||
-rwxr-xr-x | bootstrap | 84 | ||||
-rw-r--r-- | configure.ac | 20 | ||||
-rw-r--r-- | src/betab.c | 8 | ||||
-rw-r--r-- | src/varnish-mib.8 | 40 | ||||
-rw-r--r-- | src/varnish_mib.mib2c | 39 | ||||
-rw-r--r-- | src/vcli.c | 4 |
7 files changed, 172 insertions, 34 deletions
@@ -1,25 +1,30 @@ | |||
1 | Varnish-mib NEWS -- history of user-visible changes. 2015-02-25 | 1 | Varnish-mib NEWS -- history of user-visible changes. 2016-04-27 |
2 | Copyright (C) 2014-2015 Sergey Poznyakoff | 2 | Copyright (C) 2014-2016 Sergey Poznyakoff |
3 | See the end of file for copying conditions. | 3 | See the end of file for copying conditions. |
4 | 4 | ||
5 | Please send Varnish-mib bug reports to <gray@gnu.org> | 5 | Please send Varnish-mib bug reports to <gray@gnu.org> |
6 | 6 | ||
7 | Version 1.1.90 (Git) | ||
8 | |||
9 | * Support for Varnish 4.1 | ||
10 | |||
11 | |||
7 | Version 1.1, 2015-02-25 | 12 | Version 1.1, 2015-02-25 |
8 | 13 | ||
9 | * Don't exit if unable to open Varnish memory file | 14 | * Don't exit if unable to open Varnish memory file |
10 | 15 | ||
11 | 16 | ||
12 | Version 1.0, 2014-11-28 | 17 | Version 1.0, 2014-11-28 |
13 | 18 | ||
14 | Initial release. | 19 | Initial release. |
15 | 20 | ||
16 | 21 | ||
17 | * Copyright information: | 22 | * Copyright information: |
18 | 23 | ||
19 | Copyright (C) 2014-2015 Sergey Poznyakoff | 24 | Copyright (C) 2014-2016 Sergey Poznyakoff |
20 | 25 | ||
21 | Permission is granted to anyone to make or distribute verbatim copies | 26 | Permission is granted to anyone to make or distribute verbatim copies |
22 | of this document as received, in any medium, provided that the | 27 | of this document as received, in any medium, provided that the |
23 | copyright notice and this permission notice are preserved, | 28 | copyright notice and this permission notice are preserved, |
24 | thus giving the recipient permission to redistribute in turn. | 29 | thus giving the recipient permission to redistribute in turn. |
25 | 30 | ||
@@ -1,7 +1,77 @@ | |||
1 | #!/bin/sh | 1 | #!/usr/bin/perl |
2 | for dir in m4 build-aux | 2 | use strict; |
3 | do | 3 | use autodie; |
4 | test -d $dir || mkdir $dir | 4 | |
5 | done | 5 | my $mib2c_config = 'src/varnish_mib.mib2c'; |
6 | > ChangeLog | 6 | |
7 | autoreconf -f -i -s | 7 | die "This file must be run from the varnish-mib top level source directory" |
8 | unless -r $mib2c_config; | ||
9 | |||
10 | print "$0: creating ancillary directories and files\n"; | ||
11 | foreach my $dir ('m4', 'build-aux') { | ||
12 | mkdir($dir) unless -d $dir; | ||
13 | } | ||
14 | |||
15 | unless (-f 'ChangeLog') { | ||
16 | open(my $fd, '>', 'ChangeLog'); | ||
17 | print $fd <<EOT | ||
18 | This file is a placeholder. It will be filled with actual data by the first | ||
19 | run of make. | ||
20 | EOT | ||
21 | ; | ||
22 | close $fd; | ||
23 | } | ||
24 | |||
25 | print "$0: generating m4/varnish_mib.m4\n"; | ||
26 | open(my $fd, '<', $mib2c_config); | ||
27 | my $prog; | ||
28 | while (<$fd>) { | ||
29 | if (defined($prog)) { | ||
30 | last if /^\@endperl\@/; | ||
31 | $prog .= $_; | ||
32 | } else { | ||
33 | if (/^\@startperl\@/) { | ||
34 | $prog = "no strict \"vars\";\n"; | ||
35 | } | ||
36 | } | ||
37 | } | ||
38 | |||
39 | my %vars; | ||
40 | eval $prog; | ||
41 | die $@ if $@; | ||
42 | die "$mib2c_config does not declare translation table" | ||
43 | unless exists $vars{'varnish_translate_table'}; | ||
44 | |||
45 | open(my $fd, '>', 'm4/varnish_mib.m4'); | ||
46 | print $fd <<'EOT'; | ||
47 | AC_DEFUN([AC_CHECK_VSC_C_MAIN_MEMBERS], | ||
48 | [save_CFLAGS="$CFLAGS" | ||
49 | CFLAGS="$CFLAGS $VARNISHAPI_CFLAGS" | ||
50 | EOT | ||
51 | ; | ||
52 | |||
53 | foreach my $member (sort | ||
54 | map { $_->[1] } | ||
55 | grep { $_->[0] eq 'MAIN' } | ||
56 | values %{$vars{'varnish_translate_table'}}) { | ||
57 | print $fd <<EOT | ||
58 | AC_CHECK_MEMBERS([struct VSC_C_main.$member],,, | ||
59 | [#include <stddef.h> | ||
60 | #include <stdlib.h> | ||
61 | #include <stdint.h> | ||
62 | #include <limits.h> | ||
63 | #include <vapi/vsc.h> | ||
64 | #include <vapi/vsm.h> | ||
65 | #include <vcli.h>]) | ||
66 | EOT | ||
67 | ; | ||
68 | } | ||
69 | print $fd <<'EOT' | ||
70 | CFLAGS="$save_CFLAGS" | ||
71 | ]) | ||
72 | EOT | ||
73 | ; | ||
74 | close $fd; | ||
75 | |||
76 | print "$0: reconfiguring\n"; | ||
77 | exec('autoreconf -f -i -s'); | ||
diff --git a/configure.ac b/configure.ac index d571518..cf0bf05 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -1,8 +1,8 @@ | |||
1 | # This file is part of Varnish-mib -*- autoconf -*- | 1 | # This file is part of Varnish-mib -*- autoconf -*- |
2 | # Copyright (C) 2014-2015 Sergey Poznyakoff | 2 | # Copyright (C) 2014-2016 Sergey Poznyakoff |
3 | # | 3 | # |
4 | # Varnish-mib is free software; you can redistribute it and/or modify | 4 | # Varnish-mib is free software; you can redistribute it and/or modify |
5 | # it under the terms of the GNU General Public License as published by | 5 | # it under the terms of the GNU General Public License as published by |
6 | # the Free Software Foundation; either version 3, or (at your option) | 6 | # the Free Software Foundation; either version 3, or (at your option) |
7 | # any later version. | 7 | # any later version. |
8 | # | 8 | # |
@@ -12,13 +12,13 @@ | |||
12 | # GNU General Public License for more details. | 12 | # GNU General Public License for more details. |
13 | # | 13 | # |
14 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
15 | # along with Varnish-mib. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Varnish-mib. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | ||
17 | AC_PREREQ(2.69) | 17 | AC_PREREQ(2.69) |
18 | AC_INIT([varnish-mib], 1.1, [gray@gnu.org]) | 18 | AC_INIT([varnish-mib], 1.1.90, [gray@gnu.org]) |
19 | AC_CONFIG_SRCDIR(src/varnish_mib.mib2c) | 19 | AC_CONFIG_SRCDIR(src/varnish_mib.mib2c) |
20 | AM_CONFIG_HEADER(config.h) | 20 | AM_CONFIG_HEADER(config.h) |
21 | AC_CONFIG_AUX_DIR([build-aux]) | 21 | AC_CONFIG_AUX_DIR([build-aux]) |
22 | AC_CONFIG_MACRO_DIR([m4]) | 22 | AC_CONFIG_MACRO_DIR([m4]) |
23 | 23 | ||
24 | AC_CANONICAL_SYSTEM | 24 | AC_CANONICAL_SYSTEM |
@@ -40,12 +40,28 @@ AC_PROG_MAKE_SET | |||
40 | # Check for pkg-config | 40 | # Check for pkg-config |
41 | PKG_PROG_PKG_CONFIG | 41 | PKG_PROG_PKG_CONFIG |
42 | 42 | ||
43 | # Checks for Varnish | 43 | # Checks for Varnish |
44 | PKG_CHECK_MODULES([VARNISHAPI], [varnishapi >= 4.0]) | 44 | PKG_CHECK_MODULES([VARNISHAPI], [varnishapi >= 4.0]) |
45 | 45 | ||
46 | varnishapi_version() { | ||
47 | AC_DEFINE_UNQUOTED([VARNISHAPI_MAJOR],[$1],[Varnish API major version number]) | ||
48 | AC_DEFINE_UNQUOTED([VARNISHAPI_MINOR],[$2],[Varnish API minor version number]) | ||
49 | AC_DEFINE_UNQUOTED([VARNISHAPI_PATCH],[$3],[Varnish API patchlevel]) | ||
50 | } | ||
51 | |||
52 | v=$($PKG_CONFIG --modversion varnishapi) | ||
53 | if test -n "$v"; then | ||
54 | save_IFS=$IFS | ||
55 | IFS='.' | ||
56 | varnishapi_version $v | ||
57 | IFS=$save_IFS | ||
58 | fi | ||
59 | |||
60 | AC_CHECK_VSC_C_MAIN_MEMBERS | ||
61 | |||
46 | # Check for Net-SNMP | 62 | # Check for Net-SNMP |
47 | AC_PATH_PROG([NET_SNMP_CONFIG], net-snmp-config, none, $PATH) | 63 | AC_PATH_PROG([NET_SNMP_CONFIG], net-snmp-config, none, $PATH) |
48 | if test "$NET_SNMP_CONFIG" = "none"; then | 64 | if test "$NET_SNMP_CONFIG" = "none"; then |
49 | AC_MSG_ERROR([cannot find Net-SNMP (net-snmp-config not found)]) | 65 | AC_MSG_ERROR([cannot find Net-SNMP (net-snmp-config not found)]) |
50 | fi | 66 | fi |
51 | AC_SUBST(NET_SNMP_CONFIG) | 67 | AC_SUBST(NET_SNMP_CONFIG) |
diff --git a/src/betab.c b/src/betab.c index b583958..49e02f7 100644 --- a/src/betab.c +++ b/src/betab.c | |||
@@ -56,13 +56,19 @@ create_entry(netsnmp_tdata *table_data, long idx, | |||
56 | return entry; | 56 | return entry; |
57 | } | 57 | } |
58 | 58 | ||
59 | #define VSC_POINT_TYPE(p) ((p)->section->fantom->type) | 59 | #define VSC_POINT_TYPE(p) ((p)->section->fantom->type) |
60 | #define VSC_POINT_IDENT(p) ((p)->section->fantom->ident) | 60 | #define VSC_POINT_IDENT(p) ((p)->section->fantom->ident) |
61 | #define VSC_POINT_NAME(p) ((p)->desc->name) | 61 | #define VSC_POINT_NAME(p) ((p)->desc->name) |
62 | #define VSC_POINT_FMT(p) ((p)->desc->fmt) | 62 | #if VARNISHAPI_MINOR == 0 |
63 | # define VSC_POINT_FMT(p) ((p)->desc->fmt) | ||
64 | #elif VARNISHAPI_MINOR == 1 | ||
65 | # define VSC_POINT_FMT(p) ((p)->desc->ctype) | ||
66 | #else | ||
67 | # error "unsupported Varnish API minor number" | ||
68 | #endif | ||
63 | 69 | ||
64 | struct betab_priv { | 70 | struct betab_priv { |
65 | int err; | 71 | int err; |
66 | long idx; | 72 | long idx; |
67 | struct backendTable_entry ent; | 73 | struct backendTable_entry ent; |
68 | netsnmp_tdata *table; | 74 | netsnmp_tdata *table; |
diff --git a/src/varnish-mib.8 b/src/varnish-mib.8 index 4559b0c..0c54e6f 100644 --- a/src/varnish-mib.8 +++ b/src/varnish-mib.8 | |||
@@ -1,8 +1,8 @@ | |||
1 | .\" This file is part of Varnish-mib -*- nroff -*- | 1 | .\" This file is part of Varnish-mib -*- nroff -*- |
2 | .\" Copyright (C) 2014-2015 Sergey Poznyakoff | 2 | .\" Copyright (C) 2014-2016 Sergey Poznyakoff |
3 | .\"< |