+#define SO_ACCEPTCON (1<<16) /* performed a listen */
+#define SO_WAITDATA (1<<17) /* wait data to read */
+#define SO_NOSPACE (1<<18) /* no space to write */
+
+#define ADDR_NORMAL_WIDTH 23
+/* When there are IPv6 connections the IPv6 addresses will be
+ * truncated to none-recognition. The '-W' option makes the
+ * address columns wide enough to accommodate for longest possible
+ * IPv6 addresses, i.e. addresses of the form
+ * xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:ddd.ddd.ddd.ddd
+ */
+#define ADDR_WIDE 51 /* INET6_ADDRSTRLEN + 5 for the port number */
+#if ENABLE_FEATURE_NETSTAT_WIDE
+# define FMT_NET_CONN_DATA "%s %6lu %6lu %-*s %-*s %-12s"
+# define FMT_NET_CONN_HEADER "\nProto Recv-Q Send-Q %-*s %-*s State %s\n"
+#else
+# define FMT_NET_CONN_DATA "%s %6lu %6lu %-23s %-23s %-12s"
+# define FMT_NET_CONN_HEADER "\nProto Recv-Q Send-Q %-23s %-23s State %s\n"
+#endif
+
+#define PROGNAME_WIDTH 20
+#define PROGNAME_WIDTH_STR "20"
+/* PROGNAME_WIDTH chars: 12345678901234567890 */
+#define PROGNAME_BANNER "PID/Program name "
+
+struct prg_node {
+ struct prg_node *next;
+ long inode;
+ char name[PROGNAME_WIDTH];
+};
+
+#define PRG_HASH_SIZE 211
+
+struct globals {
+ smallint flags;
+#if ENABLE_FEATURE_NETSTAT_PRG
+ smallint prg_cache_loaded;
+ struct prg_node *prg_hash[PRG_HASH_SIZE];
+#endif
+#if ENABLE_FEATURE_NETSTAT_PRG
+ const char *progname_banner;
+#endif
+#if ENABLE_FEATURE_NETSTAT_WIDE
+ unsigned addr_width;
+#endif
+};
+#define G (*ptr_to_globals)
+#define flags (G.flags )
+#define prg_cache_loaded (G.prg_cache_loaded)
+#define prg_hash (G.prg_hash )
+#if ENABLE_FEATURE_NETSTAT_PRG
+# define progname_banner (G.progname_banner )
+#else
+# define progname_banner ""
+#endif
+#define INIT_G() do { \
+ SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
+ flags = NETSTAT_CONNECTED | NETSTAT_ALLPROTO; \
+} while (0)
+
+
+#if ENABLE_FEATURE_NETSTAT_PRG
+
+/* Deliberately truncating long to unsigned *int* */
+#define PRG_HASHIT(x) ((unsigned)(x) % PRG_HASH_SIZE)