diff options
Diffstat (limited to 'src/ban.c')
-rw-r--r-- | src/ban.c | 45 |
1 files changed, 4 insertions, 41 deletions
@@ -51,7 +51,7 @@ varnish_ban(netsnmp_agent_request_info *reqinfo, | |||
51 | } | 51 | } |
52 | memcpy(expr, requests->requestvb->val.string, len); | 52 | memcpy(expr, requests->requestvb->val.string, len); |
53 | expr[len] = 0; | 53 | expr[len] = 0; |
54 | DEBUGMSGTL(("varnish_ban", "setting ban %s\n", expr)); | 54 | DEBUGMSGTL(("varnish_mib:ban", "setting ban %s\n", expr)); |
55 | rc = vcli_connect(vsm, &conn); | 55 | rc = vcli_connect(vsm, &conn); |
56 | if (rc == SNMP_ERR_NOERROR) { | 56 | if (rc == SNMP_ERR_NOERROR) { |
57 | rc = send_ban_cmd(&conn, expr); | 57 | rc = send_ban_cmd(&conn, expr); |
@@ -61,43 +61,6 @@ varnish_ban(netsnmp_agent_request_info *reqinfo, | |||
61 | return rc ? SNMP_ERR_GENERR : SNMP_ERR_NOERROR; | 61 | return rc ? SNMP_ERR_GENERR : SNMP_ERR_NOERROR; |
62 | } | 62 | } |
63 | 63 | ||
64 | unsigned banTable_timeout = 60; | ||
65 | |||
66 | int | ||
67 | varnish_mib_timeout_parser(const char *token, char *line, unsigned *retval) | ||
68 | { | ||
69 | char *p; | ||
70 | unsigned long n = strtoul(line, &p, 10); | ||
71 | |||
72 | if (*p) { | ||
73 | if (isspace(*p)) { | ||
74 | while (*p && isspace(*p)) | ||
75 | ++p; | ||
76 | if (*p) { | ||
77 | config_perror("too many arguments"); | ||
78 | return 1; | ||
79 | } | ||
80 | } else { | ||
81 | config_perror("invalid timeout value"); | ||
82 | return 1; | ||
83 | } | ||
84 | } | ||
85 | |||
86 | if (n > UINT_MAX) { | ||
87 | config_perror("timeout value out of allowed range"); | ||
88 | return 1; | ||
89 | } | ||
90 | |||
91 | *retval = n; | ||
92 | return 0; | ||
93 | } | ||
94 | |||
95 | void | ||
96 | varnish_ban_table_timeout_parser(const char *token, char *line) | ||
97 | { | ||
98 | varnish_mib_timeout_parser(token, line, &banTable_timeout); | ||
99 | } | ||
100 | |||
101 | /* | 64 | /* |
102 | * create a new row in the table | 65 | * create a new row in the table |
103 | */ | 66 | */ |
@@ -156,7 +119,7 @@ banTable_load(netsnmp_cache *cache, void *vmagic) | |||
156 | if (!vsm) | 119 | if (!vsm) |
157 | return SNMP_ERR_GENERR; | 120 | return SNMP_ERR_GENERR; |
158 | 121 | ||
159 | DEBUGMSGTL(("varnish_ban", "reloading ban table\n")); | 122 | DEBUGMSGTL(("varnish_mib:ban", "reloading ban table\n")); |
160 | rc = vcli_connect(vsm, &conn); | 123 | rc = vcli_connect(vsm, &conn); |
161 | 124 | ||
162 | if (rc != SNMP_ERR_NOERROR) | 125 | if (rc != SNMP_ERR_NOERROR) |
@@ -266,7 +229,7 @@ banTable_load(netsnmp_cache *cache, void *vmagic) | |||
266 | p = q; | 229 | p = q; |
267 | } | 230 | } |
268 | vcli_disconnect(&conn); | 231 | vcli_disconnect(&conn); |
269 | DEBUGMSGTL(("varnish_ban", "loaded %ld ban entries\n", idx)); | 232 | DEBUGMSGTL(("varnish_mib:ban", "loaded %ld ban entries\n", idx)); |
270 | return 0; | 233 | return 0; |
271 | } | 234 | } |
272 | 235 | ||
@@ -276,7 +239,7 @@ banTable_free(netsnmp_cache *cache, void *vmagic) | |||
276 | netsnmp_tdata *table = (netsnmp_tdata *) vmagic; | 239 | netsnmp_tdata *table = (netsnmp_tdata *) vmagic; |
277 | netsnmp_tdata_row *row; | 240 | netsnmp_tdata_row *row; |
278 | 241 | ||
279 | DEBUGMSGTL(("varnish_ban", "freeing ban table\n")); | 242 | DEBUGMSGTL(("varnish_mib:ban", "freeing ban table\n")); |
280 | while ((row = netsnmp_tdata_row_first(table))) { | 243 | while ((row = netsnmp_tdata_row_first(table))) { |
281 | struct banTable_entry *entry = row->data; | 244 | struct banTable_entry *entry = row->data; |
282 | free(entry->banExpression); | 245 | free(entry->banExpression); |