make log a conditional macro for _log
This commit is contained in:
parent
99be8b127a
commit
284e4dd546
6 changed files with 31 additions and 29 deletions
|
|
@ -23,12 +23,12 @@ int plugin_radius_response(struct param_radius_response *data)
|
||||||
if (*data->value) data->s->snoop_ip = inet_addr(data->value);
|
if (*data->value) data->s->snoop_ip = inet_addr(data->value);
|
||||||
if (data->s->snoop_ip == INADDR_NONE) data->s->snoop_ip = 0;
|
if (data->s->snoop_ip == INADDR_NONE) data->s->snoop_ip = 0;
|
||||||
if (*x) data->s->snoop_port = atoi(x);
|
if (*x) data->s->snoop_port = atoi(x);
|
||||||
p->log(3, 0, 0, 0, " Intercepting user to %s:%d\n",
|
p->_log(3, 0, 0, 0, " Intercepting user to %s:%d\n",
|
||||||
p->inet_toa(data->s->snoop_ip), data->s->snoop_port);
|
p->inet_toa(data->s->snoop_ip), data->s->snoop_port);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p->log(3, 0, 0, 0, " Not Intercepting user (reply string should be snoop=ip:port)\n");
|
p->_log(3, 0, 0, 0, " Not Intercepting user (reply string should be snoop=ip:port)\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return PLUGIN_RET_OK;
|
return PLUGIN_RET_OK;
|
||||||
|
|
|
||||||
|
|
@ -36,17 +36,17 @@ int plugin_radius_response(struct param_radius_response *data)
|
||||||
case 2: // output
|
case 2: // output
|
||||||
data->s->throttle_out = rate;
|
data->s->throttle_out = rate;
|
||||||
free(pt);
|
free(pt);
|
||||||
p->log(3, 0, p->get_id_by_session(data->s), data->s->tunnel, " Set output throttle rate %dkb/s\n", rate);
|
p->_log(3, 0, p->get_id_by_session(data->s), data->s->tunnel, " Set output throttle rate %dkb/s\n", rate);
|
||||||
return PLUGIN_RET_OK;
|
return PLUGIN_RET_OK;
|
||||||
|
|
||||||
case 3: //input
|
case 3: //input
|
||||||
data->s->throttle_in = rate;
|
data->s->throttle_in = rate;
|
||||||
free(pt);
|
free(pt);
|
||||||
p->log(3, 0, p->get_id_by_session(data->s), data->s->tunnel, " Set input throttle rate %dkb/s\n", rate);
|
p->_log(3, 0, p->get_id_by_session(data->s), data->s->tunnel, " Set input throttle rate %dkb/s\n", rate);
|
||||||
return PLUGIN_RET_OK;
|
return PLUGIN_RET_OK;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
p->log(1, 0, p->get_id_by_session(data->s), data->s->tunnel, "Syntax error in rate limit AV pair: %s=%s\n", data->key, data->value);
|
p->_log(1, 0, p->get_id_by_session(data->s), data->s->tunnel, "Syntax error in rate limit AV pair: %s=%s\n", data->key, data->value);
|
||||||
free(pt);
|
free(pt);
|
||||||
return PLUGIN_RET_OK;
|
return PLUGIN_RET_OK;
|
||||||
}
|
}
|
||||||
|
|
@ -54,7 +54,7 @@ int plugin_radius_response(struct param_radius_response *data)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
free(pt);
|
free(pt);
|
||||||
p->log(1, 0, p->get_id_by_session(data->s), data->s->tunnel, "Syntax error in rate limit AV pair: %s=%s\n",
|
p->_log(1, 0, p->get_id_by_session(data->s), data->s->tunnel, "Syntax error in rate limit AV pair: %s=%s\n",
|
||||||
data->key, data->value);
|
data->key, data->value);
|
||||||
return PLUGIN_RET_OK;
|
return PLUGIN_RET_OK;
|
||||||
}
|
}
|
||||||
|
|
@ -65,17 +65,17 @@ int plugin_radius_response(struct param_radius_response *data)
|
||||||
{
|
{
|
||||||
if (strcmp(data->value, "yes") == 0)
|
if (strcmp(data->value, "yes") == 0)
|
||||||
{
|
{
|
||||||
p->log(3, 0, p->get_id_by_session(data->s), data->s->tunnel, " Throttling user\n");
|
p->_log(3, 0, p->get_id_by_session(data->s), data->s->tunnel, " Throttling user\n");
|
||||||
data->s->throttle_in = data->s->throttle_out = config->rl_rate;
|
data->s->throttle_in = data->s->throttle_out = config->rl_rate;
|
||||||
}
|
}
|
||||||
else if (strcmp(data->value, "no") == 0)
|
else if (strcmp(data->value, "no") == 0)
|
||||||
{
|
{
|
||||||
p->log(3, 0, p->get_id_by_session(data->s), data->s->tunnel, " Not throttling user\n");
|
p->_log(3, 0, p->get_id_by_session(data->s), data->s->tunnel, " Not throttling user\n");
|
||||||
data->s->throttle_in = data->s->throttle_out = 0;
|
data->s->throttle_in = data->s->throttle_out = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p->log(4, 0, p->get_id_by_session(data->s), data->s->tunnel, "autothrottle module ignoring AV pair %s=%s\n",
|
p->_log(4, 0, p->get_id_by_session(data->s), data->s->tunnel, "autothrottle module ignoring AV pair %s=%s\n",
|
||||||
data->key, data->value);
|
data->key, data->value);
|
||||||
|
|
||||||
return PLUGIN_RET_OK;
|
return PLUGIN_RET_OK;
|
||||||
|
|
|
||||||
20
garden.c
20
garden.c
|
|
@ -7,7 +7,7 @@
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
#include "control.h"
|
#include "control.h"
|
||||||
|
|
||||||
char const *cvs_id = "$Id: garden.c,v 1.8 2004-10-30 07:35:31 bodea Exp $";
|
char const *cvs_id = "$Id: garden.c,v 1.9 2004-11-03 13:23:58 bodea Exp $";
|
||||||
|
|
||||||
int __plugin_api_version = 1;
|
int __plugin_api_version = 1;
|
||||||
static struct pluginfuncs *p = 0;
|
static struct pluginfuncs *p = 0;
|
||||||
|
|
@ -45,7 +45,7 @@ int plugin_post_auth(struct param_post_auth *data)
|
||||||
// Ignore if user authentication was successful
|
// Ignore if user authentication was successful
|
||||||
if (data->auth_allowed) return PLUGIN_RET_OK;
|
if (data->auth_allowed) return PLUGIN_RET_OK;
|
||||||
|
|
||||||
p->log(3, 0, 0, 0, "Walled Garden allowing login\n");
|
p->_log(3, 0, 0, 0, "Walled Garden allowing login\n");
|
||||||
data->auth_allowed = 1;
|
data->auth_allowed = 1;
|
||||||
data->s->walled_garden = 1;
|
data->s->walled_garden = 1;
|
||||||
return PLUGIN_RET_OK;
|
return PLUGIN_RET_OK;
|
||||||
|
|
@ -100,7 +100,7 @@ int plugin_control(struct param_control *data)
|
||||||
sprintf((data->response + data->response_length), "%s", errormsg);
|
sprintf((data->response + data->response_length), "%s", errormsg);
|
||||||
data->response_length += strlen(errormsg) + 1;
|
data->response_length += strlen(errormsg) + 1;
|
||||||
|
|
||||||
p->log(3, 0, 0, 0, "Unknown session %d\n", session);
|
p->_log(3, 0, 0, 0, "Unknown session %d\n", session);
|
||||||
return PLUGIN_RET_STOP;
|
return PLUGIN_RET_STOP;
|
||||||
}
|
}
|
||||||
*(short *)(data->response + 2) = ntohs(PKT_RESP_OK);
|
*(short *)(data->response + 2) = ntohs(PKT_RESP_OK);
|
||||||
|
|
@ -123,7 +123,7 @@ int plugin_become_master(void)
|
||||||
|
|
||||||
for (i = 0; up_commands[i] && *up_commands[i]; i++)
|
for (i = 0; up_commands[i] && *up_commands[i]; i++)
|
||||||
{
|
{
|
||||||
p->log(3, 0, 0, 0, "Running %s\n", up_commands[i]);
|
p->_log(3, 0, 0, 0, "Running %s\n", up_commands[i]);
|
||||||
system(up_commands[i]);
|
system(up_commands[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,9 +148,9 @@ int garden_session(sessiont *s, int flag)
|
||||||
|
|
||||||
if (flag == 1)
|
if (flag == 1)
|
||||||
{
|
{
|
||||||
p->log(2, 0, 0, s->tunnel, "Garden user %s (%s)\n", s->user, p->inet_toa(htonl(s->ip)));
|
p->_log(2, 0, 0, s->tunnel, "Garden user %s (%s)\n", s->user, p->inet_toa(htonl(s->ip)));
|
||||||
snprintf(cmd, sizeof(cmd), "iptables -t nat -A garden_users -s %s -j garden", p->inet_toa(htonl(s->ip)));
|
snprintf(cmd, sizeof(cmd), "iptables -t nat -A garden_users -s %s -j garden", p->inet_toa(htonl(s->ip)));
|
||||||
p->log(3, 0, 0, s->tunnel, "%s\n", cmd);
|
p->_log(3, 0, 0, s->tunnel, "%s\n", cmd);
|
||||||
system(cmd);
|
system(cmd);
|
||||||
s->walled_garden = 1;
|
s->walled_garden = 1;
|
||||||
}
|
}
|
||||||
|
|
@ -160,7 +160,7 @@ int garden_session(sessiont *s, int flag)
|
||||||
int count = 40;
|
int count = 40;
|
||||||
|
|
||||||
// Normal User
|
// Normal User
|
||||||
p->log(2, 0, 0, s->tunnel, "Un-Garden user %s (%s)\n", s->user, p->inet_toa(htonl(s->ip)));
|
p->_log(2, 0, 0, s->tunnel, "Un-Garden user %s (%s)\n", s->user, p->inet_toa(htonl(s->ip)));
|
||||||
// Kick off any duplicate usernames
|
// Kick off any duplicate usernames
|
||||||
// but make sure not to kick off ourself
|
// but make sure not to kick off ourself
|
||||||
if (s->ip && !s->die && (other = p->get_session_by_username(s->user)) && s != p->get_session_by_id(other)) {
|
if (s->ip && !s->die && (other = p->get_session_by_username(s->user)) && s != p->get_session_by_id(other)) {
|
||||||
|
|
@ -171,7 +171,7 @@ int garden_session(sessiont *s, int flag)
|
||||||
s->pin = s->pout = 0;
|
s->pin = s->pout = 0;
|
||||||
|
|
||||||
snprintf(cmd, sizeof(cmd), "iptables -t nat -D garden_users -s %s -j garden", p->inet_toa(htonl(s->ip)));
|
snprintf(cmd, sizeof(cmd), "iptables -t nat -D garden_users -s %s -j garden", p->inet_toa(htonl(s->ip)));
|
||||||
p->log(3, 0, 0, s->tunnel, "%s\n", cmd);
|
p->_log(3, 0, 0, s->tunnel, "%s\n", cmd);
|
||||||
while (--count)
|
while (--count)
|
||||||
{
|
{
|
||||||
int status = system(cmd);
|
int status = system(cmd);
|
||||||
|
|
@ -215,7 +215,7 @@ int plugin_init(struct pluginfuncs *funcs)
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; down_commands[i] && *down_commands[i]; i++)
|
for (i = 0; down_commands[i] && *down_commands[i]; i++)
|
||||||
{
|
{
|
||||||
p->log(3, 0, 0, 0, "Running %s\n", down_commands[i]);
|
p->_log(3, 0, 0, 0, "Running %s\n", down_commands[i]);
|
||||||
system(down_commands[i]);
|
system(down_commands[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -232,7 +232,7 @@ void plugin_done()
|
||||||
|
|
||||||
for (i = 0; down_commands[i] && *down_commands[i]; i++)
|
for (i = 0; down_commands[i] && *down_commands[i]; i++)
|
||||||
{
|
{
|
||||||
p->log(3, 0, 0, 0, "Running %s\n", down_commands[i]);
|
p->_log(3, 0, 0, 0, "Running %s\n", down_commands[i]);
|
||||||
system(down_commands[i]);
|
system(down_commands[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
6
l2tpns.c
6
l2tpns.c
|
|
@ -4,7 +4,7 @@
|
||||||
// Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced
|
// Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced
|
||||||
// vim: sw=8 ts=8
|
// vim: sw=8 ts=8
|
||||||
|
|
||||||
char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.38 2004-11-02 06:45:03 bodea Exp $";
|
char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.39 2004-11-03 13:23:58 bodea Exp $";
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
@ -239,7 +239,7 @@ void _log(int level, ipt address, sessionidt s, tunnelidt t, const char *format,
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _log_hex(int level, ipt address, sessionidt s, tunnelidt t, const char *title, const char *data, int maxsize)
|
void _log_hex(int level, const char *title, const char *data, int maxsize)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
const u8 *d = (const u8 *)data;
|
const u8 *d = (const u8 *)data;
|
||||||
|
|
@ -249,7 +249,7 @@ void _log_hex(int level, ipt address, sessionidt s, tunnelidt t, const char *tit
|
||||||
// No support for log_hex to syslog
|
// No support for log_hex to syslog
|
||||||
if (log_stream)
|
if (log_stream)
|
||||||
{
|
{
|
||||||
log(level, address, s, t, "%s (%d bytes):\n", title, maxsize);
|
_log(level, 0, 0, 0, "%s (%d bytes):\n", title, maxsize);
|
||||||
setvbuf(log_stream, NULL, _IOFBF, 16384);
|
setvbuf(log_stream, NULL, _IOFBF, 16384);
|
||||||
|
|
||||||
for (i = 0; i < maxsize; )
|
for (i = 0; i < maxsize; )
|
||||||
|
|
|
||||||
14
l2tpns.h
14
l2tpns.h
|
|
@ -1,5 +1,5 @@
|
||||||
// L2TPNS Global Stuff
|
// L2TPNS Global Stuff
|
||||||
// $Id: l2tpns.h,v 1.27 2004-11-02 23:43:52 bodea Exp $
|
// $Id: l2tpns.h,v 1.28 2004-11-03 13:23:59 bodea Exp $
|
||||||
|
|
||||||
#ifndef __L2TPNS_H__
|
#ifndef __L2TPNS_H__
|
||||||
#define __L2TPNS_H__
|
#define __L2TPNS_H__
|
||||||
|
|
@ -539,12 +539,14 @@ int cmd_show_ipcache(struct cli_def *cli, char *command, char **argv, int argc);
|
||||||
int cmd_show_hist_idle(struct cli_def *cli, char *command, char **argv, int argc);
|
int cmd_show_hist_idle(struct cli_def *cli, char *command, char **argv, int argc);
|
||||||
int cmd_show_hist_open(struct cli_def *cli, char *command, char **argv, int argc);
|
int cmd_show_hist_open(struct cli_def *cli, char *command, char **argv, int argc);
|
||||||
|
|
||||||
#define log _log
|
#undef log
|
||||||
#ifndef log_hex
|
#undef log_hex
|
||||||
#define log_hex(a,b,c,d) do{if (a <= config->debug) _log_hex(a,0,0,0,b,c,d);}while (0)
|
#define log(D, a, s, t, f, ...) ({ if (D <= config->debug) _log(D, a, s, t, f, ## __VA_ARGS__); })
|
||||||
#endif
|
#define log_hex(D, t, d, s) ({ if (D <= config->debug) _log_hex(D, t, d, s); })
|
||||||
|
|
||||||
void _log(int level, ipt address, sessionidt s, tunnelidt t, const char *format, ...) __attribute__((format (printf, 5, 6)));
|
void _log(int level, ipt address, sessionidt s, tunnelidt t, const char *format, ...) __attribute__((format (printf, 5, 6)));
|
||||||
void _log_hex(int level, ipt address, sessionidt s, tunnelidt t, const char *title, const char *data, int maxsize);
|
void _log_hex(int level, const char *title, const char *data, int maxsize);
|
||||||
|
|
||||||
void build_chap_response(char *challenge, u8 id, u16 challenge_length, char **challenge_response);
|
void build_chap_response(char *challenge, u8 id, u16 challenge_length, char **challenge_response);
|
||||||
int sessionsetup(tunnelidt t, sessionidt s);
|
int sessionsetup(tunnelidt t, sessionidt s);
|
||||||
int cluster_send_session(int s);
|
int cluster_send_session(int s);
|
||||||
|
|
|
||||||
2
plugin.h
2
plugin.h
|
|
@ -26,7 +26,7 @@ enum
|
||||||
struct pluginfuncs
|
struct pluginfuncs
|
||||||
{
|
{
|
||||||
void (*_log)(int level, ipt address, sessionidt s, tunnelidt t, const char *format, ...);
|
void (*_log)(int level, ipt address, sessionidt s, tunnelidt t, const char *format, ...);
|
||||||
void (*_log_hex)(int level, ipt address, sessionidt s, tunnelidt t, const char *title, const char *data, int maxsize);
|
void (*_log_hex)(int level, const char *title, const char *data, int maxsize);
|
||||||
char *(*inet_toa)(unsigned long addr);
|
char *(*inet_toa)(unsigned long addr);
|
||||||
sessionidt (*get_session_by_username)(char *username);
|
sessionidt (*get_session_by_username)(char *username);
|
||||||
sessiont *(*get_session_by_id)(sessionidt s);
|
sessiont *(*get_session_by_id)(sessionidt s);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue