Index: netflow1.c
===================================================================
RCS file: /var/cvs/softflowd/netflow1.c,v
retrieving revision 1.2
diff -u -p -r1.2 netflow1.c
--- netflow1.c	5 May 2005 03:31:42 -0000	1.2
+++ netflow1.c	5 Sep 2005 21:58:50 -0000
@@ -122,6 +122,7 @@ send_netflow_v1(struct FLOW **flows, int
 			    htonl(timeval_sub_ms(&flows[i]->flow_last,
 			    system_boot_time));
 			flw->protocol = flows[i]->protocol;
+			flw->tos = flows[i]->tos[0];
 			flw->tcp_flags = flows[i]->tcp_flags[0];
 			offset += sizeof(*flw);
 			j++;
@@ -143,6 +144,7 @@ send_netflow_v1(struct FLOW **flows, int
 			    htonl(timeval_sub_ms(&flows[i]->flow_last,
 			    system_boot_time));
 			flw->protocol = flows[i]->protocol;
+			flw->tos = flows[i]->tos[1];
 			flw->tcp_flags = flows[i]->tcp_flags[1];
 			offset += sizeof(*flw);
 			j++;
Index: netflow5.c
===================================================================
RCS file: /var/cvs/softflowd/netflow5.c,v
retrieving revision 1.3
diff -u -p -r1.3 netflow5.c
--- netflow5.c	5 May 2005 03:31:42 -0000	1.3
+++ netflow5.c	5 Sep 2005 21:58:50 -0000
@@ -123,6 +123,7 @@ send_netflow_v5(struct FLOW **flows, int
 			    system_boot_time));
 			flw->tcp_flags = flows[i]->tcp_flags[0];
 			flw->protocol = flows[i]->protocol;
+			flw->tos = flows[i]->tos[0];
 			offset += sizeof(*flw);
 			j++;
 			hdr->flows++;
@@ -144,6 +145,7 @@ send_netflow_v5(struct FLOW **flows, int
 			    system_boot_time));
 			flw->tcp_flags = flows[i]->tcp_flags[1];
 			flw->protocol = flows[i]->protocol;
+			flw->tos = flows[i]->tos[1];
 			offset += sizeof(*flw);
 			j++;
 			hdr->flows++;
Index: netflow9.c
===================================================================
RCS file: /var/cvs/softflowd/netflow9.c,v
retrieving revision 1.8
diff -u -p -r1.8 netflow9.c
--- netflow9.c	14 May 2005 06:47:46 -0000	1.8
+++ netflow9.c	5 Sep 2005 21:58:50 -0000
@@ -59,6 +59,7 @@ struct NF9_DATA_FLOWSET_HEADER {
 #define NF9_IN_PACKETS			2
 /* ... */
 #define NF9_IN_PROTOCOL			4
+#define NF9_SRC_TOS			5
 /* ... */
 #define NF9_TCP_FLAGS			6
 #define NF9_L4_SRC_PORT			7
@@ -76,7 +77,7 @@ struct NF9_DATA_FLOWSET_HEADER {
 #define NF9_IP_PROTOCOL_VERSION		60
 
 /* Stuff pertaining to the templates that softflowd uses */
-#define NF9_SOFTFLOWD_TEMPLATE_NRECORDS	11
+#define NF9_SOFTFLOWD_TEMPLATE_NRECORDS	12
 struct NF9_SOFTFLOWD_TEMPLATE {
 	struct NF9_TEMPLATE_FLOWSET_HEADER h;
 	struct NF9_TEMPLATE_FLOWSET_RECORD r[NF9_SOFTFLOWD_TEMPLATE_NRECORDS];
@@ -87,7 +88,7 @@ struct NF9_SOFTFLOWD_DATA_COMMON {
 	u_int32_t first_switched, last_switched;
 	u_int32_t bytes, packets;
 	u_int16_t src_port, dst_port;
-	u_int8_t protocol, tcp_flags, ipproto;
+	u_int8_t protocol, tos, tcp_flags, ipproto;
 } __packed;
 
 struct NF9_SOFTFLOWD_DATA_V4 {
@@ -137,10 +138,12 @@ nf9_init_template(void)
 	v4_template.r[7].length = htons(2);
 	v4_template.r[8].type = htons(NF9_IN_PROTOCOL);
 	v4_template.r[8].length = htons(1);
-	v4_template.r[9].type = htons(NF9_TCP_FLAGS);
+	v4_template.r[9].type = htons(NF9_SRC_TOS);
 	v4_template.r[9].length = htons(1);
-	v4_template.r[10].type = htons(NF9_IP_PROTOCOL_VERSION);
+	v4_template.r[10].type = htons(NF9_TCP_FLAGS);
 	v4_template.r[10].length = htons(1);
+	v4_template.r[11].type = htons(NF9_IP_PROTOCOL_VERSION);
+	v4_template.r[11].length = htons(1);
 
 	bzero(&v6_template, sizeof(v6_template));
 	v6_template.h.c.flowset_id = htons(0);
@@ -165,10 +168,12 @@ nf9_init_template(void)
 	v6_template.r[7].length = htons(2);
 	v6_template.r[8].type = htons(NF9_IN_PROTOCOL);
 	v6_template.r[8].length = htons(1);
-	v6_template.r[9].type = htons(NF9_TCP_FLAGS);
-	v6_template.r[9].length = htons(1);
-	v6_template.r[10].type = htons(NF9_IP_PROTOCOL_VERSION);
+	v4_template.r[9].type = htons(NF9_SRC_TOS);
+	v4_template.r[9].length = htons(1);
+	v6_template.r[10].type = htons(NF9_TCP_FLAGS);
 	v6_template.r[10].length = htons(1);
+	v6_template.r[11].type = htons(NF9_IP_PROTOCOL_VERSION);
+	v6_template.r[11].length = htons(1);
 }
 
 static int
@@ -220,6 +225,8 @@ nf_flow_to_flowset(const struct FLOW *fl
 	dc[0]->src_port = dc[1]->dst_port = flow->port[0];
 	dc[1]->src_port = dc[0]->dst_port = flow->port[1];
 	dc[0]->protocol = dc[1]->protocol = flow->protocol;
+	dc[0]->tos = flow->tos[0];
+	dc[1]->tos = flow->tos[1];
 	dc[0]->tcp_flags = flow->tcp_flags[0];
 	dc[1]->tcp_flags = flow->tcp_flags[1];
 
Index: softflowd.c
===================================================================
RCS file: /var/cvs/softflowd/softflowd.c,v
retrieving revision 1.83
diff -u -p -r1.83 softflowd.c
--- softflowd.c	14 May 2005 06:47:16 -0000	1.83
+++ softflowd.c	5 Sep 2005 21:58:50 -0000
@@ -331,6 +331,7 @@ ipv4_to_flowrec(struct FLOW *flow, const
 	flow->addr[ndx ^ 1].v4 = ip->ip_dst;
 	flow->protocol = ip->ip_p;
 	flow->octets[ndx] = len;
+	flow->tos[ndx] = ip->ip_tos;
 	flow->packets[ndx] = 1;
 
 	*isfrag = (ntohs(ip->ip_off) & (IP_OFFMASK|IP_MF)) ? 1 : 0;
@@ -369,6 +370,7 @@ ipv6_to_flowrec(struct FLOW *flow, const
 	flow->addr[ndx ^ 1].v6 = ip6->ip6_dst;
 	flow->octets[ndx] = len;
 	flow->packets[ndx] = 1;
+	flow->tos[ndx] = (ip6->ip6_vfc & ~IPV6_VERSION_MASK);
 
 	*isfrag = 0;
 	nxt = ip6->ip6_nxt;
@@ -555,9 +557,13 @@ process_packet(struct FLOWTRACK *ft, con
 			logit(LOG_DEBUG, "ADD FLOW %s", format_flow_brief(flow));
 	} else {
 		/* Update flow statistics */
+		if (flow->packets[0] == 0)
+			flow->tos[0] = tmp.tos[0];
 		flow->packets[0] += tmp.packets[0];
 		flow->octets[0] += tmp.octets[0];
 		flow->tcp_flags[0] |= tmp.tcp_flags[0];
+		if (flow->packets[1] == 0)
+			flow->tos[1] = tmp.tos[1];
 		flow->packets[1] += tmp.packets[1];
 		flow->octets[1] += tmp.octets[1];
 		flow->tcp_flags[1] |= tmp.tcp_flags[1];
Index: softflowd.h
===================================================================
RCS file: /var/cvs/softflowd/softflowd.h,v
retrieving revision 1.8
diff -u -p -r1.8 softflowd.h
--- softflowd.h	5 May 2005 03:31:42 -0000	1.8
+++ softflowd.h	5 Sep 2005 21:58:50 -0000
@@ -147,6 +147,7 @@ struct FLOW {
 	} addr[2];				/* Endpoint addresses */
 	u_int16_t port[2];			/* Endpoint ports */
 	u_int8_t tcp_flags[2];			/* Cumulative OR of flags */
+	u_int8_t tos[2];			/* ToS */
 	u_int8_t protocol;			/* Protocol */
 
 	/* Per-flow statistics (all in _host_ byte order) */
