Print this page
dccp: complete netstack

@@ -191,21 +191,23 @@
 static void             ire_report(const mib_item_t *item);
 static void             tcp_report(const mib_item_t *item);
 static void             udp_report(const mib_item_t *item);
 static void             group_report(mib_item_t *item);
 static void             dce_report(mib_item_t *item);
+static void             sctp_report(const mib_item_t *item);
+static void             dccp_report(const mib_item_t *item);
 static void             print_ip_stats(mib2_ip_t *ip);
 static void             print_icmp_stats(mib2_icmp_t *icmp);
 static void             print_ip6_stats(mib2_ipv6IfStatsEntry_t *ip6);
 static void             print_icmp6_stats(mib2_ipv6IfIcmpEntry_t *icmp6);
 static void             print_sctp_stats(mib2_sctp_t *tcp);
 static void             print_tcp_stats(mib2_tcp_t *tcp);
 static void             print_udp_stats(mib2_udp_t *udp);
 static void             print_rawip_stats(mib2_rawip_t *rawip);
 static void             print_igmp_stats(struct igmpstat *igps);
 static void             print_mrt_stats(struct mrtstat *mrts);
-static void             sctp_report(const mib_item_t *item);
+static void             print_dccp_stats(mib2_dccp_t *dccp);
 static void             sum_ip6_stats(mib2_ipv6IfStatsEntry_t *ip6,
                             mib2_ipv6IfStatsEntry_t *sum6);
 static void             sum_icmp6_stats(mib2_ipv6IfIcmpEntry_t *icmp6,
                             mib2_ipv6IfIcmpEntry_t *sum6);
 static void             m_report(void);

@@ -282,10 +284,12 @@
 static int udpEntrySize;
 static int udp6EntrySize;
 static int sctpEntrySize;
 static int sctpLocalEntrySize;
 static int sctpRemoteEntrySize;
+static int dccpEntrySize;
+static int dccp6EntrySize;
 
 #define protocol_selected(p)    (proto == IPPROTO_MAX || proto == (p))
 
 /* Machinery used for -f (filter) option */
 enum { FK_AF = 0, FK_OUTIF, FK_DST, FK_FLAGS, NFILTERKEYS };

@@ -475,10 +479,12 @@
                         } else if (strcmp(optarg, "sctp") == 0) {
                                 proto = IPPROTO_SCTP;
                         } else if (strcmp(optarg, "raw") == 0 ||
                             strcmp(optarg, "rawip") == 0) {
                                 proto = IPPROTO_RAW;
+                        } else if (strcmp(optarg, "dccp") == 0) {
+                                proto = IPPROTO_DCCP;
                         } else {
                                 fatal(1, "%s: unknown protocol.\n", optarg);
                         }
                         break;
 

@@ -620,10 +626,12 @@
                                         udp_report(item);
                                 if (protocol_selected(IPPROTO_TCP))
                                         tcp_report(item);
                                 if (protocol_selected(IPPROTO_SCTP))
                                         sctp_report(item);
+                                if (protocol_selected(IPPROTO_DCCP))
+                                        dccp_report(item);
                         }
                         if (Iflag)
                                 if_report(item, ifname, Iflag_only, once_only);
                         if (Mflag)
                                 m_report();

@@ -1004,10 +1012,11 @@
                         case MIB2_ICMP6:
                         case MIB2_TCP:
                         case MIB2_UDP:
                         case MIB2_SCTP:
                         case EXPER_RAWIP:
+                        case MIB2_DCCP:
                                 nitems++;
                         }
         }
         tempp2 = NULL;
         if (nitems == 0) {

@@ -1450,10 +1459,14 @@
                                 MDIFF(d, s2, s1, sctpListenDrop);
                                 MDIFF(d, s2, s1, sctpInClosed);
                                 prevp = diffptr++;
                                 break;
                         }
+                        case MIB2_DCCP: {
+                                /* XXX:DCCP */
+                                break;
+                        }
                         case EXPER_RAWIP: {
                                 mib2_rawip_t *r2;
                                 mib2_rawip_t *r1;
                                 mib2_rawip_t *d;
 

@@ -1859,10 +1872,21 @@
                         sctpEntrySize = sctp->sctpEntrySize;
                         sctpLocalEntrySize = sctp->sctpLocalEntrySize;
                         sctpRemoteEntrySize = sctp->sctpRemoteEntrySize;
                         break;
                 }
+                case MIB2_DCCP: {
+                        mib2_dccp_t     *dccp = (mib2_dccp_t *)item->valp;
+
+                        dccpEntrySize = dccp->dccpConnTableSize;
+                        dccp6EntrySize = dccp->dccp6ConnTableSize;
+                        assert(IS_P2ALIGNED(dccpEntrySize,
+                            sizeof (mib2_dccpConnEntry_t *)));
+                        assert(IS_P2ALIGNED(dccp6EntrySize,
+                            sizeof (mib2_dccp6ConnEntry_t *)));
+                        break;
+                }
                 }
         } /* 'for' loop 1 ends */
 
         if (Xflag) {
                 (void) puts("mib_get_constants:");

@@ -1894,10 +1918,12 @@
                 (void) printf("\tudp6EntrySize %d\n", udp6EntrySize);
                 (void) printf("\tsctpEntrySize %d\n", sctpEntrySize);
                 (void) printf("\tsctpLocalEntrySize %d\n", sctpLocalEntrySize);
                 (void) printf("\tsctpRemoteEntrySize %d\n",
                     sctpRemoteEntrySize);
+                (void) printf("\tdccpEntrySize %d\n", dccpEntrySize);
+                (void) printf("\ttcp6EntrySize %d\n", dccp6EntrySize);
         }
 }
 
 
 /* ----------------------------- STAT_REPORT ------------------------------- */

@@ -5429,10 +5455,137 @@
         }
         if (attrs != NULL)
                 free(attrs);
 }
 
+/* ------------------------------ DCCP_REPORT------------------------------- */
+
+static const char dccp_hdr_v4[] =
+"\nDCCP: IPv4\n";
+static const char dccp_hdr_v4_compat[] =
+"\nDCCP\n";
+static const char dccp_hdr_v4_verbose[] =
+"Local/Remote Address Swind  Snext     Suna   Rwind  Rnext     Rack   "
+" Rto   Mss     State\n"
+"-------------------- ----- -------- -------- ----- -------- -------- "
+"----- ----- -----------\n";
+static const char dccp_hdr_v4_normal[] =
+"   Local Address        Remote Address    Swind Send-Q Rwind Recv-Q "
+"   State\n"
+"-------------------- -------------------- ----- ------ ----- ------ "
+"-----------\n";
+
+static const char dccp_hdr_v6[] =
+"\nDCCP: IPv6\n";
+static const char dccp_hdr_v6_verbose[] =
+"Local/Remote Address              Swind  Snext     Suna   Rwind  Rnext   "
+"  Rack    Rto   Mss    State      If\n"
+"--------------------------------- ----- -------- -------- ----- -------- "
+"-------- ----- ----- ----------- -----\n";
+static const char dccp_hdr_v6_normal[] =
+"   Local Address                     Remote Address                 "
+"Swind Send-Q Rwind Recv-Q   State      If\n"
+"--------------------------------- --------------------------------- "
+"----- ------ ----- ------ ----------- -----\n";
+
+static boolean_t dccp_report_item_v4(const mib2_dccpConnEntry_t *,
+    boolean_t, const mib2_transportMLPEntry_t *);
+static boolean_t dccp_report_item_v6(const mib2_dccp6ConnEntry_t *,
+    boolean_t, const mib2_transportMLPEntry_t *);
+
+static void
+dccp_report(const mib_item_t *item)
+{
+        mib2_dccpConnEntry_t            *dp;
+        mib2_transportMLPEntry_t        **v4_attrs;
+        mib2_transportMLPEntry_t        **v6_attrs;
+        mib2_transportMLPEntry_t        **v4a;
+        mib2_transportMLPEntry_t        **v6a;
+        mib2_transportMLPEntry_t        *aptr;
+        boolean_t                       print_hdr_once_v4 = B_TRUE;
+        boolean_t                       print_hdr_once_v6 = B_TRUE;
+        int                             jtemp = 0;
+
+        if (!protocol_selected(IPPROTO_DCCP)) {
+                return;
+        }
+
+        v4_attrs = family_selected(AF_INET) && RSECflag ?
+            gather_attrs(item, MIB2_DCCP, MIB2_DCCP_CONN, dccpEntrySize) :
+            NULL;
+        v6_attrs = family_selected(AF_INET6) && RSECflag ?
+            gather_attrs(item, MIB2_DCCP6, MIB2_DCCP6_CONN, dccp6EntrySize) :
+            NULL;
+
+        v4a = v4_attrs;
+        v6a = v6_attrs;
+        for (; item != NULL; item = item->next_item) {
+                if (Xflag) {
+                        (void) printf("\n--- Entry %d ---\n", ++jtemp);
+                        (void) printf("Group = %d, mib_id = %d, "
+                            "length = %d, valp = 0x%p\n",
+                            item->group, item->mib_id,
+                            item->length, item->valp);
+                }
+
+                if (item->group == MIB2_DCCP) {
+                        for (dp = (mib2_dccpConnEntry_t *)item->valp;
+                            (char *)dp < (char *)item->valp + item->length;
+                            dp = (mib2_dccpConnEntry_t *)((char *)dp +
+                            dccpEntrySize)) {
+                                aptr = v4a == NULL ? NULL : *v4a++;
+                                print_hdr_once_v4 = dccp_report_item_v4(dp,
+                                    print_hdr_once_v4, aptr);
+                        }
+                }
+        }
+
+        (void) fflush(stdout);
+
+        if (v4_attrs != NULL) {
+                free(v4_attrs);
+        }
+        if (v6_attrs != NULL) {
+                free(v6_attrs);
+        }
+}
+
+static boolean_t
+dccp_report_item_v4(const mib2_dccpConnEntry_t *dp, boolean_t first,
+    const mib2_transportMLPEntry_t *attr)
+{
+        char    lname[MAXHOSTNAMELEN + MAXHOSTNAMELEN + 1];
+        char    fname[MAXHOSTNAMELEN + MAXHOSTNAMELEN + 1];
+
+        if (first) {
+                (void) printf(v4compat ? dccp_hdr_v4_compat : dccp_hdr_v4);
+                (void) printf(Vflag ? dccp_hdr_v4_verbose : dccp_hdr_v4_normal);
+        }
+
+        (void) printf("%-20s %-20s %5u %6d %5u %6d %s\n",
+            pr_ap(dp->dccpConnLocalAddress,
+            dp->dccpConnLocalPort, "dccp", lname, sizeof (lname)),
+            pr_ap(dp->dccpConnRemAddress,
+            dp->dccpConnRemPort, "dccp", fname, sizeof (fname)),
+            0,
+            0,
+            0,
+            0,
+            0);
+
+        print_transport_label(attr);
+
+        return (B_FALSE);
+}
+
+static boolean_t
+dccp_report_item_v6(const mib2_dccp6ConnEntry_t *dp, boolean_t first,
+    const mib2_transportMLPEntry_t *attr)
+{
+        return (B_FALSE);
+}
+
 static char *
 plural(int n)
 {
         return (n != 1 ? "s" : "");
 }