about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-03-12 08:58:35 +0000
committerEric Wong <normalperson@yhbt.net>2011-03-12 08:58:35 +0000
commit562e2e243e69f128c47ceb59c5b1710fa35c7081 (patch)
tree1f20806f072d7892f5ad76ea57e1a2880137c4c8
parent8f12e060ce2a47f92b47d197f8daf7c094277bf3 (diff)
downloadraindrops-562e2e243e69f128c47ceb59c5b1710fa35c7081.tar.gz
-rw-r--r--ext/raindrops/linux_inet_diag.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/ext/raindrops/linux_inet_diag.c b/ext/raindrops/linux_inet_diag.c
index 160f90b..386b87c 100644
--- a/ext/raindrops/linux_inet_diag.c
+++ b/ext/raindrops/linux_inet_diag.c
@@ -83,6 +83,20 @@ static int st_free_data(st_data_t key, st_data_t value, st_data_t ignored)
         return ST_DELETE;
 }
 
+static int st_to_hash(st_data_t key, st_data_t value, VALUE hash)
+{
+        struct listen_stats *stats = (struct listen_stats *)value;
+
+        if (stats->listener_p) {
+                VALUE k = rb_str_new2((const char *)key);
+                VALUE v = rb_listen_stats(stats);
+
+                OBJ_FREEZE(k);
+                rb_hash_aset(hash, k, v);
+        }
+        return st_free_data(key, value, 0);
+}
+
 static struct listen_stats *stats_for(st_table *table, struct inet_diag_msg *r)
 {
         char *key, *port;
@@ -359,6 +373,24 @@ static void parse_addr(struct sockaddr_storage *inet, VALUE addr)
         freeaddrinfo(res);
 }
 
+/* generates inet_diag bytecode to match all addrs for a given family */
+static void gen_bytecode_all(struct iovec *iov, sa_family_t family)
+{
+        struct inet_diag_bc_op *op;
+        struct inet_diag_hostcond *cond;
+
+        /* iov_len was already set and base allocated in a parent function */
+        assert(iov->iov_len == OPLEN && iov->iov_base && "iov invalid");
+        op = iov->iov_base;
+        op->code = INET_DIAG_BC_S_COND;
+        op->yes = OPLEN;
+        op->no = sizeof(struct inet_diag_bc_op) + OPLEN;
+        cond = (struct inet_diag_hostcond *)(op + 1);
+        cond->family = family;
+        cond->port = -1;
+        cond->prefix_len = 0;
+}
+
 /* generates inet_diag bytecode to match a single addr */
 static void gen_bytecode(struct iovec *iov, struct sockaddr_storage *inet)
 {
@@ -460,38 +492,6 @@ static VALUE tcp_listener_stats(VALUE obj, VALUE addrs)
         return rv;
 }
 
-static int st_to_hash(st_data_t key, st_data_t value, VALUE hash)
-{
-        struct listen_stats *stats = (struct listen_stats *)value;
-
-        if (stats->listener_p) {
-                VALUE k = rb_str_new2((const char *)key);
-                VALUE v = rb_listen_stats(stats);
-
-                OBJ_FREEZE(k);
-                rb_hash_aset(hash, k, v);
-        }
-        return st_free_data(key, value, 0);
-}
-
-/* generates inet_diag bytecode to match all addrs for a given family */
-static void gen_bytecode_all(struct iovec *iov, sa_family_t family)
-{
-        struct inet_diag_bc_op *op;
-        struct inet_diag_hostcond *cond;
-
-        /* iov_len was already set and base allocated in a parent function */
-        assert(iov->iov_len == OPLEN && iov->iov_base && "iov invalid");
-        op = iov->iov_base;
-        op->code = INET_DIAG_BC_S_COND;
-        op->yes = OPLEN;
-        op->no = sizeof(struct inet_diag_bc_op) + OPLEN;
-        cond = (struct inet_diag_hostcond *)(op + 1);
-        cond->family = family;
-        cond->port = -1;
-        cond->prefix_len = 0;
-}
-
 static VALUE all_tcp_listener_stats(VALUE obj)
 {
         VALUE rv;