[Bro] Patch for 1.3? Was: Type conversion and table initialization

Vern Paxson vern at icir.org
Fri Jul 13 00:36:33 PDT 2007


> Please try the appended and let me know if it works as you need.

Mike, per our off-line conversation, here's an updated patch.  Thanks
for your help with this.

		Vern


Index: src/bro.bif
===================================================================
--- src/bro.bif	(revision 4618)
+++ src/bro.bif	(working copy)
@@ -496,6 +496,23 @@
 	return ret;
 	%}
 
+# Interprets the first 4 bytes of 'b' as an IPv4 address in network order.
+function raw_bytes_to_v4_addr%(b: string%): addr
+	%{
+	uint32 a = 0;
+
+	if ( b->Len() < 4 )
+		builtin_run_time("too short a string as input to raw_bytes_to_v4_addr()");
+
+	else
+		{
+		const u_char* bp = b->Bytes();
+		a = (bp[0] << 24) | (bp[1] << 16) | (bp[2] << 8) | bp[3];
+		}
+
+	return new AddrVal(htonl(a));
+	%}
+
 function to_net%(a: addr%): net
 	%{
 #ifdef BROv6



More information about the Bro mailing list