--- old/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c	2012-07-09 14:38:05.648475791 +0000
+++ new/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c	2012-07-09 14:38:05.657270738 +0000
@@ -193,6 +193,8 @@
 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);
@@ -203,7 +205,7 @@
 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,
@@ -284,6 +286,8 @@
 static int sctpEntrySize;
 static int sctpLocalEntrySize;
 static int sctpRemoteEntrySize;
+static int dccpEntrySize;
+static int dccp6EntrySize;
 
 #define	protocol_selected(p)	(proto == IPPROTO_MAX || proto == (p))
 
@@ -477,6 +481,8 @@
 			} 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);
 			}
@@ -622,6 +628,8 @@
 					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);
@@ -1006,6 +1014,7 @@
 			case MIB2_UDP:
 			case MIB2_SCTP:
 			case EXPER_RAWIP:
+			case MIB2_DCCP:
 				nitems++;
 			}
 	}
@@ -1452,6 +1461,10 @@
 				prevp = diffptr++;
 				break;
 			}
+			case MIB2_DCCP: {
+				/* XXX:DCCP */
+				break;
+			}
 			case EXPER_RAWIP: {
 				mib2_rawip_t *r2;
 				mib2_rawip_t *r1;
@@ -1861,6 +1874,17 @@
 			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 */
 
@@ -1896,6 +1920,8 @@
 		(void) printf("\tsctpLocalEntrySize %d\n", sctpLocalEntrySize);
 		(void) printf("\tsctpRemoteEntrySize %d\n",
 		    sctpRemoteEntrySize);
+		(void) printf("\tdccpEntrySize %d\n", dccpEntrySize);
+		(void) printf("\ttcp6EntrySize %d\n", dccp6EntrySize);
 	}
 }
 
@@ -5431,6 +5457,133 @@
 		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)
 {
