PERFORCE change 165719 for review

Ana Kukec anchie at FreeBSD.org
Mon Jul 6 20:41:43 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=165719

Change 165719 by anchie at anchie_malimis on 2009/07/06 20:41:17

	Processing of received routing message containing NS/NA/Redirect.	

Affected files ...

.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/net.c#14 edit
.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/proto.c#6 edit

Differences ...

==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/net.c#14 (text+ko) ====

@@ -84,7 +84,7 @@
 static DEFINE_LIST_HEAD(ifaces);
 
 /* Data packet meta data */
-struct input_hook_packet_info {
+struct snd_packet_info {
 	struct snd_ifinfo *ifinfo;
 	int direction;
 };
@@ -135,22 +135,7 @@
         return (0);
 }
 
-#if 0
 void
-snd_dispatch_fds(fd_set *fds)
-{
-	struct snd_ifinfo *p;
-
-	list_for_each_entry(p, &ifaces, list) {
-		if (FD_ISSET(p->icmps, fds)) {
-			/* Reuse the code from
-			snd_recv_pkt() and snd_icmp_sock_read()		
-			*/
-		}
-}
-#endif
-
-void
 snd_put_buf(struct sbuff *b)
 {
 	sbuff_free(b);
@@ -196,29 +181,30 @@
 {
 	struct rt_msghdr *rtm;
 	struct if_announcemsghdr *ifan;
-	struct sbuff *b;
+	struct sbuff *b, *b1;
+	struct snd_packet_info *pi;
 	int n, ifidx = -1;
-	
+
 	if ((b = snd_get_buf()) == NULL) {
 		return;
 	}
 
-	applog(LOG_ERR, "sndsock prije read = %d", sndsock);
-	n = read(sndsock, b, sizeof(b));
+	pi = sbuff_data(b);
+
+	n = recv(sndsock, b->data, b->rem, 0);
 	if (n < 0) {
 		applog(LOG_ERR, "%s: read: %s", __FUNCTION__, strerror(errno));
 		goto done;
 	} else {
-		applog(LOG_ERR, "%s: %d bytes read on routing socket.", n, __FUNCTION__);
+		applog(LOG_ERR, "%s: %d bytes read on routing socket.", __FUNCTION__, n);
 	}
+
 	b->len = n;
 
-	rtm = (struct rt_msghdr *) b;
+	rtm = sbuff_data(b);
 	if (rtm->rtm_version != RTM_VERSION) {
 		applog(LOG_ERR, "%s: Unsupported routing message version.", __FUNCTION__);
 		goto done;
-	} else {
-		applog(LOG_ERR, "%s RTM_VERSION", __FUNCTION__);
 	}
 
 	switch (rtm->rtm_type) {
@@ -226,17 +212,23 @@
 		/* XXX: Do we need this? */
 		break;
 	case RTM_SND:
-		ifan = (struct if_announcemsghdr *) rtm;
+		ifan = sbuff_data(b);	
 		switch (ifan->ifan_what) {
 		case RTM_SND_IN:
+			applog(LOG_ERR, "RTM_SND_IN");
 			/* n = RTM hdr + m as passed to nd6_ns_input() */
 			b = (struct rt_msghdr *) &ifan[1];
 			/* ToDo: Extract ifidx. */
 			snd_recv_pkt(b, ifidx, SND_IN);		
 			break;
 		case RTM_SND_OUT:
-			/* n = RTM hdr + ip6_hdr + icmp6len == ND message (as sent to if_output()) */
-			b = (struct rt_msghdr *) &ifan[1];
+			applog(LOG_ERR, "RTM_SND_OUT");
+			/* n = RTM hdr + ip6_hdr + icmp6len */
+			if (sbuff_pull(b, sizeof (struct rt_msghdr)) == NULL) {
+				DBG(&dbg_snd, "invalid pkt (not enough for rtm hedaer");
+				goto done;
+			}
+
 			/* ToDo: Extract ifidx. */
 			snd_recv_pkt(b, ifidx, SND_OUT);
 			break;

==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/proto.c#6 (text+ko) ====

@@ -654,7 +654,9 @@
 }
 
 void
-/* snd_recv_pkt(struct sbuff *b, int ifidx, int in, void *pkt) */
+#if 0
+snd_recv_pkt(struct sbuff *b, int ifidx, int in, void *pkt)
+#endif
 snd_recv_pkt(struct sbuff *b, int ifidx, int in)
 {
 	int tlen, drop = 0;
@@ -664,19 +666,21 @@
 	enum snd_pkt_decision r;
 	void *start;
 	struct ip6_hdr *iph;
-/*
+
+#if 0
 	if (!snd_iface_ok_(ifidx)) {
 		return;
 	}
-*/
-/*
+#endif
+#if 0
 	if (!in)
 		if (sbuff_pull(b, sizeof (struct ether_header)) == NULL) {
 			DBG(&dbg_snd, "invalid pkt (not enough for ether header");
 			goto drop;
 		}
 	}
-*/
+#endif
+
 	start = sbuff_data(b);
 
 	DBG(&dbg, "%s", in ? "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" :
@@ -699,6 +703,7 @@
 		DBG(&dbg_snd, "pkt too small (ip6 hdr)");
 		goto drop;
 	}
+
 	pi->icmp = sbuff_data(b);
 	if (b->len < sizeof (*(pi->icmp))) {
 		DBG(&dbg_snd, "pkt too small (icmp6 hdr)");
@@ -796,6 +801,8 @@
 		return (-1);
 	}
 #endif
+	applog(LOG_ERR, "snd_proto_init");
+
 	if (snd_proto_nonce_init() < 0 ||
 	    snd_proto_timestamp_init() < 0) {
 		return (-1);


More information about the p4-projects mailing list