]> granicus.if.org Git - libnl/commitdiff
idiag: deprecate IDIAG_SS_* socket states
authorThomas Haller <thaller@redhat.com>
Mon, 24 Nov 2014 16:14:50 +0000 (17:14 +0100)
committerThomas Haller <thaller@redhat.com>
Mon, 24 Nov 2014 17:30:21 +0000 (18:30 +0100)
These values mirror TCP_* socket states from 'netinit/tcp.h'.
There is no good reason to expose a copy of those values.
User space should use the original values (if they care).
The only value that is actually useful is IDIAGNL_SS_ALL.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
include/netlink/idiag/idiagnl.h
lib/idiag/idiag.c
src/idiag-socket-details.c

index 9f3345a317e550d6646ce4b275d90d2b5f8ac827..3b3b57e6317902bba8558a8e7f7e4bfa16043d5f 100644 (file)
@@ -32,28 +32,39 @@ extern "C" {
 /**
  * Socket state identifiers
  * @ingroup idiag
+ * @deprecated: use instead the TCP_* defines from netinet/tcp.h.
  */
 enum {
-       IDIAG_SS_UNKNOWN,
-       IDIAG_SS_ESTABLISHED,
-       IDIAG_SS_SYN_SENT,
-       IDIAG_SS_SYN_RECV,
-       IDIAG_SS_FIN_WAIT1,
-       IDIAG_SS_FIN_WAIT2,
-       IDIAG_SS_TIME_WAIT,
-       IDIAG_SS_CLOSE,
-       IDIAG_SS_CLOSE_WAIT,
-       IDIAG_SS_LAST_ACK,
-       IDIAG_SS_LISTEN,
-       IDIAG_SS_CLOSING,
-       IDIAG_SS_MAX
+       IDIAG_SS_UNKNOWN           = 0,
+
+       IDIAG_SS_ESTABLISHED       = 1,  /* TCP_ESTABLISHED */
+       IDIAG_SS_SYN_SENT          = 2,  /* TCP_SYN_SENT */
+       IDIAG_SS_SYN_RECV          = 3,  /* TCP_SYN_RECV */
+       IDIAG_SS_FIN_WAIT1         = 4,  /* TCP_FIN_WAIT1 */
+       IDIAG_SS_FIN_WAIT2         = 5,  /* TCP_FIN_WAIT2 */
+       IDIAG_SS_TIME_WAIT         = 6,  /* TCP_TIME_WAIT */
+       IDIAG_SS_CLOSE             = 7,  /* TCP_CLOSE */
+       IDIAG_SS_CLOSE_WAIT        = 8,  /* TCP_CLOSE_WAIT */
+       IDIAG_SS_LAST_ACK          = 9,  /* TCP_LAST_ACK */
+       IDIAG_SS_LISTEN            = 10, /* TCP_LISTEN */
+       IDIAG_SS_CLOSING           = 11, /* TCP_CLOSING */
+
+       IDIAG_SS_MAX               = 12,
 };
 
 /**
  * Macro to represent all socket states.
  * @ingroup idiag
  */
-#define IDIAG_SS_ALL ((1<<IDIAG_SS_MAX)-1)
+#define IDIAGNL_SS_ALL (((1<<12)-1))
+
+/**
+ * Macro to represent all socket states.
+ * @ingroup idiag
+ * @deprecated
+ */
+#define IDIAG_SS_ALL  IDIAGNL_SS_ALL
+
 
 /**
  * Inet Diag extended attributes
index 216235253ec379717e34540d107b242bff3fe250..303ffea9d0ed51995a7d5efb2fdbe25fb751c4b0 100644 (file)
@@ -82,25 +82,22 @@ int idiagnl_send_simple(struct nl_sock *sk, int flags, uint8_t family,
  */
 
 static const struct trans_tbl idiag_states[] = {
-       __ADD(IDIAG_SS_UNKNOWN, unknown),
-       __ADD(IDIAG_SS_ESTABLISHED, established),
-       __ADD(IDIAG_SS_SYN_SENT, syn_sent),
-       __ADD(IDIAG_SS_SYN_RECV, syn_recv),
-       __ADD(IDIAG_SS_FIN_WAIT1, fin_wait),
-       __ADD(IDIAG_SS_FIN_WAIT2, fin_wait2),
-       __ADD(IDIAG_SS_TIME_WAIT, time_wait),
-       __ADD(IDIAG_SS_CLOSE, close),
-       __ADD(IDIAG_SS_CLOSE_WAIT, close_wait),
-       __ADD(IDIAG_SS_LAST_ACK, last_ack),
-       __ADD(IDIAG_SS_LISTEN, listen),
-       __ADD(IDIAG_SS_CLOSING, closing),
-       __ADD(IDIAG_SS_MAX, max),
-       { ((1<<IDIAG_SS_MAX)-1), "all" }
+       __ADD(TCP_ESTABLISHED, established),
+       __ADD(TCP_SYN_SENT, syn_sent),
+       __ADD(TCP_SYN_RECV, syn_recv),
+       __ADD(TCP_FIN_WAIT1, fin_wait),
+       __ADD(TCP_FIN_WAIT2, fin_wait2),
+       __ADD(TCP_TIME_WAIT, time_wait),
+       __ADD(TCP_CLOSE, close),
+       __ADD(TCP_CLOSE_WAIT, close_wait),
+       __ADD(TCP_LAST_ACK, last_ack),
+       __ADD(TCP_LISTEN, listen),
+       __ADD(TCP_CLOSING, closing),
 };
 
 /**
  * Convert inet diag socket states to strings.
- * @arg state    inetdiag socket state (e.g., IDIAG_SS_ESTABLISHED)
+ * @arg state    inetdiag socket state (e.g., TCP_ESTABLISHED)
  * @arg buf      output buffer which will hold string result
  * @arg len      length in bytes of the output buffer
  *
index 95686768728c50e726c1e4b97c40feb99f373ec3..17bcef23cd01bd3dbf0f6ca52ad112898b5f0673 100644 (file)
@@ -72,7 +72,7 @@ int main(int argc, char *argv[])
                }
        }
 
-       if ((err = idiagnl_msg_alloc_cache(sock, AF_INET, IDIAG_SS_ALL,
+       if ((err = idiagnl_msg_alloc_cache(sock, AF_INET, IDIAGNL_SS_ALL,
                                        &idiag_cache))) {
                nl_cli_fatal(err, "Unable to allocate idiag msg cache: %s",
                                nl_geterror(err));