summaryrefslogtreecommitdiffstats
path: root/plugin/firewall/eurephiafw.c
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2010-08-25 19:22:10 +0200
committerDavid Sommerseth <dazo@users.sourceforge.net>2010-08-25 19:22:10 +0200
commit787ce00e997d63a9ce1f1c16cf79b3ff1afd2588 (patch)
treee731032476121232987c68ff4a14345c363638b3 /plugin/firewall/eurephiafw.c
parentcbaf2c929a1c97cf9fb9c5a058f72c76a60edc52 (diff)
downloadeurephia-787ce00e997d63a9ce1f1c16cf79b3ff1afd2588.tar.gz
eurephia-787ce00e997d63a9ce1f1c16cf79b3ff1afd2588.tar.xz
eurephia-787ce00e997d63a9ce1f1c16cf79b3ff1afd2588.zip
Completed the needed changes for the new firewall plug-in API
Moved over the missing pieces to use the eFWupdateRequest struct. This is a continuation of the work started in commit bdd956adcccd91ff553278fd73cea7 Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
Diffstat (limited to 'plugin/firewall/eurephiafw.c')
-rw-r--r--plugin/firewall/eurephiafw.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/plugin/firewall/eurephiafw.c b/plugin/firewall/eurephiafw.c
index 8b24486..774fe21 100644
--- a/plugin/firewall/eurephiafw.c
+++ b/plugin/firewall/eurephiafw.c
@@ -265,11 +265,11 @@ void eFW_StartFirewall(eurephiaCTX *ctx) {
updreq.mode = fwINITIALISE;
strncpy(updreq.rule_destination, fwdest, 64);
mqres = mq_send((*ctx->fwcfg).thrdata.msgq,
- (const char *)&updreq, sizeof(eFWupdateRequest), 1);
- if( mqres < 1 ) {
+ (const char *)&updreq, EFW_MSG_SIZE, 1);
+ if( mqres < 0 ) {
eurephia_log(ctx, LOG_ERROR, 0,
- "Could not request firewall initialisation of the %s chain: %s",
- fwdest, strerror(errno));
+ "Could not request firewall initialisation of the %s chain: (%i) %s",
+ fwdest, mqres, strerror(errno));
};
if( ctx->fwcfg->fwblacklist != NULL ) {
@@ -282,16 +282,19 @@ void eFW_StartFirewall(eurephiaCTX *ctx) {
strncpy(updreq.rule_destination, ctx->fwcfg->fwblacklist, 64);
errno = 0;
mqres = mq_send((*ctx->fwcfg).thrdata.msgq,
- (const char *)&updreq, sizeof(eFWupdateRequest), 1);
- if( mqres < 1 ) {
- eurephia_log(ctx, LOG_ERROR, 0, "Could not request flushing of the %s chain: %s",
- ctx->fwcfg->fwblacklist, strerror(errno));
+ (const char *)&updreq, EFW_MSG_SIZE, 1);
+ if( mqres < 0 ) {
+ eurephia_log(ctx, LOG_ERROR, 0, "Could not request flushing of the %s chain: (%i) %s",
+ ctx->fwcfg->fwblacklist, mqres, strerror(errno));
};
// Registering already blacklisted IP addresses into the proper firewall chain
memset(&updreq, 0, sizeof(eFWupdateRequest));
updreq.mode = fwBLACKLIST;
blacklisted = eDBget_blacklisted_ip(ctx);
+ strncpy(updreq.rule_destination, ctx->fwcfg->fwblacklist, 64);
+ strncpy(updreq.goto_destination,
+ ctx->fwcfg->fwblacklist_sendto ? ctx->fwcfg->fwblacklist_sendto : "\0", 64);
p = blacklisted;
while( p != NULL ) {
if( p->val != NULL ) {
@@ -333,8 +336,8 @@ void eFW_StopFirewall(eurephiaCTX *ctx) {
errno = 0;
mqres = mq_send((*ctx->fwcfg).thrdata.msgq,
- (const char *)&updreq, sizeof(eFWupdateRequest), 1);
- if( mqres < 1 ) {
+ (const char *)&updreq, EFW_MSG_SIZE, 1);
+ if( mqres < 0 ) {
eurephia_log(ctx, LOG_CRITICAL, 0,
"Could not request firewall flushing of the %s chain: %s",
fwdest, strerror(errno));
@@ -350,7 +353,7 @@ void eFW_StopFirewall(eurephiaCTX *ctx) {
updreq.mode = fwSHUTDOWN;
errno = 0;
mqres = mq_send((*ctx->fwcfg).thrdata.msgq,
- (const char *)&updreq, sizeof(eFWupdateRequest), 1);
+ (const char *)&updreq, EFW_MSG_SIZE, 1);
if( mqres < 1 ) {
eurephia_log(ctx, LOG_PANIC, 0,
"Could not initiate shutdown on eFW module: %s", strerror(errno));
@@ -437,7 +440,7 @@ int eFW_UpdateFirewall(eurephiaCTX *ctx, eFWupdateRequest *request ) {
request->goto_destination);
errno = 0;
mqres = mq_send((*ctx->fwcfg).thrdata.msgq,
- (const char *)request, sizeof(eFWupdateRequest), prio);
+ (const char *)request, EFW_MSG_SIZE, prio);
if( mqres < 0 ) {
eurephia_log(ctx, LOG_CRITICAL, 0,
"eFW_updateFirewall: Failed to send update request - %s",
@@ -468,7 +471,7 @@ int eFW_UpdateFirewall(eurephiaCTX *ctx, eFWupdateRequest *request ) {
errno = 0;
mqres = mq_send((*ctx->fwcfg).thrdata.msgq,
- (const char *)request, sizeof(eFWupdateRequest), prio);
+ (const char *)request, EFW_MSG_SIZE, prio);
if( mqres < 0 ) {
eurephia_log(ctx, LOG_CRITICAL, 0,
"eFW_updateFirewall: Failed to send update request - %s",