aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-04-27 14:26:04 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2016-04-27 15:02:18 +0300
commit94973146c58df26b20e17e2e5b1274216ca88969 (patch)
tree17538cc2991af0acec5bebfe6a826ef67cd9fc95
parent319c154c46214fdc5d8f8b498ae5a23bc8d03072 (diff)
downloadvarnish-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--NEWS11
-rwxr-xr-xbootstrap84
-rw-r--r--configure.ac20
-rw-r--r--src/betab.c8
-rw-r--r--src/varnish-mib.840
-rw-r--r--src/varnish_mib.mib2c39
-rw-r--r--src/vcli.c4
7 files changed, 172 insertions, 34 deletions
diff --git a/NEWS b/NEWS
index cb6b102..f12c539 100644
--- a/NEWS
+++ b/NEWS
@@ -1,25 +1,30 @@
1Varnish-mib NEWS -- history of user-visible changes. 2015-02-25 1Varnish-mib NEWS -- history of user-visible changes. 2016-04-27
2Copyright (C) 2014-2015 Sergey Poznyakoff 2Copyright (C) 2014-2016 Sergey Poznyakoff
3See the end of file for copying conditions. 3See the end of file for copying conditions.
4 4
5Please send Varnish-mib bug reports to <gray@gnu.org> 5Please send Varnish-mib bug reports to <gray@gnu.org>
6 6
7Version 1.1.90 (Git)
8
9* Support for Varnish 4.1
10
11
7Version 1.1, 2015-02-25 12Version 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
12Version 1.0, 2014-11-28 17Version 1.0, 2014-11-28
13 18
14Initial release. 19Initial release.
15 20
16 21
17* Copyright information: 22* Copyright information:
18 23
19Copyright (C) 2014-2015 Sergey Poznyakoff 24Copyright (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
diff --git a/bootstrap b/bootstrap
index c55c2b2..25bc72e 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,7 +1,77 @@
1#!/bin/sh 1#!/usr/bin/perl
2for dir in m4 build-aux 2use strict;
3do 3use autodie;
4 test -d $dir || mkdir $dir 4
5done 5my $mib2c_config = 'src/varnish_mib.mib2c';
6> ChangeLog 6
7autoreconf -f -i -s 7die "This file must be run from the varnish-mib top level source directory"
8 unless -r $mib2c_config;
9
10print "$0: creating ancillary directories and files\n";
11foreach my $dir ('m4', 'build-aux') {
12 mkdir($dir) unless -d $dir;
13}
14
15unless (-f 'ChangeLog') {
16 open(my $fd, '>', 'ChangeLog');
17 print $fd <<EOT
18This file is a placeholder. It will be filled with actual data by the first
19run of make.
20EOT
21;
22 close $fd;
23}
24
25print "$0: generating m4/varnish_mib.m4\n";
26open(my $fd, '<', $mib2c_config);
27my $prog;
28while (<$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
39my %vars;
40eval $prog;
41die $@ if $@;
42die "$mib2c_config does not declare translation table"
43 unless exists $vars{'varnish_translate_table'};
44
45open(my $fd, '>', 'm4/varnish_mib.m4');
46print $fd <<'EOT';
47AC_DEFUN([AC_CHECK_VSC_C_MAIN_MEMBERS],
48[save_CFLAGS="$CFLAGS"
49CFLAGS="$CFLAGS $VARNISHAPI_CFLAGS"
50EOT
51;
52
53foreach 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>])
66EOT
67;
68}
69print $fd <<'EOT'
70CFLAGS="$save_CFLAGS"
71])
72EOT
73;
74close $fd;
75
76print "$0: reconfiguring\n";
77exec('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
17AC_PREREQ(2.69) 17AC_PREREQ(2.69)
18AC_INIT([varnish-mib], 1.1, [gray@gnu.org]) 18AC_INIT([varnish-mib], 1.1.90, [gray@gnu.org])
19AC_CONFIG_SRCDIR(src/varnish_mib.mib2c) 19AC_CONFIG_SRCDIR(src/varnish_mib.mib2c)
20AM_CONFIG_HEADER(config.h) 20AM_CONFIG_HEADER(config.h)
21AC_CONFIG_AUX_DIR([build-aux]) 21AC_CONFIG_AUX_DIR([build-aux])
22AC_CONFIG_MACRO_DIR([m4]) 22AC_CONFIG_MACRO_DIR([m4])
23 23
24AC_CANONICAL_SYSTEM 24AC_CANONICAL_SYSTEM
@@ -40,12 +40,28 @@ AC_PROG_MAKE_SET
40# Check for pkg-config 40# Check for pkg-config
41PKG_PROG_PKG_CONFIG 41PKG_PROG_PKG_CONFIG
42 42
43# Checks for Varnish 43# Checks for Varnish
44PKG_CHECK_MODULES([VARNISHAPI], [varnishapi >= 4.0]) 44PKG_CHECK_MODULES([VARNISHAPI], [varnishapi >= 4.0])
45 45
46varnishapi_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
52v=$($PKG_CONFIG --modversion varnishapi)
53if test -n "$v"; then
54 save_IFS=$IFS
55 IFS='.'
56 varnishapi_version $v
57 IFS=$save_IFS
58fi
59
60AC_CHECK_VSC_C_MAIN_MEMBERS
61
46# Check for Net-SNMP 62# Check for Net-SNMP
47AC_PATH_PROG([NET_SNMP_CONFIG], net-snmp-config, none, $PATH) 63AC_PATH_PROG([NET_SNMP_CONFIG], net-snmp-config, none, $PATH)
48if test "$NET_SNMP_CONFIG" = "none"; then 64if 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)])
50fi 66fi
51AC_SUBST(NET_SNMP_CONFIG) 67AC_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
64struct betab_priv { 70struct 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.\"<