Changeset cf90d9f4e60f515ae835451b841ce4df92ca1a34

Show
Ignore:
Timestamp:
11/03/08 02:43:11 (4 years ago)
Author:
Neutron Soutmun <neo.neutron@…>
Children:
f51abe393259f4b3a94cea5d277c2dd5865696ee
Parents:
b1bb912de56607e397dd65f43cce29f66f79a172
git-author:
Neutron Soutmun <neo.neutron@…> (09/12/08 18:56:30)
git-committer:
Neutron Soutmun <neo.neutron@…> (11/03/08 02:43:11)
Message:

Add the tasks list concept

2008-09-12 Neutron Soutmun <neo.neutron@…>

  • +src/rh-task-*.{h,c}:
    • Add the tasks concept of the workers. eg. memset, ipset,
  • dbset and etc.
  • Each tasks provide the function to handle each events,

eg. init, start and stop service, start and stop session.

  • src/rahunas.{h,c}, src/rh-ipset.{h,c}, src/rh-utils.{h,c}, src/rh-xmlrpc-server.c: Change respectively to new tasks concept and do code beautifier.
  • +src/rh-config.h: Move the configuration definitions from rahunasd.h.
  • src/Makefile.am: Change respectively to properly build the tasks concept.
  • AUTHORS: Add Suriya Soutmun to the author team.
Files:
9 added
10 modified

Legend:

Unmodified
Added
Removed
  • AUTHORS

    r4d5414b rcf90d9f  
    11Neutron Soutmun <neo.neutron@gmail.com> 
     2Suriya Soutmun <darksolar@gmail.com> 
  • ChangeLog

    rb1bb912 rcf90d9f  
     12008-09-12  Neutron Soutmun <neo.neutron@gmail.com> 
     2 
     3        * +src/rh-task-*.{h,c}:  
     4                - Add the tasks concept of the workers. eg. memset, ipset, 
     5            dbset and etc.  
     6          - Each tasks provide the function to handle each events,  
     7                        eg. init, start and stop service, start and stop session. 
     8        * src/rahunas.{h,c}, src/rh-ipset.{h,c}, src/rh-utils.{h,c}, 
     9          src/rh-xmlrpc-server.c:  
     10          Change respectively to new tasks concept and do code beautifier.  
     11        * +src/rh-config.h: Move the configuration definitions from rahunasd.h. 
     12        * src/Makefile.am: Change respectively to properly build the tasks concept. 
     13        * AUTHORS: Add Suriya Soutmun to the author team. 
     14 
    1152008-09-03  Neutron Soutmun <neo.neutron@gmail.com> 
    216 
  • src/Makefile.am

    r2d4b30a rcf90d9f  
    1010        rh-xmlrpc-cmd.c \ 
    1111  rh-ipset.c \ 
    12         rh-utils.c 
     12        rh-utils.c \ 
     13        rh-task.c \ 
     14        rh-task-ipset.c \ 
     15        rh-task-memset.c 
    1316 
    1417rahunasd_LDADD =  \ 
  • src/rahunasd.c

    rb1bb912 rcf90d9f  
    1515#include <errno.h> 
    1616#include <unistd.h> 
    17 #include <time.h> 
    1817#include <signal.h> 
    1918#include <syslog.h> 
     
    2423#include "rh-ipset.h" 
    2524#include "rh-utils.h" 
     25#include "rh-task.h" 
    2626 
    2727/* Abstract functions */ 
    2828int logmsg(int priority, const char *msg, ...);  
    2929int getline(int fd, char *buf, size_t size); 
    30 int finish(); 
    31 int ipset_flush(); 
    32  
    33 struct rahunas_map* rh_init_map(); 
    34 int rh_init_members(struct rahunas_map *map); 
    35  
    36 int walk_through_set (int (*callback)(void *)); 
     30 
    3731size_t expired_check(void *data); 
    38 size_t nas_reboot(void *data); 
    3932 
    4033/* Declaration */ 
     
    163156    case SIGKILL: 
    164157      if (pid == 0) { 
    165         walk_through_set(&nas_reboot); 
    166158        rh_exit(); 
    167159        exit(EXIT_SUCCESS); 
     
    174166      break; 
    175167  } 
    176 } 
    177  
    178 int ipset_flush() 
    179 { 
    180   syslog(LOG_NOTICE, "Flushing IPSET..."); 
    181   set_flush(SET_NAME); 
    182 } 
    183  
    184 int finish() 
    185 { 
    186   char *exitmsg = "Exit Gracefully"; 
    187         struct rahunas_member *members = NULL; 
    188         int i; 
    189   int end; 
    190  
    191   if (map) { 
    192     if (map->members) { 
    193       members = map->members; 
    194       end = map->size; 
    195     } else { 
    196       end = 0; 
    197     }   
    198  
    199           for (i=0; i < end; i++) { 
    200                           rh_free_member(&members[i]); 
    201                 } 
    202  
    203                 rh_free(&(map->members)); 
    204                 rh_free(&map); 
    205         } 
    206  
    207   rh_free(&rahunas_set); 
    208         syslog(LOG_INFO, exitmsg); 
    209   return 0; 
    210168} 
    211169 
     
    233191} 
    234192 
    235 struct rahunas_map* rh_init_map() { 
    236   struct rahunas_map *map = NULL; 
    237  
    238         map = (struct rahunas_map*)(rh_malloc(sizeof(struct rahunas_map))); 
    239  
    240   map->members = NULL; 
    241         map->size = 0; 
    242  
    243         return map; 
    244 } 
    245  
    246 int rh_init_members (struct rahunas_map* map) 
    247 { 
    248         struct rahunas_member *members = NULL; 
    249         int size; 
    250  
    251   if (!map) 
    252           return (-1); 
    253          
    254         size = map->size == 0 ? MAX_MEMBERS : map->size; 
    255  
    256         members =  
    257     (struct rahunas_member*)(rh_malloc(sizeof(struct rahunas_member)*size)); 
    258  
    259         memset(members, 0, sizeof(struct rahunas_member)*size); 
    260  
    261         map->members = members; 
    262  
    263         return 0; 
    264 } 
    265  
    266193gboolean polling(gpointer data) { 
    267194  struct rahunas_map *map = (struct rahunas_map *)data; 
     
    278205  struct ip_set_rahunas *table = NULL; 
    279206  struct rahunas_member *members = map->members; 
     207  struct task_req req; 
    280208  unsigned int i; 
    281209  char *ip = NULL; 
    282   ip_set_ip_t current_ip; 
    283210  int res  = 0; 
    284211 
     
    289216  
    290217  for (i = 0; i < map->size; i++) { 
    291     if (test_bit(IPSET_RAHUNAS_ISSET, 
    292           (void *)&table[i].flags)) { 
    293       if ((time(NULL) - table[i].timestamp) > IDLE_THRESHOLD) { 
     218    if (test_bit(IPSET_RAHUNAS_ISSET, (void *)&table[i].flags) &&  
     219          (time(NULL) - table[i].timestamp) > IDLE_THRESHOLD) { 
    294220        DP("Found IP: %s expired", idtoip(map, i)); 
    295         current_ip = ntohl(map->first_ip) + i; 
    296         res = set_adtip_nb(rahunas_set, &current_ip, &table[i].ethernet, 
    297                            IP_SET_OP_DEL_IP);   
    298         DP("set_adtip_nb() res=%d errno=%d", res, errno); 
    299  
    300         if (res == 0) { 
    301                             send_xmlrpc_stopacct(map, i, RH_RADIUS_TERM_IDLE_TIMEOUT); 
    302  
    303           if (!members[i].username) 
    304             members[i].username = termstring; 
    305  
    306           if (!members[i].session_id) 
    307             members[i].session_id = termstring; 
    308  
    309           logmsg(RH_LOG_NORMAL, "Session Idle-Timeout, User: %s, IP: %s, " 
    310                                 "Session ID: %s, MAC: %s", 
    311                                 members[i].username,  
    312                                 idtoip(map, i),  
    313                                 members[i].session_id, 
    314                                 mac_tostring(members[i].mac_address));  
    315  
    316           rh_free_member(&members[i]); 
    317         } 
    318       }  
     221        req.id = i; 
     222        memcpy(req.mac_address, &table[i].ethernet, ETH_ALEN); 
     223        req.req_opt = RH_RADIUS_TERM_IDLE_TIMEOUT; 
     224                          send_xmlrpc_stopacct(map, i, RH_RADIUS_TERM_IDLE_TIMEOUT); 
     225        res = rh_task_stopsess(map, &req); 
    319226    } 
    320227  } 
    321228} 
    322229 
    323 size_t nas_reboot(void *data) 
    324 { 
    325   struct ip_set_list *setlist = (struct ip_set_list *) data; 
    326   struct set *set = set_list[setlist->index]; 
    327   size_t offset; 
    328   struct ip_set_rahunas *table = NULL; 
    329   struct rahunas_member *members = map->members; 
    330   unsigned int i; 
    331   char *ip = NULL; 
    332   ip_set_ip_t current_ip; 
    333   int res  = 0; 
    334  
    335   offset = sizeof(struct ip_set_list) + setlist->header_size; 
    336   table = (struct ip_set_rahunas *)(data + offset); 
    337  
    338   DP("Map size %d", map->size); 
    339   
    340   for (i = 0; i < map->size; i++) { 
    341     if (test_bit(IPSET_RAHUNAS_ISSET, (void *)&table[i].flags)) { 
    342       DP("Found IP: %s in set, try logout", idtoip(map, i)); 
    343       current_ip = ntohl(map->first_ip) + i; 
    344       res = set_adtip_nb(rahunas_set, &current_ip, &table[i].ethernet, 
    345                          IP_SET_OP_DEL_IP);   
    346       DP("set_adtip_nb() res=%d errno=%d", res, errno); 
    347  
    348       if (res == 0) { 
    349                             send_xmlrpc_stopacct(map, i, RH_RADIUS_TERM_NAS_REBOOT); 
    350  
    351         if (!members[i].username) 
    352           members[i].username = termstring; 
    353  
    354         if (!members[i].session_id) 
    355           members[i].session_id = termstring; 
    356  
    357         logmsg(RH_LOG_NORMAL, "Session Stop (NAS Reboot), User: %s, IP: %s, " 
    358                               "Session ID: %s, MAC: %s", 
    359                               members[i].username,  
    360                               idtoip(map, i),  
    361                               members[i].session_id, 
    362                               mac_tostring(members[i].mac_address));  
    363  
    364         rh_free_member(&members[i]); 
    365       } 
    366     } 
    367   } 
    368 } 
    369  
    370 int get_header_from_set () 
    371 { 
    372   struct ip_set_req_rahunas_create *header = NULL; 
    373   void *data = NULL; 
    374   ip_set_id_t idx; 
    375   socklen_t size, req_size; 
    376   size_t offset; 
    377   int res = 0; 
    378         in_addr_t first_ip; 
    379         in_addr_t last_ip; 
    380  
    381   size = req_size = load_set_list(SET_NAME, &idx,  
    382                                   IP_SET_OP_LIST_SIZE, CMD_LIST);  
    383  
    384   DP("Get Set Size: %d", size); 
    385    
    386   if (size) { 
    387     data = rh_malloc(size); 
    388     ((struct ip_set_req_list *) data)->op = IP_SET_OP_LIST; 
    389     ((struct ip_set_req_list *) data)->index = idx; 
    390     res = kernel_getfrom_handleerrno(data, &size); 
    391     DP("get_lists getsockopt() res=%d errno=%d", res, errno); 
    392  
    393     if (res != 0 || size != req_size) { 
    394       free(data); 
    395       return -EAGAIN; 
    396     } 
    397     size = 0; 
    398   } 
    399  
    400   offset = sizeof(struct ip_set_list); 
    401   header = (struct ip_set_req_rahunas_create *) (data + offset); 
    402  
    403   first_ip = htonl(header->from);  
    404   last_ip = htonl(header->to);  
    405    
    406   memcpy(&map->first_ip, &first_ip, sizeof(in_addr_t)); 
    407   memcpy(&map->last_ip, &last_ip, sizeof(in_addr_t)); 
    408         map->size = ntohl(map->last_ip) - ntohl(map->first_ip) + 1; 
    409  
    410         logmsg(RH_LOG_NORMAL, "First IP: %s", ip_tostring(ntohl(map->first_ip))); 
    411         logmsg(RH_LOG_NORMAL, "Last  IP: %s", ip_tostring(ntohl(map->last_ip))); 
    412         logmsg(RH_LOG_NORMAL, "Set Size: %lu", map->size); 
    413  
    414   rh_free(&data); 
    415   return res; 
    416 } 
    417  
    418 int walk_through_set (int (*callback)(void *)) 
    419 { 
    420   void *data = NULL; 
    421   ip_set_id_t idx; 
    422   socklen_t size, req_size; 
    423   int res = 0; 
    424  
    425   size = req_size = load_set_list(SET_NAME, &idx,  
    426                                   IP_SET_OP_LIST_SIZE, CMD_LIST);  
    427  
    428   DP("Get Set Size: %d", size); 
    429    
    430   if (size) { 
    431     data = rh_malloc(size); 
    432     ((struct ip_set_req_list *) data)->op = IP_SET_OP_LIST; 
    433     ((struct ip_set_req_list *) data)->index = idx; 
    434     res = kernel_getfrom_handleerrno(data, &size); 
    435     DP("get_lists getsockopt() res=%d errno=%d", res, errno); 
    436  
    437     if (res != 0 || size != req_size) { 
    438       free(data); 
    439       return -EAGAIN; 
    440     } 
    441     size = 0; 
    442   } 
    443    
    444   if (data != NULL) 
    445     (*callback)(data); 
    446  
    447   rh_free(&data); 
    448   return res; 
    449 } 
    450  
    451230void rh_exit() 
    452231{ 
    453232  syslog(LOG_ALERT, "Child Exiting .."); 
    454   ipset_flush(); 
    455   finish(); 
     233  rh_task_stopservice(map); 
     234  rh_task_cleanup(); 
    456235  rh_closelog(DEFAULT_LOG); 
    457236} 
     
    577356  dup2(fd_log, STDERR_FILENO); 
    578357 
     358  sprintf(version, "Starting %s - Version %s", PROGRAM, VERSION); 
     359        logmsg(RH_LOG_NORMAL, version); 
     360  syslog(LOG_INFO, version); 
     361 
     362  rh_task_init(); 
     363 
    579364  gnet_init(); 
    580365  main_loop = g_main_loop_new (NULL, FALSE); 
    581366 
    582   sprintf(version, "Starting %s - Version %s", PROGRAM, VERSION); 
    583  
    584    
    585         logmsg(RH_LOG_NORMAL, version); 
    586   syslog(LOG_INFO, version); 
    587  
    588   rahunas_set = set_adt_get(SET_NAME); 
    589   DP("getsetname: %s", rahunas_set->name); 
    590   DP("getsetid: %d", rahunas_set->id); 
    591   DP("getsetindex: %d", rahunas_set->index); 
    592  
    593   map = rh_init_map(); 
    594   get_header_from_set(); 
    595   rh_init_members(map); 
    596  
    597367  /* XML RPC Server */ 
    598368        server = gnet_xmlrpc_server_new (addr, port); 
     
    600370        if (!server) { 
    601371    syslog(LOG_ERR, "Could not start XML-RPC server!"); 
    602     ipset_flush(); 
    603     finish();  
     372    rh_task_stopservice(map); 
    604373          exit (EXIT_FAILURE); 
    605374        } 
     
    622391  g_timeout_add_seconds (POLLING, polling, map); 
    623392 
     393  rh_task_startservice(map); 
     394 
    624395        g_main_loop_run(main_loop); 
    625396 
  • src/rahunasd.h

    rb1bb912 rcf90d9f  
    88#define __RAHUNASD_H 
    99 
     10 
    1011#include <stdio.h> 
    1112#include <sys/socket.h> 
     
    1415#include <time.h> 
    1516#include <linux/if_ether.h> 
     17#include <errno.h> 
     18 
     19#include "rh-config.h" 
     20#include "rh-utils.h" 
    1621 
    1722#define PROGRAM "RahuNASd" 
     
    1924#define MAX_MEMBERS 0x00FFFF 
    2025 
    21 /* Configuration */ 
    22 #define DEFAULT_LOG "/var/log/rahunas/rahunas.log" 
    23 #define DEFAULT_PID "/var/run/rahunasd.pid" 
    24  
    25 #ifdef RH_DEBUG 
    26 #  define IDLE_THRESHOLD 30 
    27 #  define POLLING 15  
    28 #else 
    29 #  define IDLE_THRESHOLD 600 
    30 #  define POLLING 60  
    31 #endif 
    32  
    33 #define SET_NAME "rahunas_set" 
    34 #define XMLSERVICE_HOST "localhost" 
    35 #define XMLSERVICE_PORT 8888 
    36 #define XMLSERVICE_URL  "/xmlrpc_service.php" 
     26extern struct rahunas_map *map; 
     27extern struct set *rahunas_set; 
     28extern const char *termstring;  
    3729 
    3830enum RH_LOG { 
     
    7567void rh_free_member (struct rahunas_member *member); 
    7668 
    77 static char *timemsg() 
     69static const char *timemsg() 
    7870{ 
    7971  static char tmsg[32] = ""; 
  • src/rh-ipset.c

    r1268629 rcf90d9f  
    1212#include "rh-ipset.h" 
    1313#include "rh-utils.h" 
    14  
    15 extern struct set **set_list; 
    16 extern ip_set_id_t max_sets; 
    1714 
    1815int kernel_getsocket(void) 
     
    256253} 
    257254 
    258  
    259255void set_flush(const char *name) 
    260256{ 
     
    350346        return size; 
    351347} 
     348 
     349int get_header_from_set (struct rahunas_map *map) 
     350{ 
     351  struct ip_set_req_rahunas_create *header = NULL; 
     352  void *data = NULL; 
     353  ip_set_id_t idx; 
     354  socklen_t size, req_size; 
     355  size_t offset; 
     356  int res = 0; 
     357        in_addr_t first_ip; 
     358        in_addr_t last_ip; 
     359 
     360  size = req_size = load_set_list(SET_NAME, &idx,  
     361                                  IP_SET_OP_LIST_SIZE, CMD_LIST);  
     362 
     363  DP("Get Set Size: %d", size); 
     364   
     365  if (size) { 
     366    data = rh_malloc(size); 
     367    ((struct ip_set_req_list *) data)->op = IP_SET_OP_LIST; 
     368    ((struct ip_set_req_list *) data)->index = idx; 
     369    res = kernel_getfrom_handleerrno(data, &size); 
     370    DP("get_lists getsockopt() res=%d errno=%d", res, errno); 
     371 
     372    if (res != 0 || size != req_size) { 
     373      free(data); 
     374      return -EAGAIN; 
     375    } 
     376    size = 0; 
     377  } 
     378 
     379  offset = sizeof(struct ip_set_list); 
     380  header = (struct ip_set_req_rahunas_create *) (data + offset); 
     381 
     382  first_ip = htonl(header->from);  
     383  last_ip = htonl(header->to);  
     384   
     385  memcpy(&map->first_ip, &first_ip, sizeof(in_addr_t)); 
     386  memcpy(&map->last_ip, &last_ip, sizeof(in_addr_t)); 
     387        map->size = ntohl(map->last_ip) - ntohl(map->first_ip) + 1; 
     388 
     389        logmsg(RH_LOG_NORMAL, "First IP: %s", ip_tostring(ntohl(map->first_ip))); 
     390        logmsg(RH_LOG_NORMAL, "Last  IP: %s", ip_tostring(ntohl(map->last_ip))); 
     391        logmsg(RH_LOG_NORMAL, "Set Size: %lu", map->size); 
     392 
     393  rh_free(&data); 
     394  return res; 
     395} 
     396 
     397int walk_through_set (int (*callback)(void *)) 
     398{ 
     399  void *data = NULL; 
     400  ip_set_id_t idx; 
     401  socklen_t size, req_size; 
     402  int res = 0; 
     403 
     404  size = req_size = load_set_list(SET_NAME, &idx,  
     405                                  IP_SET_OP_LIST_SIZE, CMD_LIST);  
     406 
     407  DP("Get Set Size: %d", size); 
     408   
     409  if (size) { 
     410    data = rh_malloc(size); 
     411    ((struct ip_set_req_list *) data)->op = IP_SET_OP_LIST; 
     412    ((struct ip_set_req_list *) data)->index = idx; 
     413    res = kernel_getfrom_handleerrno(data, &size); 
     414    DP("get_lists getsockopt() res=%d errno=%d", res, errno); 
     415 
     416    if (res != 0 || size != req_size) { 
     417      free(data); 
     418      return -EAGAIN; 
     419    } 
     420    size = 0; 
     421  } 
     422   
     423  if (data != NULL) 
     424    (*callback)(data); 
     425 
     426  rh_free(&data); 
     427  return res; 
     428} 
  • src/rh-ipset.h

    r6f9f304 rcf90d9f  
    1515#define GETSOCK_TRIES 5 
    1616#define LIST_TRIES 5 
     17 
     18extern struct set **set_list; 
     19extern ip_set_id_t max_sets; 
    1720 
    1821/* The view of an ipset in userspace */ 
     
    8285                            unsigned op, unsigned cmd); 
    8386 
     87int get_header_from_set (struct rahunas_map *map); 
     88 
     89int walk_through_set (int (*callback)(void *)); 
     90 
    8491void parse_ip(const char *str, ip_set_ip_t *ip); 
    8592void parse_mac(const char *mac, unsigned char *ethernet); 
  • src/rh-utils.c

    r1268629 rcf90d9f  
    77#include <syslog.h> 
    88#include <glib.h> 
     9#include <time.h> 
    910 
    1011#include "rh-utils.h" 
  • src/rh-utils.h

    r9c2bbec rcf90d9f  
    1414const char *rh_string_get_sep(const char *haystack, const char *sep,  
    1515                              unsigned short idx); 
    16  
    1716#endif // __RH_UTILS_H 
  • src/rh-xmlrpc-server.c

    r5193352 rcf90d9f  
    22 * RahuNAS XML-RPC Server implementation 
    33 * Author: Neutron Soutmun <neo.neutron@gmail.com> 
     4 *         Suriya Soutmun <darksolar@gmail.com> 
    45 * Date:   2008-08-07 
    56 */ 
     
    910#include "rahunasd.h" 
    1011#include "rh-xmlrpc-server.h" 
     12#include "rh-radius.h" 
    1113#include "rh-ipset.h" 
    1214#include "rh-utils.h" 
    13  
    14 extern struct set *rahunas_set; 
     15#include "rh-task.h" 
     16 
    1517extern const char* termstring; 
    1618 
     
    2426        struct rahunas_member *members = NULL; 
    2527  unsigned char ethernet[ETH_ALEN] = {0,0,0,0,0,0}; 
     28  struct task_req req; 
    2629        gchar *ip = NULL; 
    2730        gchar *username = NULL; 
     
    2932  gchar *mac_address = NULL; 
    3033        uint32_t id; 
    31   int res = 0; 
    3234 
    3335        if (!map) 
     
    5860        } 
    5961 
    60   res = set_adtip(rahunas_set, ip, mac_address, IP_SET_OP_ADD_IP); 
    61   if (res == 0) { 
    62     members[id].flags = 1; 
    63     if (members[id].username && members[id].username != termstring) 
    64       free(members[id].username); 
    65  
    66     if (members[id].session_id && members[id].username != termstring) 
    67       free(members[id].session_id); 
    68  
    69     members[id].username   = strdup(username); 
    70     if (!members[id].username) 
    71       members[id].username = termstring; 
    72  
    73     members[id].session_id = strdup(session_id); 
    74     if (!members[id].session_id) 
    75       members[id].session_id = termstring; 
    76  
    77                 time(&(members[id].session_start)); 
    78  
    79     parse_mac(mac_address, &ethernet); 
    80     memcpy(&members[id].mac_address, &ethernet, ETH_ALEN); 
    81  
    82     logmsg(RH_LOG_NORMAL, "Session Start, User: %s, IP: %s, " 
    83                           "Session ID: %s, MAC: %s", 
    84                           members[id].username,  
    85                           idtoip(map, id),  
    86                           members[id].session_id, 
    87                           mac_tostring(members[id].mac_address));  
    88  
    89   } else if (res == RH_IS_IN_SET) { 
    90     members[id].flags = 1; 
    91   } 
     62  req.id = id; 
     63  req.username = username; 
     64  req.session_id = session_id; 
     65  parse_mac(mac_address, &ethernet); 
     66  memcpy(req.mac_address, &ethernet, ETH_ALEN); 
     67 
     68  rh_task_startsess(map, &req); 
    9269 
    9370  *reply_string = g_strdup_printf("Greeting! Got: IP %s, User %s, ID %s",  
     
    11693  struct rahunas_map *map = (struct rahunas_map *)user_data; 
    11794        struct rahunas_member *members; 
     95  struct task_req req; 
    11896        gchar *ip = NULL; 
    11997        gchar *mac_address = NULL; 
     
    148126        } 
    149127 
     128  req.id = id; 
     129  parse_mac(mac_address, &ethernet); 
     130  memcpy(req.mac_address, &ethernet, ETH_ALEN); 
     131  req.req_opt = RH_RADIUS_TERM_USER_REQUEST; 
     132 
    150133        if (members[id].flags) { 
    151     parse_mac(mac_address, &ethernet); 
    152134    if (memcmp(&ethernet, &members[id].mac_address, ETH_ALEN) == 0) { 
    153       res = set_adtip(rahunas_set, idtoip(map, id), mac_address, 
    154                       IP_SET_OP_DEL_IP); 
     135      res = rh_task_stopsess(map, &req); 
    155136      if (res == 0) { 
    156         if (!members[id].username) 
    157           members[id].username = termstring; 
    158  
    159         if (!members[id].session_id) 
    160           members[id].session_id = termstring; 
    161  
    162         logmsg(RH_LOG_NORMAL, "Session Stop, User: %s, IP: %s, " 
    163                               "Session ID: %s, MAC: %s", 
    164                               members[id].username,  
    165                               idtoip(map, id),  
    166                               members[id].session_id, 
    167                               mac_tostring(members[id].mac_address));  
    168  
    169         rh_free_member(&members[id]);    
    170   
    171137        *reply_string = g_strdup_printf("Client IP %s was removed!",  
    172138                                                          idtoip(map, id));