Added netutils; update for changed paths
diff --git a/src/python/oftest/controller/controller.py b/src/python/oftest/controller/controller.py
index 1526cee..a0519ea 100644
--- a/src/python/oftest/controller/controller.py
+++ b/src/python/oftest/controller/controller.py
@@ -19,7 +19,7 @@
 """
 
 import sys
-sys.path.append("../ofmsg")
+sys.path.append("../protocol")
 import os
 import socket
 import time
@@ -27,6 +27,8 @@
 from threading import Thread
 from threading import Lock
 from message import *
+from parse import *
+from netutils import *
 
 class Controller(Thread):
     """
@@ -42,10 +44,10 @@
     byte order.
     """
 
-    def __init__(port=6633, passive=1):
+    def __init__(host=HOST_DEFAULT, port=PORT_DEFAULT, passive=1):
         if (passive):
             # FIXME: add error handling
-            self.sock = open_ctrlsocket()
+            self.sock = open_ctrlsocket(host, port)
             self.clientsock, self.clientaddr = self.sock.accept()
         else:
             print "Error in controller init: Active cxn not supported"
@@ -62,7 +64,7 @@
         """
         print "Controller message handler registration not supported"
 
-    def poll(self, exp_msg=None, timeout=None):
+    def poll(self, exp_msg=None, timeout=RCV_TIMEOUT_DEFAULT):
         """
         Wait for the next OF message received from the switch.
 
@@ -88,26 +90,35 @@
                 # FIXME: Check for error
                 return None, None
             # Convert msg to the proper OpenFlow message object
-            msg_type, msg = ofpkt.pkt_to_msg(pkt)
-            print "DEBUG: Got msg type %d of len %d" % (msg_type, len(msg))
+            hdr = of_header_parse(pkt)
+            print "DEBUG: msg in. pkt len %d. type %d. length %d" % \
+                (len(pkt), hdr.type, hdr.length)
 
             if not exp_msg or (exp_msg and (hdr.type == exp_msg)):
                 return msg_type, msg
 
-    def flow_install(self, flow):
+    def transact(self, msg, xid=None):
         """
-        Install the flow indicated through the control interface
-        TBD:  We may just use message_send below with ofp_flow_mod objects
-        @param flow The ofp_flow_mod object to install
+        Run a transaction
+
+        Send the message in msg and wait for a reply with a matching
+        transaction id.
+
+        @param msg The message to send
+        @param xid If non None, set the transaction ID of the message; 
+        otherwise use the one already present in the message's header.
+
         """
+        print "Controller transact not supported"
 
     def message_send(self, msg):
         """
         Send the message to the switch
-        @param msg An OpenFlow message object (from a SWIG generated
-        class) to be forwarded to the switch.  The data members of the
-        object must be in host endian order when pased to message_send.
+
+        @param msg An OpenFlow message object to be forwarded to the switch.  
+
         """
+        pass
 
     def kill(self):
         self.clientsock.close()
diff --git a/src/python/oftest/controller/netutils.py b/src/python/oftest/controller/netutils.py
new file mode 100644
index 0000000..aed1f2b
--- /dev/null
+++ b/src/python/oftest/controller/netutils.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+
+"""
+Network utilities for the OpenFlow controller
+"""
+
+import socket
+
+RCV_TIMEOUT_DEFAULT = 10
+HOST_DEFAULT = ''
+PORT_DEFAULT = 6633
+RCV_SIZE_DEFAULT = 4096
+
+def rcv_data_from_socket(sock, timeout=RCV_TIMEOUT_DEFAULT):
+    """ 
+    Wait for data on a specified socket.
+
+    Time out in (timeout)seconds.
+
+    @param sock control socket
+    @param timeout Timeout if data hasn't come in a specified seconds
+    @return A pair (okay, msg) okay is boolean to indicate a packet was
+    received.  msg is the message if okay is True
+
+    """
+    sock.settimeout(RCV_TIMEOUT)
+    try:
+        rcvmsg = sock.recv(RCV_SIZE)
+        return (True, rcvmsg)
+    except socket.timeout:
+        return (False, None)
+
+def open_ctrlsocket(host=HOST_DEFAULT, port=PORT_DEFAULT):
+    """ Open a socket for a controller connection.
+
+        @param host host IP address
+        @param port transport port number for the test-controller
+        @retval s socket
+    """
+    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+    s.bind((host, port))
+    s.listen(1)
+    return s