diff options
author | Jakub Sławiński | 2004-10-12 00:07:33 +0200 |
---|---|---|
committer | Joshua Judson Rosen | 2014-07-17 21:14:58 +0200 |
commit | 8a5f0141a346ad4b94d09313a2ec9a52efa7cf59 (patch) | |
tree | 70af82a7af209cca2ecd6fb44388cf25dd9c785d /exmodule.c | |
parent | v0.5.4 (diff) | |
download | apf-8a5f0141a346ad4b94d09313a2ec9a52efa7cf59.tar.gz |
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
Diffstat (limited to 'exmodule.c')
-rw-r--r-- | exmodule.c | 37 |
1 files changed, 26 insertions, 11 deletions
@@ -18,10 +18,8 @@ * */ -/* This example module put IP of the connected user into a body of the message */ -#include <string.h> -/* 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 */ + } |