From 8a5f0141a346ad4b94d09313a2ec9a52efa7cf59 Mon Sep 17 00:00:00 2001 From: Jakub Sławiński Date: Tue, 12 Oct 2004 00:07:33 +0200 Subject: v0.5.5 - Added: rsa key generation by afclient - Modified: afclient is now generating keys by default - Fixed: major bug in packet buffering - Added: 'timeout', 'clients' and 'usrpcli' options - Fixed: parsing 'users' option - Modified: module management routines - Added: module support for service's packet filtering - Fixed: few minor bugs in closing connection routines - Added: possibility to use several clients per realm - Modified: there is no need for 'users', 'timeout', 'clients', 'proto', 'usrpcli' and 'climode' options in config file when default values are acceptable --- exmodule.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'exmodule.c') diff --git a/exmodule.c b/exmodule.c index 133609c..09141c4 100644 --- a/exmodule.c +++ b/exmodule.c @@ -18,10 +18,8 @@ * */ -/* This example module put IP of the connected user into a body of the message */ -#include -/* There is no required headers for module to work. - * We just need string.h for memcpy and strlen functions. +/* This example module scan the message for specified string and perform + * appropriate action */ /* info @@ -32,7 +30,7 @@ char* info(void) { - return "An example module"; + return "Module tester v0.1"; } /* allow @@ -52,15 +50,32 @@ allow(char* host, char* port) * 0 - allow to transfer * 1 - drop the packet * 2 - drop the connection + * 3 - release the module + * 4 - drop the packet and release the module + * 5 - drop the connection and release the module */ int filter(char* host, unsigned char* message, int* length) { - int n; - n = strlen(host); - message[*length] = '|'; - memcpy(&message[*length+1], host, n); - *length += n+1; - return 0; /* allow to transfer */ + int i; + for (i = 0; i < *length; ++i) { + if ((message[i] == 'M') && (message[i+1] == '1')) { + return 1; /* ignored */ + } + if ((message[i] == 'M') && (message[i+1] == '2')) { + return 2; /* dropped */ + } + if ((message[i] == 'M') && (message[i+1] == '3')) { + return 3; /* release */ + } + if ((message[i] == 'M') && (message[i+1] == '4')) { + return 4; /* ignored + release */ + } + if ((message[i] == 'M') && (message[i+1] == '5')) { + return 5; /* dropped + release */ + } + } + return 0; /* allow to transfer */ + } -- cgit v1.1