Use :retab to conver tab to 2 spaces
authorNeutron Soutmun <neo.neutron@gmail.com>
Wed, 3 Dec 2008 09:28:13 +0000 (16:28 +0700)
committerNeutron Soutmun <neo.neutron@gmail.com>
Wed, 3 Dec 2008 09:28:13 +0000 (16:28 +0700)
2008-12-03  Neutron Soutmun <neo.neutron@gmail.com>

* src/rahunasd.{c,h}, src/rh-config.h, src/rh-ipset.{c,h},
  src/rh-task-ipset.c, src/rh-task-memset.c, src/rh-task.h,
  src/rh-xmlrpc-cmd.c, src/rh-xmlrpc-server.{c,h}:
  Use :retab to convert tab to 2 spaces.

12 files changed:
ChangeLog
src/rahunasd.c
src/rahunasd.h
src/rh-config.h
src/rh-ipset.c
src/rh-ipset.h
src/rh-task-ipset.c
src/rh-task-memset.c
src/rh-task.h
src/rh-xmlrpc-cmd.c
src/rh-xmlrpc-server.c
src/rh-xmlrpc-server.h

index f07b2f6..69f3df4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-12-03  Neutron Soutmun <neo.neutron@gmail.com>
+
+       * src/rahunasd.{c,h}, src/rh-config.h, src/rh-ipset.{c,h}, 
+         src/rh-task-ipset.c, src/rh-task-memset.c, src/rh-task.h, 
+         src/rh-xmlrpc-cmd.c, src/rh-xmlrpc-server.{c,h}:
+         Use :retab to convert tab to 2 spaces.
+
 2008-12-01  Neutron Soutmun <neo.neutron@gmail.com>
 
        * example/firewall.sh.in:
index 9fe89ef..bda0ca5 100644 (file)
@@ -46,7 +46,7 @@ uint32_t iptoid(struct rahunas_map *map, const char *ip) {
   struct in_addr req_ip;
 
   if (!map || !ip)
-         return (-1);
+    return (-1);
 
   if (!(inet_aton(ip, &req_ip))) {
     DP("Could not convert IP: %s", ip);
@@ -54,10 +54,10 @@ uint32_t iptoid(struct rahunas_map *map, const char *ip) {
   }
 
   DP("Request IP: %s", ip);
-       
+  
   ret = ntohl(req_ip.s_addr) - ntohl(map->first_ip);
-       if (ret < 0 || ret > (map->size - 1))
-         ret = (-1);
+  if (ret < 0 || ret > (map->size - 1))
+    ret = (-1);
 
   DP("Request Index: %lu", ret);
   return ret; 
@@ -98,55 +98,55 @@ int rh_openlog(const char *filename)
 int rh_closelog(int fd)
 {
   if (close(fd) == 0)
-         return 1;
-       else
-         return 0;
+    return 1;
+  else
+    return 0;
 }
 
 int logmsg(int priority, const char *msg, ...) 
 {
   int n, size = 256;
-       va_list ap;
-       char *time_fmt = "%b %e %T";
-       char *p = NULL;
+  va_list ap;
+  char *time_fmt = "%b %e %T";
+  char *p = NULL;
   char *np = NULL;
 
-       if (priority < RH_LOG_LEVEL)
-         return 0;
+  if (priority < RH_LOG_LEVEL)
+    return 0;
 
-       if ((p = rh_malloc(size)) == NULL) {
-               return (-1);
-       }
+  if ((p = rh_malloc(size)) == NULL) {
+    return (-1);
+  }
 
-       while (1) {
+  while (1) {
     va_start(ap, msg);
-               n = vsnprintf(p, size, msg, ap);
-               va_end(ap);
+    n = vsnprintf(p, size, msg, ap);
+    va_end(ap);
 
-               if (n > -1 && n < size)
-                 break;
+    if (n > -1 && n < size)
+      break;
  
     if (n > -1)
-                 size = n+1;
-               else
-                 size *= 2;
+      size = n+1;
+    else
+      size *= 2;
 
-               if ((np = realloc(p, size)) == NULL) {
+    if ((np = realloc(p, size)) == NULL) {
       free(p);
       p = NULL;
-                       break;
-               } else {
+      break;
+    } else {
       p = np;
-               }
-       }
+    }
+  }
 
-       if (!p)
-         return (-1);
+  if (!p)
+    return (-1);
 
-       fprintf(stderr, "%s : %s\n", timemsg(), p);
+  fprintf(stderr, "%s : %s\n", timemsg(), p);
 
-       rh_free(&p);
-       rh_free(&np);
+  rh_free(&p);
+  rh_free(&np);
 }
 
 void rh_sighandler(int sig)
@@ -171,29 +171,29 @@ void rh_sighandler(int sig)
 int getline(int fd, char *buf, size_t size)
 {
   char cbuf;
-       char *current;
+  char *current;
 
   if (!buf || fd < 0)
     return 0;
 
-       current = buf;
+  current = buf;
 
   while (read(fd, &cbuf, 1) > 0) {
-         *current = cbuf;
-         if (cbuf == '\n') {
-                 *current = '\0';
-                 break;
-               } else if ((current - buf) < (size - 1)) {
-                 current++;
-         }
-       }
-
-       return (current - buf);
+    *current = cbuf;
+    if (cbuf == '\n') {
+      *current = '\0';
+      break;
+    } else if ((current - buf) < (size - 1)) {
+      current++;
+    }
+  }
+
+  return (current - buf);
 }
 
 gboolean polling(gpointer data) {
   struct rahunas_map *map = (struct rahunas_map *)data;
-       DP("%s", "Start polling!");
+  DP("%s", "Start polling!");
   walk_through_set(&expired_check);
   return TRUE;
 }
@@ -223,7 +223,7 @@ size_t expired_check(void *data)
         req.id = i;
         memcpy(req.mac_address, &table[i].ethernet, ETH_ALEN);
         req.req_opt = RH_RADIUS_TERM_IDLE_TIMEOUT;
-                         send_xmlrpc_stopacct(map, i, RH_RADIUS_TERM_IDLE_TIMEOUT);
+        send_xmlrpc_stopacct(map, i, RH_RADIUS_TERM_IDLE_TIMEOUT);
         res = rh_task_stopsess(map, &req);
       } else if (members[i].session_timeout != 0 && 
                    time(NULL) > members[i].session_timeout) {
@@ -232,7 +232,7 @@ size_t expired_check(void *data)
         req.id = i;
         memcpy(req.mac_address, &table[i].ethernet, ETH_ALEN);
         req.req_opt = RH_RADIUS_TERM_SESSION_TIMEOUT;
-                         send_xmlrpc_stopacct(map, i, RH_RADIUS_TERM_SESSION_TIMEOUT);
+        send_xmlrpc_stopacct(map, i, RH_RADIUS_TERM_SESSION_TIMEOUT);
         res = rh_task_stopsess(map, &req);
       }
     }
@@ -251,77 +251,76 @@ static void
 watch_child(char *argv[])
 {
   char *prog = NULL;
-       int failcount = 0;
-       time_t start;
-       time_t stop;
-       int status;
+  int failcount = 0;
+  time_t start;
+  time_t stop;
+  int status;
 
-       int nullfd;
+  int nullfd;
   int pidfd;
   
-       if (*(argv[0]) == '(')
-         return;
+  if (*(argv[0]) == '(')
+    return;
 
-
-  pid = fork();        
-       if (pid < 0) {
-         syslog(LOG_ALERT, "fork failed");
-               exit(EXIT_FAILURE);
-       } else if (pid > 0) {
-         /* parent */
+  pid = fork(); 
+  if (pid < 0) {
+    syslog(LOG_ALERT, "fork failed");
+    exit(EXIT_FAILURE);
+  } else if (pid > 0) {
+    /* parent */
     pidfd = open(DEFAULT_PID, O_WRONLY | O_TRUNC | O_CREAT);
     if (pidfd) {
       dup2(pidfd, STDOUT_FILENO);
       fprintf(stdout, "%d\n", pid);
       close(pidfd);
     }
-         exit(EXIT_SUCCESS);
-       }
+    exit(EXIT_SUCCESS);
+  }
 
   /* Change the file mode mask */
   umask(0);
 
-       if ((sid = setsid()) < 0)
-         syslog(LOG_ALERT, "setsid failed");
+  if ((sid = setsid()) < 0)
+    syslog(LOG_ALERT, "setsid failed");
 
-       if ((chdir("/")) < 0) {
+  if ((chdir("/")) < 0) {
     exit(EXIT_FAILURE);
   }
     
   /* Close out the standard file descriptors */
-       close(STDIN_FILENO);
-       close(STDOUT_FILENO);
-       close(STDERR_FILENO);
+  close(STDIN_FILENO);
+  close(STDOUT_FILENO);
+  close(STDERR_FILENO);
 
 
   while(1) {
 
-         if ((pid = fork()) == 0) {
+    if ((pid = fork()) == 0) {
       /* child */
       prog = strdup(argv[0]);
-           argv[0] = strdup("(rahunasd)");
-                 execvp(prog, argv);
-                 syslog(LOG_ALERT, "execvp failed");
-               }
+      argv[0] = strdup("(rahunasd)");
+      execvp(prog, argv);
+      syslog(LOG_ALERT, "execvp failed");
+    }
   
     syslog(LOG_NOTICE, "RahuNASd Parent: child process %d started", pid);   
 
     time(&start);
-         /* parent */
-       pid = waitpid(-1, &status, 0);
-       time(&stop);
-
-       if (WIFEXITED(status)) {
-         syslog(LOG_NOTICE,
-                        "RahuNASd Parent: child process %d exited with status %d",
-                                                pid, WEXITSTATUS(status));
-       } else if (WIFSIGNALED(status)) {
+    /* parent */
+    pid = waitpid(-1, &status, 0);
+    time(&stop);
+
+    if (WIFEXITED(status)) {
+      syslog(LOG_NOTICE,
+               "RahuNASd Parent: child process %d exited with status %d",
+               pid, WEXITSTATUS(status));
+    } else if (WIFSIGNALED(status)) {
       syslog(LOG_NOTICE,
-                        "RahuNASd Parent: child process %d exited due to signal %d",
-                                                pid, WTERMSIG(status));
-       } else {
+               "RahuNASd Parent: child process %d exited due to signal %d",
+               pid, WTERMSIG(status));
+    } else {
       syslog(LOG_NOTICE, "RahuNASd Parent: child process %d exited", pid);
-       }
+    }
   
     if (stop - start < 10)
       failcount++;
@@ -334,41 +333,41 @@ watch_child(char *argv[])
     }
   
   
-       if (WIFEXITED(status))
-         if (WEXITSTATUS(status) == 0)
-                 exit(EXIT_SUCCESS);
-       
-       sleep(3);
+    if (WIFEXITED(status))
+      if (WEXITSTATUS(status) == 0)
+        exit(EXIT_SUCCESS);
+    
+    sleep(3);
   }
 }
 
 int main(int argc, char **argv) 
 {
-       gchar* addr = "localhost";
-       int port    = 8123;
+  gchar* addr = "localhost";
+  int port    = 8123;
   int fd_log;
 
-       char line[256];
-       char version[256];
+  char line[256];
+  char version[256];
 
-       GNetXmlRpcServer *server = NULL;
-       GMainLoop* main_loop     = NULL;
+  GNetXmlRpcServer *server = NULL;
+  GMainLoop* main_loop     = NULL;
 
    
 
   signal(SIGTERM, rh_sighandler);
   signal(SIGKILL, rh_sighandler);
 
-       watch_child(argv);
+  watch_child(argv);
 
   /* Get configuration from config file */
   if (config_init(&rh_config) < 0) {
-         syslog(LOG_ERR, "Could not open config file %s", CONFIG_FILE);
+    syslog(LOG_ERR, "Could not open config file %s", CONFIG_FILE);
     exit(EXIT_FAILURE);
   }
 
   /* Open log file */
-       if ((fd_log = rh_openlog(rh_config.log_file)) < 0) {
+  if ((fd_log = rh_openlog(rh_config.log_file)) < 0) {
     syslog(LOG_ERR, "Could not open log file %s", rh_config.log_file);
     exit(EXIT_FAILURE);
   }
@@ -376,7 +375,7 @@ int main(int argc, char **argv)
   dup2(fd_log, STDERR_FILENO);
 
   sprintf(version, "Starting %s - Version %s", PROGRAM, RAHUNAS_VERSION);
-       logmsg(RH_LOG_NORMAL, version);
+  logmsg(RH_LOG_NORMAL, version);
   syslog(LOG_INFO, version);
 
   rh_task_init();
@@ -385,34 +384,34 @@ int main(int argc, char **argv)
   main_loop = g_main_loop_new (NULL, FALSE);
 
   /* XML RPC Server */
-       server = gnet_xmlrpc_server_new (addr, port);
+  server = gnet_xmlrpc_server_new (addr, port);
 
-       if (!server) {
+  if (!server) {
     syslog(LOG_ERR, "Could not start XML-RPC server!");
     rh_task_stopservice(map);
-         exit (EXIT_FAILURE);
-       }
+    exit (EXIT_FAILURE);
+  }
 
-       gnet_xmlrpc_server_register_command (server, 
-                                            "startsession", 
-                                                                                                                                          do_startsession, 
-                                                                                                                                                map);
+  gnet_xmlrpc_server_register_command (server, 
+                                       "startsession", 
+                                       do_startsession, 
+                                       map);
 
-       gnet_xmlrpc_server_register_command (server, 
-                                            "stopsession", 
-                                                                                                                                          do_stopsession, 
-                                                                                                                                                map);
+  gnet_xmlrpc_server_register_command (server, 
+                                       "stopsession", 
+                                       do_stopsession, 
+                                       map);
 
   gnet_xmlrpc_server_register_command (server, 
-                                            "getsessioninfo", 
-                                                                                                                                          do_getsessioninfo, 
-                                                                                                                                                map);
+                                       "getsessioninfo", 
+                                       do_getsessioninfo, 
+                                       map);
 
   g_timeout_add_seconds (rh_config.polling_interval, polling, map);
 
   rh_task_startservice(map);
 
-       g_main_loop_run(main_loop);
+  g_main_loop_run(main_loop);
 
-       exit(EXIT_SUCCESS);
+  exit(EXIT_SUCCESS);
 }
index 4322ce7..43b5354 100644 (file)
@@ -30,8 +30,8 @@ extern const char *termstring;
 
 enum RH_LOG {
   RH_LOG_DEBUG,
-       RH_LOG_NORMAL,
-       RH_LOG_ERROR
+  RH_LOG_NORMAL,
+  RH_LOG_ERROR
 };
 
 #define RH_LOG_LEVEL RH_LOG_NORMAL
@@ -48,20 +48,20 @@ enum RH_LOG {
 
 struct rahunas_map {
   struct rahunas_member *members;
-       in_addr_t first_ip;
-       in_addr_t last_ip;
-       unsigned int size;
+  in_addr_t first_ip;
+  in_addr_t last_ip;
+  unsigned int size;
 };
 
 struct rahunas_member {
   unsigned short flags; 
   unsigned short expired;
-       time_t session_start;
+  time_t session_start;
   time_t session_timeout;
   long bandwidth_max_down;
   long bandwidth_max_up;
   unsigned short bandwidth_slot_id;
-       char *username;
+  char *username;
   char *session_id;
   unsigned char mac_address[ETH_ALEN];
 };
index b09daa0..90ad9cd 100644 (file)
@@ -12,9 +12,9 @@
 #define IDLE_THRESHOLD 600
 #define POLLING 60 
 #define SET_NAME "rahunas_set"
-#define XMLSERVICE_HOST        "localhost"
-#define XMLSERVICE_PORT        8888
-#define XMLSERVICE_URL "/xmlrpc_service.php"
+#define XMLSERVICE_HOST "localhost"
+#define XMLSERVICE_PORT 8888
+#define XMLSERVICE_URL  "/xmlrpc_service.php"
 
 #define CONFIG_FILE RAHUNAS_CONF_DIR "rahunas.conf"
 #define DEFAULT_PID RAHUNAS_RUN_DIR "rahunasd.pid"
index 2f3d56b..9475f00 100644 (file)
@@ -221,30 +221,30 @@ int set_adtip_nb(struct set *rahunas_set, ip_set_ip_t *adtip,
            sizeof(struct ip_set_req_rahunas));
 
   if (kernel_sendto_handleerrno(op, data, size) == -1)
-               switch (op) {
-               case IP_SET_OP_ADD_IP:
-                 DP("%s:%s is already in set", ip_tostring(adtip), mac_tostring(adtmac));
+    switch (op) {
+    case IP_SET_OP_ADD_IP:
+      DP("%s:%s is already in set", ip_tostring(adtip), mac_tostring(adtmac));
       res = RH_IS_IN_SET;
-                       break;
-               case IP_SET_OP_DEL_IP:
+      break;
+    case IP_SET_OP_DEL_IP:
       DP("%s:%s is not in set", ip_tostring(adtip), mac_tostring(adtmac));
       res = RH_IS_NOT_IN_SET; 
-                       break;
-               case IP_SET_OP_TEST_IP:
+      break;
+    case IP_SET_OP_TEST_IP:
       DP("%s:%s is in set", ip_tostring(adtip), mac_tostring(adtmac));
       res = RH_IS_IN_SET;
-                       break;
-               default:
-                       break;
-               }
-       else
-               switch (op) {
-               case IP_SET_OP_TEST_IP:
+      break;
+    default:
+      break;
+    }
+  else
+    switch (op) {
+    case IP_SET_OP_TEST_IP:
       DP("%s:%s is not in set", ip_tostring(adtip), mac_tostring(adtmac));
       res = RH_IS_NOT_IN_SET;
-                       break;
-               default:
-                       break;   
+      break;
+    default:
+      break;   
     }
 
   rh_free(&data);
@@ -264,88 +264,88 @@ void set_flush(const char *name)
 }
 
 size_t load_set_list(const char name[IP_SET_MAXNAMELEN],
-                           ip_set_id_t *idx,
-                           unsigned op, unsigned cmd)
+          ip_set_id_t *idx,
+          unsigned op, unsigned cmd)
 {
-       void *data = NULL;
-       struct ip_set_req_max_sets req_max_sets;
-       struct ip_set_name_list *name_list;
-       struct set *set;
-       ip_set_id_t i;
-       socklen_t size, req_size;
-       int repeated = 0, res = 0;
-
-       DP("%s %s", cmd == CMD_MAX_SETS ? "MAX_SETS"
-                   : cmd == CMD_LIST_SIZE ? "LIST_SIZE"
-                   : "SAVE_SIZE",
-                   name);
-       
+  void *data = NULL;
+  struct ip_set_req_max_sets req_max_sets;
+  struct ip_set_name_list *name_list;
+  struct set *set;
+  ip_set_id_t i;
+  socklen_t size, req_size;
+  int repeated = 0, res = 0;
+
+  DP("%s %s", cmd == CMD_MAX_SETS ? "MAX_SETS"
+        : cmd == CMD_LIST_SIZE ? "LIST_SIZE"
+        : "SAVE_SIZE",
+        name);
+  
 tryagain:
-       if (set_list != NULL) {
-               for (i = 0; i < max_sets; i++)
-                       if (set_list[i] != NULL) {
-                               free(set_list[i]);
+  if (set_list != NULL) {
+    for (i = 0; i < max_sets; i++)
+      if (set_list[i] != NULL) {
+        free(set_list[i]);
         set_list[i] = NULL;
       }
-               free(set_list);
-               set_list = NULL;
-       }
-       /* Get max_sets */
-       req_max_sets.op = IP_SET_OP_MAX_SETS;
-       req_max_sets.version = IP_SET_PROTOCOL_VERSION;
-       strcpy(req_max_sets.set.name, name);
-       size = sizeof(req_max_sets);
-       kernel_getfrom(&req_max_sets, &size);
-
-       DP("got MAX_SETS: sets %d, max_sets %d",
-          req_max_sets.sets, req_max_sets.max_sets);
-
-       max_sets = req_max_sets.max_sets;
-       set_list = rh_malloc(max_sets * sizeof(struct set *));
-       memset(set_list, 0, max_sets * sizeof(struct set *));
-       *idx = req_max_sets.set.index;
-
-       if (req_max_sets.sets == 0)
-               /* No sets in kernel */
-               return 0;
-
-       /* Get setnames */
-       size = req_size = sizeof(struct ip_set_req_setnames) 
-                         + req_max_sets.sets * sizeof(struct ip_set_name_list);
-       data = rh_malloc(size);
-       ((struct ip_set_req_setnames *) data)->op = op;
-       ((struct ip_set_req_setnames *) data)->index = *idx;
-
-       res = kernel_getfrom_handleerrno(data, &size);
-
-       if (res != 0 || size != req_size) {
-               rh_free(&data);
-               if (repeated++ < LIST_TRIES)
-                       goto tryagain;
-
-               DP("Tried to get sets from kernel %d times"
-                          " and failed. Please try again when the load on"
-                          " the sets has gone down.", LIST_TRIES);
+    free(set_list);
+    set_list = NULL;
+  }
+  /* Get max_sets */
+  req_max_sets.op = IP_SET_OP_MAX_SETS;
+  req_max_sets.version = IP_SET_PROTOCOL_VERSION;
+  strcpy(req_max_sets.set.name, name);
+  size = sizeof(req_max_sets);
+  kernel_getfrom(&req_max_sets, &size);
+
+  DP("got MAX_SETS: sets %d, max_sets %d",
+     req_max_sets.sets, req_max_sets.max_sets);
+
+  max_sets = req_max_sets.max_sets;
+  set_list = rh_malloc(max_sets * sizeof(struct set *));
+  memset(set_list, 0, max_sets * sizeof(struct set *));
+  *idx = req_max_sets.set.index;
+
+  if (req_max_sets.sets == 0)
+    /* No sets in kernel */
+    return 0;
+
+  /* Get setnames */
+  size = req_size = sizeof(struct ip_set_req_setnames) 
+        + req_max_sets.sets * sizeof(struct ip_set_name_list);
+  data = rh_malloc(size);
+  ((struct ip_set_req_setnames *) data)->op = op;
+  ((struct ip_set_req_setnames *) data)->index = *idx;
+
+  res = kernel_getfrom_handleerrno(data, &size);
+
+  if (res != 0 || size != req_size) {
+    rh_free(&data);
+    if (repeated++ < LIST_TRIES)
+      goto tryagain;
+
+    DP("Tried to get sets from kernel %d times"
+         " and failed. Please try again when the load on"
+         " the sets has gone down.", LIST_TRIES);
     return -1;
-       }
-               
-       /* Load in setnames */
-       size = sizeof(struct ip_set_req_setnames);                      
-       while (size + sizeof(struct ip_set_name_list) <= req_size) {
-               name_list = (struct ip_set_name_list *)
-                       (data + size);
-               set = rh_malloc(sizeof(struct set));
-               strcpy(set->name, name_list->name);
-               set->index = name_list->index;
-               set->id = name_list->id;
-               set_list[name_list->index] = set;
-               size += sizeof(struct ip_set_name_list);
-       }
-       /* Size to get set members, bindings */
-       size = ((struct ip_set_req_setnames *)data)->size;
-       rh_free(&data);
-       
-       return size;
+  }
+    
+  /* Load in setnames */
+  size = sizeof(struct ip_set_req_setnames);      
+  while (size + sizeof(struct ip_set_name_list) <= req_size) {
+    name_list = (struct ip_set_name_list *)
+      (data + size);
+    set = rh_malloc(sizeof(struct set));
+    strcpy(set->name, name_list->name);
+    set->index = name_list->index;
+    set->id = name_list->id;
+    set_list[name_list->index] = set;
+    size += sizeof(struct ip_set_name_list);
+  }
+  /* Size to get set members, bindings */
+  size = ((struct ip_set_req_setnames *)data)->size;
+  rh_free(&data);
+  
+  return size;
 }
 
 int get_header_from_set (struct rahunas_map *map)
@@ -356,8 +356,8 @@ int get_header_from_set (struct rahunas_map *map)
   socklen_t size, req_size;
   size_t offset;
   int res = 0;
-       in_addr_t first_ip;
-       in_addr_t last_ip;
+  in_addr_t first_ip;
+  in_addr_t last_ip;
 
   size = req_size = load_set_list(rh_config.set_name, &idx, 
                                   IP_SET_OP_LIST_SIZE, CMD_LIST); 
@@ -386,11 +386,11 @@ int get_header_from_set (struct rahunas_map *map)
   
   memcpy(&map->first_ip, &first_ip, sizeof(in_addr_t));
   memcpy(&map->last_ip, &last_ip, sizeof(in_addr_t));
-       map->size = ntohl(map->last_ip) - ntohl(map->first_ip) + 1;
+  map->size = ntohl(map->last_ip) - ntohl(map->first_ip) + 1;
 
-       logmsg(RH_LOG_NORMAL, "First IP: %s", ip_tostring(ntohl(map->first_ip)));
-       logmsg(RH_LOG_NORMAL, "Last  IP: %s", ip_tostring(ntohl(map->last_ip)));
-       logmsg(RH_LOG_NORMAL, "Set Size: %lu", map->size);
+  logmsg(RH_LOG_NORMAL, "First IP: %s", ip_tostring(ntohl(map->first_ip)));
+  logmsg(RH_LOG_NORMAL, "Last  IP: %s", ip_tostring(ntohl(map->last_ip)));
+  logmsg(RH_LOG_NORMAL, "Set Size: %lu", map->size);
 
   rh_free(&data);
   return res;
index 301c277..9314573 100644 (file)
@@ -20,11 +20,11 @@ extern ip_set_id_t max_sets;
 
 /* The view of an ipset in userspace */
 struct set {
-       char name[IP_SET_MAXNAMELEN];           /* Name of the set */
-       ip_set_id_t id;                         /* Unique set id */
-       ip_set_id_t index;                      /* Array index */
-       unsigned ref;                           /* References in kernel */
-       struct settype *settype;                /* Pointer to set type functions */
+  char name[IP_SET_MAXNAMELEN];   /* Name of the set */
+  ip_set_id_t id;       /* Unique set id */
+  ip_set_id_t index;      /* Array index */
+  unsigned ref;       /* References in kernel */
+  struct settype *settype;    /* Pointer to set type functions */
 };
 
 enum rh_adt_result {
@@ -34,34 +34,34 @@ enum rh_adt_result {
 
 /* Commands */
 enum set_commands {
-       CMD_NONE,
-       CMD_CREATE,             /* -N */
-       CMD_DESTROY,            /* -X */
-       CMD_FLUSH,              /* -F */
-       CMD_RENAME,             /* -E */
-       CMD_SWAP,               /* -W */
-       CMD_LIST,               /* -L */
-       CMD_SAVE,               /* -S */
-       CMD_RESTORE,            /* -R */
-       CMD_ADD,                /* -A */
-       CMD_DEL,                /* -D */
-       CMD_TEST,               /* -T */
-       CMD_BIND,               /* -B */
-       CMD_UNBIND,             /* -U */
-       CMD_HELP,               /* -H */
-       CMD_VERSION,            /* -V */
-       NUMBER_OF_CMD = CMD_VERSION,
-       /* Internal commands */
-       CMD_MAX_SETS,
-       CMD_LIST_SIZE,
-       CMD_SAVE_SIZE,
-       CMD_ADT_GET,
+  CMD_NONE,
+  CMD_CREATE,   /* -N */
+  CMD_DESTROY,    /* -X */
+  CMD_FLUSH,    /* -F */
+  CMD_RENAME,   /* -E */
+  CMD_SWAP,   /* -W */
+  CMD_LIST,   /* -L */
+  CMD_SAVE,   /* -S */
+  CMD_RESTORE,    /* -R */
+  CMD_ADD,    /* -A */
+  CMD_DEL,    /* -D */
+  CMD_TEST,   /* -T */
+  CMD_BIND,   /* -B */
+  CMD_UNBIND,   /* -U */
+  CMD_HELP,   /* -H */
+  CMD_VERSION,    /* -V */
+  NUMBER_OF_CMD = CMD_VERSION,
+  /* Internal commands */
+  CMD_MAX_SETS,
+  CMD_LIST_SIZE,
+  CMD_SAVE_SIZE,
+  CMD_ADT_GET,
 };
 
 enum exittype {
-       OTHER_PROBLEM = 1,
-       PARAMETER_PROBLEM,
-       VERSION_PROBLEM
+  OTHER_PROBLEM = 1,
+  PARAMETER_PROBLEM,
+  VERSION_PROBLEM
 };
 
 int kernel_getsocket(void);
@@ -81,8 +81,8 @@ int set_adtip_nb(struct set *rahunas_set, ip_set_ip_t *adtip,
 void set_flush(const char *name);
 
 size_t load_set_list(const char name[IP_SET_MAXNAMELEN],
-                           ip_set_id_t *idx,
-                           unsigned op, unsigned cmd);
+          ip_set_id_t *idx,
+          unsigned op, unsigned cmd);
 
 int get_header_from_set (struct rahunas_map *map);
 
index 0455a35..cb32f6b 100644 (file)
@@ -35,7 +35,7 @@ size_t nas_stopservice(void *data)
       req.id = i;
       memcpy(req.mac_address, &table[i].ethernet, ETH_ALEN);
       req.req_opt = RH_RADIUS_TERM_NAS_REBOOT;
-                       send_xmlrpc_stopacct(map, i, RH_RADIUS_TERM_NAS_REBOOT);
+      send_xmlrpc_stopacct(map, i, RH_RADIUS_TERM_NAS_REBOOT);
       rh_task_stopsess(map, &req);
     }
   }
index 1a5fb1d..e63836a 100644 (file)
@@ -31,19 +31,19 @@ static void init (void)
 
   size = map->size == 0 ? MAX_MEMBERS : map->size;
 
-       members = 
+  members = 
     (struct rahunas_member*)(rh_malloc(sizeof(struct rahunas_member)*size));
 
-       memset(members, 0, sizeof(struct rahunas_member)*size);
+  memset(members, 0, sizeof(struct rahunas_member)*size);
 
-       map->members = members;
+  map->members = members;
 }
 
 /* Cleanup */
 static void cleanup (void)
 {
   struct rahunas_member *members = NULL;
-       int i;
+  int i;
   int end;
 
   logmsg(RH_LOG_NORMAL, "Task MEMSET cleanup..");  
@@ -56,13 +56,13 @@ static void cleanup (void)
       end = 0;
     }  
 
-         for (i=0; i < end; i++) {
-                         rh_free_member(&members[i]);
-               }
+    for (i=0; i < end; i++) {
+        rh_free_member(&members[i]);
+    }
 
-               rh_free(&(map->members));
-               rh_free(&map);
-       }
+    rh_free(&(map->members));
+    rh_free(&map);
+  }
 
   return 0;
 }
@@ -83,7 +83,7 @@ static int stopservice  (struct rahunas_map *map)
 /* Start session task */
 static int startsess (struct rahunas_map *map, struct task_req *req)
 {
-       struct rahunas_member *members = map->members;
+  struct rahunas_member *members = map->members;
   uint32_t id = req->id;
 
   members[id].flags = 1;
@@ -101,7 +101,7 @@ static int startsess (struct rahunas_map *map, struct task_req *req)
   if (!members[id].session_id)
     members[id].session_id = termstring;
 
-       time(&(members[id].session_start));
+  time(&(members[id].session_start));
   memcpy(&req->session_start, &members[id].session_start, sizeof(time_t));
 
   memcpy(&members[id].mac_address, &(req->mac_address), ETH_ALEN);
@@ -126,7 +126,7 @@ static int startsess (struct rahunas_map *map, struct task_req *req)
 /* Stop session task */
 static int stopsess  (struct rahunas_map *map, struct task_req *req)
 {
-       struct rahunas_member *members = map->members;
+  struct rahunas_member *members = map->members;
   uint32_t id = req->id;
   char cause[16] = "";
   switch (req->req_opt) {
index 4d15f61..1ad1d0a 100644 (file)
@@ -16,7 +16,7 @@ struct task_req {
   const char *username;
   const char *session_id;
   unsigned char mac_address[ETH_ALEN];
-       time_t session_start;
+  time_t session_start;
   time_t session_timeout;
   unsigned long bandwidth_max_down;
   unsigned long bandwidth_max_up;
index 556eadd..2057d31 100644 (file)
@@ -12,24 +12,24 @@ int send_xmlrpc_stopacct(struct rahunas_map *map, uint32_t id, int cause) {
   struct rahunas_member *members = NULL;
   GNetXmlRpcClient *client = NULL;
   gchar *reply  = NULL;
-       gchar *params = NULL;
+  gchar *params = NULL;
 
-       if (!map)
-         return (-1);
+  if (!map)
+    return (-1);
 
   if (!map->members)
     return (-1);
 
   if (id < 0 || id > (map->size - 1))
     return (-1);
-       
-       members = map->members;
+  
+  members = map->members;
 
-       params = g_strdup_printf("%s|%s|%s|%d|%s|%d", 
+  params = g_strdup_printf("%s|%s|%s|%d|%s|%d", 
                            idtoip(map, id),
-                                members[id].username,
-                                                                                                        members[id].session_id,
-                                                                                                        members[id].session_start,
+                           members[id].username,
+                           members[id].session_id,
+                           members[id].session_start,
                            mac_tostring(members[id].mac_address),
                            cause);
 
@@ -38,13 +38,13 @@ int send_xmlrpc_stopacct(struct rahunas_map *map, uint32_t id, int cause) {
 
   client = gnet_xmlrpc_client_new(rh_config.xml_serv_host, 
                                   rh_config.xml_serv_url, 
-                                       rh_config.xml_serv_port);
+                                  rh_config.xml_serv_port);
 
   if (!client) {
     logmsg(RH_LOG_ERROR, "Could not connect to XML-RPC service");
     return (-1);
   }
-       
+  
   if (gnet_xmlrpc_client_call(client, "stopacct", params, &reply) == 0)
     {
       DP("stopacct reply = %s", reply);
@@ -56,9 +56,9 @@ int send_xmlrpc_stopacct(struct rahunas_map *map, uint32_t id, int cause) {
       return (-1);
     }
 
-  gnet_xmlrpc_client_delete(client);   
+  gnet_xmlrpc_client_delete(client);  
 
-       g_free(params);
+  g_free(params);
 
   return 0;
 }
index f0dee5d..171be74 100644 (file)
@@ -18,25 +18,25 @@ extern const char* termstring;
 
 int do_startsession(GNetXmlRpcServer *server,
                     const gchar *command,
-                                                                               const gchar *param,
-                                                                               gpointer user_data,
-                                                                               gchar **reply_string) 
+                    const gchar *param,
+                    gpointer user_data,
+                    gchar **reply_string) 
 {
   struct rahunas_map *map = (struct rahunas_map *)user_data;
-       struct rahunas_member *members = NULL;
+  struct rahunas_member *members = NULL;
   unsigned char ethernet[ETH_ALEN] = {0,0,0,0,0,0};
   struct task_req req;
-       gchar *ip = NULL;
-       gchar *username = NULL;
-       gchar *session_id = NULL;
+  gchar *ip = NULL;
+  gchar *username = NULL;
+  gchar *session_id = NULL;
   gchar *mac_address = NULL;
   gchar *session_timeout = NULL;
   gchar *bandwidth_max_down = NULL;
   gchar *bandwidth_max_up = NULL;
-       uint32_t id;
+  uint32_t id;
 
-       if (!map)
-         goto out;
+  if (!map)
+    goto out;
 
   if (!map->members)
     goto out;
@@ -44,11 +44,11 @@ int do_startsession(GNetXmlRpcServer *server,
   if (param == NULL)
     goto out;
 
-       members = map->members;
+  members = map->members;
 
-       ip          = rh_string_get_sep(param, "|", 1);
-       username    = rh_string_get_sep(param, "|", 2);
-       session_id  = rh_string_get_sep(param, "|", 3);
+  ip          = rh_string_get_sep(param, "|", 1);
+  username    = rh_string_get_sep(param, "|", 2);
+  session_id  = rh_string_get_sep(param, "|", 3);
   mac_address = rh_string_get_sep(param, "|", 4);
   session_timeout    = rh_string_get_sep(param, "|", 5);
   bandwidth_max_down = rh_string_get_sep(param, "|", 6);
@@ -61,12 +61,12 @@ int do_startsession(GNetXmlRpcServer *server,
   if (mac_address == NULL)
     mac_address = g_strdup(DEFAULT_MAC);
 
-       id = iptoid(map, ip);
+  id = iptoid(map, ip);
 
-       if (id < 0) {
+  if (id < 0) {
     *reply_string = g_strdup("Invalid IP Address");
-               goto cleanup;
-       }
+    goto cleanup;
+  }
 
   req.id = id;
   req.username = username;
@@ -93,8 +93,8 @@ int do_startsession(GNetXmlRpcServer *server,
   rh_task_startsess(map, &req);
 
   *reply_string = g_strdup_printf("Greeting! Got: IP %s, User %s, ID %s", 
-                                        ip, members[id].username, 
-                                                                                                                                        members[id].session_id);
+                                   ip, members[id].username, 
+                                   members[id].session_id);
   goto cleanup;
 
 out:
@@ -114,29 +114,29 @@ cleanup:
 
 int do_stopsession(GNetXmlRpcServer *server,
                    const gchar *command,
-                                                                        const gchar *param,
-                                                                        gpointer user_data,
-                                                                        gchar **reply_string)
+                   const gchar *param,
+                   gpointer user_data,
+                   gchar **reply_string)
 {
   struct rahunas_map *map = (struct rahunas_map *)user_data;
-       struct rahunas_member *members;
+  struct rahunas_member *members;
   struct task_req req;
-       gchar *ip = NULL;
-       gchar *mac_address = NULL;
-       uint32_t   id;
+  gchar *ip = NULL;
+  gchar *mac_address = NULL;
+  uint32_t   id;
   int res = 0;
   unsigned char ethernet[ETH_ALEN] = {0,0,0,0,0,0};
 
-       if (!map)
-         goto out;
+  if (!map)
+    goto out;
 
   if (!map->members)
     goto out;
 
-       members = map->members;
+  members = map->members;
 
-       if (param == NULL)
-         goto out;
+  if (param == NULL)
+    goto out;
 
   DP("RPC Receive: %s", param);
 
@@ -149,17 +149,17 @@ int do_stopsession(GNetXmlRpcServer *server,
   if (mac_address == NULL)
     mac_address = g_strdup(DEFAULT_MAC);
 
-       id = iptoid(map, ip);
+  id = iptoid(map, ip);
 
-       if (id < 0) {
+  if (id < 0) {
     *reply_string = g_strdup("Invalid IP Address");
     goto cleanup;
-       }
+  }
 
   parse_mac(mac_address, &ethernet);
   memcpy(req.mac_address, &ethernet, ETH_ALEN);
 
-       if (members[id].flags) {
+  if (members[id].flags) {
     if (memcmp(&ethernet, &members[id].mac_address, ETH_ALEN) == 0) {
       req.id = id;
       req.req_opt = RH_RADIUS_TERM_USER_REQUEST;
@@ -167,13 +167,13 @@ int do_stopsession(GNetXmlRpcServer *server,
       res = rh_task_stopsess(map, &req);
       if (res == 0) {
         *reply_string = g_strdup_printf("Client IP %s was removed!", 
-                                                         idtoip(map, id));
+                                          idtoip(map, id));
       } else {
          *reply_string = g_strdup_printf("Client IP %s error remove!", 
-                                                       idtoip(map, id));
+                                        idtoip(map, id));
       }
       goto cleanup;
-               }       
+    } 
   }
 
   *reply_string = g_strdup_printf("%s", ip);
@@ -191,35 +191,35 @@ cleanup:
 
 int do_getsessioninfo(GNetXmlRpcServer *server,
                       const gchar *command,
-                                                                           const gchar *param,
-                                                                           gpointer user_data,
-                                                                           gchar **reply_string)
+                      const gchar *param,
+                      gpointer user_data,
+                      gchar **reply_string)
 {
   struct rahunas_map *map = (struct rahunas_map *)user_data;
-       struct rahunas_member *members = NULL;
-       gchar *ip = NULL;
-       uint32_t   id;
+  struct rahunas_member *members = NULL;
+  gchar *ip = NULL;
+  uint32_t   id;
 
-       if (!map)
-         goto out;
+  if (!map)
+    goto out;
 
   if (!map->members)
     goto out;
 
-       members = map->members;
+  members = map->members;
 
-       if (param == NULL)
-         goto out;
+  if (param == NULL)
+    goto out;
 
   ip = param;
-       id = iptoid(map, ip);
+  id = iptoid(map, ip);
 
-       if (id < 0) {
+  if (id < 0) {
     *reply_string = g_strdup("Invalid IP Address");
     return 0;
-       }
+  }
 
-       if (members[id].flags) {
+  if (members[id].flags) {
     if (!members[id].username) {
       *reply_string = g_strdup("Invalid Username");
       return 0;
@@ -232,18 +232,18 @@ int do_getsessioninfo(GNetXmlRpcServer *server,
     
     *reply_string = g_strdup_printf("%s|%s|%s|%d|%s|%d", 
                                       ip, 
-                                                 members[id].username,
-                                                                                                                                                 members[id].session_id,
-                                                                                                                                                 members[id].session_start,
+                                      members[id].username,
+                                      members[id].session_id,
+                                      members[id].session_start,
                                       mac_tostring(members[id].mac_address),
                                       members[id].session_timeout);
-               return 0;
-       }
+    return 0;
+  }
 
   *reply_string = g_strdup_printf("%s", ip);
-       return 0;
+  return 0;
 
 out:
     *reply_string = g_strdup("Invalid input parameters");
-               return 0;
+    return 0;
 }
index 77cc3fc..99da441 100644 (file)
 
 int do_startsession(GNetXmlRpcServer *server,
                     const gchar *command,
-                                                                               const gchar *param,
-                                                                               gpointer user_data,
-                                                                               gchar **reply_string);
+                    const gchar *param,
+                    gpointer user_data,
+                    gchar **reply_string);
 
 int do_stopsession(GNetXmlRpcServer *server,
                    const gchar *command,
-                                                                        const gchar *param,
-                                                                        gpointer user_data,
-                                                                        gchar **reply_string);
+                   const gchar *param,
+                   gpointer user_data,
+                   gchar **reply_string);
 
 int do_getsessioninfo(GNetXmlRpcServer *server,
                       const gchar *command,
-                                                                           const gchar *param,
-                                                                           gpointer user_data,
-                                                                           gchar **reply_string);
+                      const gchar *param,
+                      gpointer user_data,
+                      gchar **reply_string);
 
 #endif // __RH_XMLRPC_SERVER_H