-PREFIX=../local
+PREFIX=..
 
 INCLUDEDIR=$(PREFIX)/include
 LIBDIR=$(PREFIX)/lib
 
  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
  */
 
+#include <string>
+#include <iostream>
+#include <fstream>
+#include <stdio.h>
 #include <sstream>
 
+#ifdef linux 
+#include <errno.h>
+#include <sys/types.h>
+#include <unistd.h>
+#elif defined(WIN32) && !defined(__CYGWIN__)
+
+#endif
+
+#include "vtl.h"
+
+
+#define DEFAULT_LOG_FILE "./status.log"
+#define DEFAULT_CONF_FILE "v3_nbd.ini"
 
 
-nbd_config_t g_nbd_conf;
+#define DEFAULT_PORT 9500
+#define MAX_STRING_SIZE 1024
+#define MAX_DISKS 32
+
+#define LOGFILE_TAG "logfile"
+#define IP_ADDR_TAG "address"
+#define PORT_TAG  "port"
+#define DISKS_TAG "disks"
+
 
 using namespace std;
 //using namespace __gnu_cxx;
 
 
+typedef enum {ISO, RAW} disk_type_t;
+
+struct disk_info {
+    string filename;
+    string tag;
+    disk_type_t type;
+};
+
+// eqstr from vtl (config.h)
+typedef map<const string, struct disk_info, eqstr> disk_list_t;
+
+struct nbd_config {
+    unsigned long server_addr;
+    int server_port;
+    disk_list_t disks;
+    int num_disks;
+};
+
+
+
+static const int enable_debug = 1;
+static struct nbd_config g_nbd_conf;
+
+void usage();
+int config_nbd(string conf_file_name);
+int serv_loop(int serv_sock);
+void setup_disk(string disk_tag);
 
-config_t g_config;
 
 int __main (int argc, char ** argv);
 
 
 int __main (int argc, char ** argv) {
   string config_file;
-  SOCK vnet_sock = 0;
-  struct vnet_config vnet_info;
-  iface_t * iface;
+  int serv_sock;
   if (argc > 2) {
     usage();
     exit(0);
   if (argc == 2) {
     config_file = string(argv[1]);
   } else {
-    config_file = VIDS_CONF_FILE;
+    config_file = DEFAULT_CONF_FILE;
   }
 
-
-  int * foo;
-  int num_ports = GetOpenUdpPorts(&foo);
-  int i;
-  for (i = 0; i < num_ports; i++) {
-    printf("port %d open\n", foo[i]);
-  }
-  
-
-  //  g_conf.log_file = "./vids.log";
-
-  if (config_vids(config_file) == -1) {
+ 
+  if (config_nbd(config_file) == -1) {
     cerr << "Configuration Error" << endl;
     exit(-1);
   }
 
-  // JRL DEBUG
-  debug_init(g_config[LOGFILE_TAG].c_str());
-  JRLDBG("testing...\n");
-
+  // setup network sockets
 
-
-  // Configure pcap filter...
-
-  vids_loop(iface, vnet_sock, &vnet_info);
+  vtl_debug("Starting Server Loop\n");
+  serv_loop(serv_sock);
 
   return 0;
 }
 
 
 #ifdef linux
-int vids_loop(iface_t * iface, SOCK vnet_sock, struct vnet_config * vnet_info) {
+int serv_loop(int serv_sock) {
   fd_set all_set, read_set;
   int max_fd = -1;
   RawEthernetPacket pkt;
 
   FD_ZERO(&all_set);
-  FD_SET(vnet_sock, &all_set);
-  max_fd = vnet_sock;
+  FD_SET(serv_sock, &all_set);
+  max_fd = serv_sock;
 
 
   while (1) {
     }
     
 
-    if (FD_ISSET(vnet_sock, &read_set)) {
+    if (FD_ISSET(serv_sock, &read_set)) {
       //vnet_recv();
-      
+
 
     }
   }
 }
 
 #elif WIN32
-int vids_loop(iface_t * iface, SOCK vnet_sock, struct vnet_config * vnet_info) {
+int serv_loop(iface_t * iface, SOCK vnet_sock, struct vnet_config * vnet_info) {
   int ret;
   RawEthernetPacket pkt;
   WSANETWORKEVENTS net_events;
 
 
 
-int config_vids(string conf_file_name) {
-  if (read_config(conf_file_name, &g_config) != 0) {
-    return -1;
-  }
-
-  if (g_config.count(VIDS_SERVER_TAG) > 0) {
-    g_vids_conf.server_addr = ToIPAddress(g_config[VIDS_SERVER_TAG].c_str());
-  } else {
-    printf("Must specify VIDS server address\n");
-    return -1;
-  }
-
-  if (g_config.count(VIDS_SERVER_PORT_TAG) > 0) {
-    g_vids_conf.server_port = atoi(g_config[VIDS_SERVER_PORT_TAG].c_str());
-  } else {
-    printf("Must specify VIDS server port\n");
-    return -1;
-  }
-
-  if (g_config.count(TCP_PORTS_TAG) > 0) {
-    istringstream port_stream(g_config[TCP_PORTS_TAG], istringstream::in);
-    int port;
-    int i = 0;
+int config_nbd(string conf_file_name) {
+    config_t config_map;
     
-    while (port_stream >> port) {
-      if (i >= MAX_PORTS) {
-       cerr << "You specified too many ports to forward, truncating..." << endl;
-       break;
-      }
-      
-      g_vids_conf.tcp_ports[i] = port;      
-      i++;
+    if (read_config(conf_file_name, &config_map) != 0) {
+       cerr << "Could not read config file..." << endl;
+       return -1;
     }
 
-    g_vids_conf.num_tcp_ports = i;
-  }
-
-
-
-  if (g_config.count(VIRTUAL_MAC_TAG) > 0) {
-   string_to_mac(g_config[VIRTUAL_MAC_TAG].c_str(), g_vids_conf.virtual_mac);
-  }
-
-  if (g_config.count(LOGFILE_TAG) == 0) {
-    g_config[LOGFILE_TAG] = DEFAULT_LOG_FILE;
-  }
-
-  if (GetLocalMacAddress(g_config[INTERFACE_TAG], g_vids_conf.local_mac) == -1) {
-    cerr << "Could not get local mac address" << endl;
-    return -1;
-  }
-
-
-  return 0;
-}
-
+    if (config_map.count(IP_ADDR_TAG) > 0) {
+       g_nbd_conf.server_addr = ToIPAddress(config_map[IP_ADDR_TAG].c_str());
+    } 
 
-int read_config(string conf_file_name) {
-  fstream conf_file(conf_file_name.c_str(), ios::in);
-  char line[MAX_STRING_SIZE];
+    if (config_map.count(PORT_TAG) > 0) {
+       g_nbd_conf.server_port = atoi(config_map[PORT_TAG].c_str());
+    } else {
+       g_nbd_conf.server_port = DEFAULT_PORT;
+    }
+       
+    if (config_map.count(DISKS_TAG) > 0) {
+       istringstream disk_stream(config_map[DISKS_TAG], istringstream::in);
+       string disk_tag;
+       int i = 0;
+       
+       while (disk_stream >> disk_tag) {
 
-  while ((conf_file.getline(line, MAX_STRING_SIZE))) {
-    string conf_line = line;
-    string tag;
-    string value;
-    int offset, ltrim_index, rtrim_index;
+           if (i >= MAX_DISKS) {
+               cerr << "You specified too many disks, truncating..." << endl;
+               break;
+           }
+           
+           setup_disk(disk_tag);
 
-    if (conf_line[0] == '#') {
-      continue;
+           i++;
+       }
+       
+       g_nbd_conf.num_disks = i;
+    } else {
+       cerr << "Must specify a set of disks" << endl;
+       return -1;
     }
+    
+    
+    if (config_map.count(LOGFILE_TAG) == 0) {
+       config_map[LOGFILE_TAG] = DEFAULT_LOG_FILE;
+    }
+    
 
-    offset = conf_line.find(":", 0);
-    tag = conf_line.substr(0,offset);
-
-    // kill white space
-    istringstream tag_stream(tag, istringstream::in);
-    tag_stream >> tag;
+    vtl_debug_init(config_map[LOGFILE_TAG], enable_debug);
 
-    if (tag.empty()) {
-      continue;
-    }
 
-    // basic whitespace trimming, we assume that the config handlers will deal with 
-    // tokenizing and further formatting
-    value = conf_line.substr(offset + 1, conf_line.length() - offset);
-    ltrim_index = value.find_first_not_of(" \t");
-    rtrim_index = value.find_last_not_of(" \t");
-    value = value.substr(ltrim_index, (rtrim_index + 1) - ltrim_index);
+    return 0;
+}
 
-    g_config[tag] = value;
-  }
-  return 0;
+void setup_disk(string disk_tag) {
+    printf("Setting up %s\n", disk_tag.c_str());
 }
 
 
+
 void usage() {
-  cout << "Usage: vids [config_file]" << endl;
+  cout << "Usage: v3_nbd [config_file]" << endl;
   return;
 }
 
+++ /dev/null
-/* 
- * This file is part of the Palacios Virtual Machine Monitor developed
- * by the V3VEE Project with funding from the United States National 
- * Science Foundation and the Department of Energy.  
- *
- * The V3VEE Project is a joint project between Northwestern University
- * and the University of New Mexico.  You can find out more at 
- * http://www.v3vee.org
- *
- * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> 
- * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
- * All rights reserved.
- *
- * Author: Jack Lange <jarusl@cs.northwestern.edu>
- *
- * This is free software.  You are permitted to use,
- * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
- */
-
-#ifndef __V3_NBD_H__
-#define __V3_NBD_H__
-
-#include <string>
-#include <iostream>
-#include <fstream>
-#include <stdio.h>
-#include <sstream>
-
-#ifdef linux 
-#include <errno.h>
-#include <sys/types.h>
-#include <unistd.h>
-#elif defined(WIN32) && !defined(__CYGWIN__)
-
-#endif
-
-
-using namespace std;
-
-
-
-#define DEFAULT_LOG_FILE "./status.log"
-#define VIDS_CONF_FILE "v3_nbd.ini"
-#define MAX_STRING_SIZE 1024
-
-
-typedef struct nbd_config {
-  unsigned long server_addr;
-  int server_port;
-
-
-} nbd_config_t;
-
-
-
-void usage();
-int config_nbd(string conf_file_name);
-
-
-
-#define VIDS_SERVER_TAG "vids_server"
-
-
-#endif // !__VIDS_H
 
-DISTDIR= ../dist
-PREFIX=../local
-DEBUG=-DDEBUG
-#DEBUG=
+PREFIX=..
 #PROFILER=-pg
 PROFILER=
 
 LIBDIR=$(PREFIX)/lib
 BINDIR=$(PREFIX)/bin
 
-VTL_OBJS = vtl_util.o  if.o socks.o util.o net_util.o raw_ethernet_packet.o vtl_model.o config.o
-TOR_VTL_OBJS = vtl_socks5.o tor_vtl.o vtl_dns.o
+VTL_OBJS = vtl_util.o  if.o socks.o util.o net_util.o raw_ethernet_packet.o vtl_model.o config.o debug.o
 
 VTL_HDRS = vtl.h vtl_util.h util.h socks.h if.h net_util.h vtl_model.h raw_ethernet_packet.h debug.h config.h vtl_harness.h
 
-DISTFILES = config.cc config.h debug.h if.cc if.h net_util.cc net_util.h raw_ethernet_packet.cc raw_ethernet_packet.h socks.cc socks.h util.cc util.h vtl.h vtl_harness.h vtl_model.cc vtl_model.h vtl_util.cc vtl_util.h Makefile .dependencies
 
 LIBNETLDFLAGS = -L$(LIBDIR) -lnet
 SSLFLAGS       = -lssl
 AR=ar
 RANLIB=ranlib
 
-#CXXFLAGS =  -DDEBUG  -g -gstabs+ -Wall $(PCAPCFLAGS) -I/usr/kerberos/include
-CXXFLAGS =   $(DEBUG) -Wall -g -gstabs+ -DUSE_SSL $(PCAPCFLAGS) -I/usr/kerberos/include
+#CXXFLAGS = -g -gstabs+ -Wall $(PCAPCFLAGS) -I/usr/kerberos/include
+CXXFLAGS =   -Wall -g -gstabs+ -DUSE_SSL $(PCAPCFLAGS) -I/usr/kerberos/include
 LDFLAGS  =  -L$(LIBDIR) $(PCAPLDFLAGS) $(LIBNETLDFLAGS) $(SSLFLAGS) 
 
 
 
     value = conf_line.substr(offset + 1, conf_line.length() - offset);
     ltrim_index = value.find_first_not_of(" \t");
     rtrim_index = value.find_last_not_of(" \t");
-    value = value.substr(ltrim_index, (rtrim_index + 1) - ltrim_index);
+    
+    if ((ltrim_index >= 0) && (rtrim_index >= 0)) {
+       value = value.substr(ltrim_index, (rtrim_index + 1) - ltrim_index);
+    }
 
     (*config)[tag] = value;
   }
 
 #ifndef __DEBUG_H
-#define __DEBUG_H 1
+#define __DEBUG_H
 
+#include <string>
 
+using namespace std;
 
-
-#ifdef DEBUG
-
-#define ASSERT(exp) assert(exp)
-
-/*
- *
- *
- */
-
-#ifdef linux
-
-extern FILE * logfile;
-extern time_t dbgt;
-extern char dmsg[1024];
-
-#define DEBUG_DECLARE() FILE * logfile; time_t dbgt; char dmsg[1024];
-#define JRLDBG( ...) time(&dbgt); sprintf(dmsg,"%s: ",ctime(&dbgt)); *(dmsg + strlen(dmsg) -3) = ' '; fprintf(logfile, dmsg); sprintf(dmsg,__VA_ARGS__); fprintf(logfile,dmsg); fflush(logfile);
-#define debug_init(logfilename) logfile = fopen(logfilename,"w+")
-
-#elif defined(WIN32)
-
-#define DEBUG_DECLARE() 
-#define JRLDBG printf
-#define debug_init(logfilename) 
-
-#endif
-
-/*
- *
- *
- */
-
-#else //!DEBUG
-
-#ifdef WIN32
-
-#define ASSERT(exp)
-#define DEBUG_DECLARE()
-#define JRLDBG()
-#define debug_init(logfilename)
-
-#elif defined(linux)
-
-#define ASSERT(exp)
-#define DEBUG_DECLARE(...)
-#define JRLDBG(...)
-#define debug_init(logfilename)
-
-#endif
-
-#endif
-
+int vtl_debug_init(string logfilename, int debug_enable);
+void vtl_debug(const char * fmt, ...);
 
 
 #endif
 
 #ifdef linux 
   if (mode & IF_RD) {
     if ((iface->pcap_interface = pcap_open_live((char*)if_name.c_str(), 65536, 1, 1, pcap_errbuf)) == NULL) {
-      JRLDBG("Could not initialize pcap\n");
+      vtl_debug("Could not initialize pcap\n");
       return NULL;
     }
 
     char libnet_errbuf[LIBNET_ERRORBUF_SIZE];
     
     if ((iface->net_interface = libnet_init(LIBNET_LINK_ADV, (char *)if_name.c_str(), libnet_errbuf)) == NULL) {
-      JRLDBG("Could not initialize libnet\n");
+      vtl_debug("Could not initialize libnet\n");
       return NULL;
     }
   }
 
 #elif defined(WIN32) 
   if ((iface->pcap_interface = pcap_open_live((char*)if_name.c_str(), 65536, 1, 1, pcap_errbuf)) == NULL) {
-    JRLDBG("Could not initialize pcap\n");
+    vtl_debug("Could not initialize pcap\n");
     return NULL;
   }
   
 
 
 int if_write_pkt(iface_t * iface, RawEthernetPacket * pkt) {
-  ASSERT((iface != NULL) && (pkt != NULL) && (iface->net_interface != NULL));
+  assert((iface != NULL) && (pkt != NULL) && (iface->net_interface != NULL));
 
 #ifdef linux
-  JRLDBG("Writing pkt size(%lu)\n", pkt->get_size());
+  vtl_debug("Writing pkt size(%lu)\n", pkt->get_size());
   if (libnet_adv_write_link(iface->net_interface, 
                            (u_char *)(pkt->get_data()), 
                            pkt->get_size()) < 0) {
-    JRLDBG("Libnet could not inject packet size (%lu)\n", pkt->get_size());
+    vtl_debug("Libnet could not inject packet size (%lu)\n", pkt->get_size());
     return -1;
   }
 
   if (pcap_sendpacket(iface->pcap_interface, 
                      (u_char *)(pkt->get_data()),
                      pkt->get_size()) < 0) {
-    JRLDBG("PCAP could not inject packet\n");
+    vtl_debug("PCAP could not inject packet\n");
     return -1;
   }
 
   strcpy(filter_buf, bpf_str.c_str());
   cout << "Setting Getting interface info for " << iface->name << endl;
   if (pcap_lookupnet(iface->name->c_str(), &network, &netmask, errbuf) == -1) {
-    JRLDBG("Error looking up the network info\n");
+    vtl_debug("Error looking up the network info\n");
     return -1;
   }
 
   netmask=0xffffffff;
   cout << bpf_str << endl;
   if (pcap_compile(iface->pcap_interface, &fcode, filter_buf, 1, netmask) < 0) { 
-    JRLDBG("Could not compile bpf filter\n");
+    vtl_debug("Could not compile bpf filter\n");
     return -1; 
   } 
   
   if (pcap_setfilter(iface->pcap_interface, &fcode) < 0) { 
-    JRLDBG("Could not insert bpf filter\n");
+    vtl_debug("Could not insert bpf filter\n");
     return -1; 
   } 
 
 
   
   ret = Receive(fd, ssl, pkt, sizeof(char) * 2 + sizeof(size_t), true);
   if (ret == 0) {
-    JRLDBG("TCP socket closed\n");
+    vtl_debug("TCP socket closed\n");
     return 0;
   } else if (ret != (sizeof(char) * 2 + sizeof(size_t))) {
-    JRLDBG("Error unserializing packet header from tcp socket\n");
+    vtl_debug("Error unserializing packet header from tcp socket\n");
     return -1;
   }
 
-  JRLDBG("Receiving TCP data. size=%lu, offset=%d\n", this->get_size(), *(pkt + 2));
+  vtl_debug("Receiving TCP data. size=%lu, offset=%d\n", this->get_size(), *(pkt + 2));
 
   ret = Receive(fd, ssl, data, this->get_size(), true);
   if (ret == 0) {
-    JRLDBG("TCP Socket closed\n");
+    vtl_debug("TCP Socket closed\n");
     return 0;
   } else if (ret != (int)this->get_size()) {
-    JRLDBG("Error unserializing packet from tcp socket\n");
+    vtl_debug("Error unserializing packet from tcp socket\n");
     return -1;
   }
 
   
   ret = Receive(fd, pkt, sizeof(char) * 2 + sizeof(size_t), true);
   if (ret == 0) {
-    JRLDBG("TCP socket closed\n");
+    vtl_debug("TCP socket closed\n");
     return 0;
   } else if (ret != (sizeof(char) * 2 + sizeof(size_t))) {
-    JRLDBG("Error unserializing packet header from tcp socket\n");
+    vtl_debug("Error unserializing packet header from tcp socket\n");
     return -1;
   }
 
-  JRLDBG("Receiving TCP data. size=%lu, offset=%d\n", this->get_size(), *(pkt + 2));
+  vtl_debug("Receiving TCP data. size=%lu, offset=%d\n", this->get_size(), *(pkt + 2));
 
   ret = Receive(fd, data, this->get_size(), true);
   if (ret == 0) {
-    JRLDBG("TCP Socket closed\n");
+    vtl_debug("TCP Socket closed\n");
     return 0;
   } else if (ret != (int)this->get_size()) {
-    JRLDBG("Error unserializing packet from tcp socket\n");
+    vtl_debug("Error unserializing packet from tcp socket\n");
     return -1;
   }
 
 
   ret = Receive(fd, pkt, sizeof(char) * 2, true);
   if (ret == 0) {
-    JRLDBG("VTP connection has Closed\n");
+    vtl_debug("VTP connection has Closed\n");
     return 0;
   } else if (ret != (int)sizeof(char) * 2) {
-    JRLDBG("Could not read type from VTP packet\n");
+    vtl_debug("Could not read type from VTP packet\n");
     return -1;
   }
 
   ret = Receive(fd, (char *)serveraddr, sizeof(struct in_addr), true);
   if (ret == 0) {
-    JRLDBG("VTP connection has closed\n");
+    vtl_debug("VTP connection has closed\n");
     return 0;
   } else if (ret != (int)sizeof(struct in_addr))  {
-    JRLDBG("Could not read VTP address info\n");
+    vtl_debug("Could not read VTP address info\n");
     return -1;
   }
 
   ret = Receive(fd, (char *)size, sizeof(size_t), true);
   if (ret == 0) {
-    JRLDBG("VTP connection has closed\n");
+    vtl_debug("VTP connection has closed\n");
     return 0;
   } else if (ret != sizeof(size_t)) {
-    JRLDBG("Could not read VTP size\n");
+    vtl_debug("Could not read VTP size\n");
     return -1;
   }
   
   ret = Receive(fd, data, this->get_size(), true);
   if (ret == 0) {
-    JRLDBG("VTP connection has closed\n");
+    vtl_debug("VTP connection has closed\n");
     return 0;
   } else if (ret != (int)this->get_size()) {
-    JRLDBG("Could not read VTP packet data\n");
+    vtl_debug("Could not read VTP packet data\n");
     return -1;
   }
 
 
   ret = Send(fd, type, sizeof(char) * 2, true);  
   if (ret != sizeof(char) * 2) {
-    JRLDBG("Error writing type to VTP socket\n");
+    vtl_debug("Error writing type to VTP socket\n");
     return -1;
   }
 
   ret = Send(fd, (char *)serveraddr, sizeof(struct in_addr), true);
   if (ret != sizeof(struct in_addr)) {
-    JRLDBG("Error writing dest addr to VTP socket\n");
+    vtl_debug("Error writing dest addr to VTP socket\n");
     return -1;
   }
 
 
   ret = Send(fd, pkt + (sizeof(char) * 2), length, true);
   if (ret != (int)length) {
-    JRLDBG("ERROR writing packet length and data to VTP socket\n");
+    vtl_debug("ERROR writing packet length and data to VTP socket\n");
     return -1;
   }
   
 
 
 
 int initialize_ethernet_model(ethernet_model_t * model, RawEthernetPacket * pkt, int dir = OUTBOUND_PKT) {
-  ASSERT((model != NULL) && (pkt != NULL));
+  assert((model != NULL) && (pkt != NULL));
 
-  printf("initializing ethernet model\n");
+  vtl_debug("initializing ethernet model\n");
   if (dir == OUTBOUND_PKT) {
     GET_ETH_DST(pkt->data, model->dst.addr);
     GET_ETH_SRC(pkt->data, model->src.addr);
 }
 
 int initialize_ip_model(ip_model_t * model, RawEthernetPacket * pkt, int dir) {
-  ASSERT((model != NULL) && (pkt != NULL));
+  assert((model != NULL) && (pkt != NULL));
 
   if (!is_ip_pkt(pkt)) {
     return -1;
 }
 
 int initialize_tcp_model(tcp_model_t * model, RawEthernetPacket * pkt, int dir) {
-  ASSERT((model != NULL) && (pkt != NULL));
+  assert((model != NULL) && (pkt != NULL));
 
   tcp_opts_t options;
 
 }
 
 int initialize_udp_model(udp_model_t * model, RawEthernetPacket * pkt, int dir) {
-  ASSERT((model != NULL) && (pkt != NULL));
+  assert((model != NULL) && (pkt != NULL));
   
   if (!is_udp_pkt(pkt)) {
     return -1;
 
 
 int initialize_model(vtl_model_t * model, RawEthernetPacket * pkt, int dir) {
-  ASSERT((model != NULL) && (pkt != NULL));
+  assert((model != NULL) && (pkt != NULL));
 
   if (model->type == TCP_MODEL) {
     return initialize_tcp_model(&(model->model.tcp_model), pkt, dir);
 
 
 int is_ethernet_model_pkt(ethernet_model_t * model, RawEthernetPacket * pkt) {
-  ASSERT((model != NULL) && (pkt != NULL));
+  assert((model != NULL) && (pkt != NULL));
 
   if ((memcmp(model->src.addr, ETH_SRC(pkt->data), 6) == 0) &&
       (memcmp(model->dst.addr, ETH_DST(pkt->data), 6) == 0)) {
 }
 
 int is_ip_model_pkt(ip_model_t * model, RawEthernetPacket * pkt) {
-  ASSERT((model != NULL) && (pkt != NULL));
+  assert((model != NULL) && (pkt != NULL));
 
   if (!is_ip_pkt(pkt)) {
     return INVALID_PKT;
 
 
 int is_tcp_model_pkt(tcp_model_t * model, RawEthernetPacket * pkt) {
-  ASSERT((model != NULL) && (pkt != NULL));
+  assert((model != NULL) && (pkt != NULL));
   int ip_ret;
 
   if (!is_tcp_pkt(pkt)) {
 }
 
 int is_udp_model_pkt(udp_model_t * model, RawEthernetPacket * pkt) {
-  ASSERT((model != NULL) && (pkt != NULL));
+  assert((model != NULL) && (pkt != NULL));
   int ip_ret;
 
   if (!is_udp_pkt(pkt)) {
 }
 
 int is_model_pkt(vtl_model_t * model, RawEthernetPacket * pkt) {
-  ASSERT((model != NULL) && (pkt != NULL));
+  assert((model != NULL) && (pkt != NULL));
   
   if (model->type == TCP_MODEL) {
     return is_tcp_model_pkt(&(model->model.tcp_model), pkt);
 
 
 int sync_ip_model(ip_model_t * model, RawEthernetPacket * pkt) {
-  ASSERT((model != NULL) && (pkt != NULL));
+  assert((model != NULL) && (pkt != NULL));
 
   int ip_ret; 
   
 
 
 int sync_tcp_model(tcp_model_t * model, RawEthernetPacket * pkt) {
-  ASSERT((model != NULL) && (pkt != NULL));
+  assert((model != NULL) && (pkt != NULL));
   int tcp_ret;
   tcp_opts_t options;
   int has_opts = 0;
 
 
 int sync_udp_model(udp_model_t * model, RawEthernetPacket * pkt) {
-  ASSERT((model != NULL) && (pkt != NULL));
+  assert((model != NULL) && (pkt != NULL));
   int udp_ret;
   
   udp_ret = is_udp_model_pkt(model, pkt);
 
   compute_tcp_checksum(pkt);
 
-  JRLDBG("tcp_len = %d\n", GET_TCP_HDR_LEN(pkt->data));
+  vtl_debug("tcp_len = %d\n", GET_TCP_HDR_LEN(pkt->data));
 
 
   // Set the ip hdr len
   char src_mac[6];
   char dst_mac[6];
 
-  printf("ETHERNET MODEL {\n");
+  vtl_debug("ETHERNET MODEL {\n");
 
-  printf("\tType: %s\n", get_eth_protocol(model->type));
+  vtl_debug("\tType: %s\n", get_eth_protocol(model->type));
 
   mac_to_string(model->src.addr, src_mac);
-  printf("\tSrc Host {\n");
-  printf("\t\taddr: %s\n", src_mac);
-  printf("\t}\n");
+  vtl_debug("\tSrc Host {\n");
+  vtl_debug("\t\taddr: %s\n", src_mac);
+  vtl_debug("\t}\n");
 
   mac_to_string(model->dst.addr, dst_mac);
-  printf("\tDST Host {\n");
-  printf("\t\taddr: %s\n", dst_mac);
-  printf("\t}\n");
-  printf("}\n");
+  vtl_debug("\tDST Host {\n");
+  vtl_debug("\t\taddr: %s\n", dst_mac);
+  vtl_debug("\t}\n");
+  vtl_debug("}\n");
 }
 
 
 void dbg_dump_ip_model(ip_model_t * model) {
   dbg_dump_eth_model(&(model->ethernet));
 
-  printf("IP MODEL {\n");
-  printf("\tVersion: %d\n", model->version);
-  printf("\tProtocol: %s\n", get_ip_protocol(model->proto));
+  vtl_debug("IP MODEL {\n");
+  vtl_debug("\tVersion: %d\n", model->version);
+  vtl_debug("\tProtocol: %s\n", get_ip_protocol(model->proto));
 
-  printf("\tSrc Host {\n");
-  printf("\t\taddr: %s\n", ip_to_string(model->src.addr));
-  printf("\t\tIP ID: %d\n", model->src.ip_id);
-  printf("\t\tttl: %d\n", model->src.ttl);
-  printf("\t}\n");
+  vtl_debug("\tSrc Host {\n");
+  vtl_debug("\t\taddr: %s\n", ip_to_string(model->src.addr));
+  vtl_debug("\t\tIP ID: %d\n", model->src.ip_id);
+  vtl_debug("\t\tttl: %d\n", model->src.ttl);
+  vtl_debug("\t}\n");
 
-  printf("\tDst Host {\n");
-  printf("\t\taddr: %s\n", ip_to_string(model->dst.addr));
-  printf("\t\tIP ID: %d\n", model->dst.ip_id);
-  printf("\t\tttl: %d\n", model->dst.ttl);
-  printf("\t}\n");
+  vtl_debug("\tDst Host {\n");
+  vtl_debug("\t\taddr: %s\n", ip_to_string(model->dst.addr));
+  vtl_debug("\t\tIP ID: %d\n", model->dst.ip_id);
+  vtl_debug("\t\tttl: %d\n", model->dst.ttl);
+  vtl_debug("\t}\n");
 
-  printf("}\n");
+  vtl_debug("}\n");
 }
 
 void dbg_dump_tcp_model(tcp_model_t * model) {
   dbg_dump_ip_model(&(model->ip));
 
-  printf("TCP MODEL {\n");
-  printf("\tSrc Host {\n");
-  printf("\t\tport: %hu\n", model->src.port);
-  printf("\t\tseq: %lu\n", (unsigned long)(model->src.seq_num));
-  printf("\t\tlast ack: %lu\n", (unsigned long)(model->src.last_ack));
-  printf("\t\tWin Size: %hu\n", model->src.win);
-  printf("\t\tTimestamp: %lu\n", (unsigned long)(model->src.ts));
-  printf("\t\tMSS: %hu\n", model->src.mss);
+  vtl_debug("TCP MODEL {\n");
+  vtl_debug("\tSrc Host {\n");
+  vtl_debug("\t\tport: %hu\n", model->src.port);
+  vtl_debug("\t\tseq: %lu\n", (unsigned long)(model->src.seq_num));
+  vtl_debug("\t\tlast ack: %lu\n", (unsigned long)(model->src.last_ack));
+  vtl_debug("\t\tWin Size: %hu\n", model->src.win);
+  vtl_debug("\t\tTimestamp: %lu\n", (unsigned long)(model->src.ts));
+  vtl_debug("\t\tMSS: %hu\n", model->src.mss);
   
-  printf("\t}\n");
+  vtl_debug("\t}\n");
 
-  printf("\tDst Host {\n");
-  printf("\t\tport: %hu\n", model->dst.port);
-  printf("\t\tseq: %lu\n", (unsigned long)(model->dst.seq_num));
-  printf("\t\tlast ack: %lu\n", (unsigned long)(model->dst.last_ack));
-  printf("\t\tWin Size: %hu\n", model->dst.win);
-  printf("\t\tTimestamp: %lu\n", (unsigned long)(model->dst.ts));
-  printf("\t\tMSS: %hu\n", model->dst.mss);
-  printf("\t}\n");
+  vtl_debug("\tDst Host {\n");
+  vtl_debug("\t\tport: %hu\n", model->dst.port);
+  vtl_debug("\t\tseq: %lu\n", (unsigned long)(model->dst.seq_num));
+  vtl_debug("\t\tlast ack: %lu\n", (unsigned long)(model->dst.last_ack));
+  vtl_debug("\t\tWin Size: %hu\n", model->dst.win);
+  vtl_debug("\t\tTimestamp: %lu\n", (unsigned long)(model->dst.ts));
+  vtl_debug("\t\tMSS: %hu\n", model->dst.mss);
+  vtl_debug("\t}\n");
 
 
-  printf("}\n");
+  vtl_debug("}\n");
 
 }
 
 
   dest_str = ip_to_string(GET_IP_DST(pkt->data));
   src_str = ip_to_string(GET_IP_SRC(pkt->data));
 
-  JRLDBG("Packet: %s:%d-%s:%d seq: %lu, ack: %lu\n", src_str.c_str(), ntohs(src_port), dest_str.c_str(), ntohs(dest_port), 
+  vtl_debug("Packet: %s:%d-%s:%d seq: %lu, ack: %lu\n", src_str.c_str(), ntohs(src_port), dest_str.c_str(), ntohs(dest_port), 
         seq_num, ack_num);
         
   return;
   char pkt_line[128];
   unsigned int pkt_size = pkt->get_size() - 1;
 
-  JRLDBG("Packet Dump: (pkt_size=%lu) \n", pkt->get_size());
+  vtl_debug("Packet Dump: (pkt_size=%lu) \n", pkt->get_size());
 
   for (x = 0; x < pkt_size;) {
     sprintf(pkt_line, "\t%.4x:  ", x);
       }
     }
 
-    JRLDBG("%s\n", pkt_line);
+    vtl_debug("%s\n", pkt_line);
 
     x += 16;
   }
   int i;
   char pkt_line[128];
 
-  JRLDBG("Buf Dump: (len=%d) \n", len);
+  vtl_debug("Buf Dump: (len=%d) \n", len);
 
   for (x = 0; x < len-1;) {
     sprintf(pkt_line, "\t%.4x:  ", x);
       }
     }
 
-    JRLDBG("%s\n", pkt_line);
+    vtl_debug("%s\n", pkt_line);
 
     x += 16;
   }
 }
 
 int parse_tcp_options(tcp_opts_t * options, RawEthernetPacket * pkt) {
-  ASSERT((options != NULL) && (pkt != NULL));
+  assert((options != NULL) && (pkt != NULL));
   
   memset(options, 0, sizeof(options));
 
       offset += *(opts + offset + 1);
     } else {
       offset += *(opts + offset + 1);
-      //JRLDBG("Could not find timestamp\n");
+      //vtl_debug("Could not find timestamp\n");
       //break;
     }
   }
       return offset;
     } else {
       offset += *(opts + offset + 1);
-      //JRLDBG("Could not find timestamp\n");
+      //vtl_debug("Could not find timestamp\n");
       //break;
     }
   }
   //  memcpy(buf + 6, (pkt->data + ETH_HDR_LEN + GET_IP_HDR_LEN(pkt->data)), tcp_len);
   memcpy(buf + 6, TCP_HDR(pkt->data), tcp_len);
   if (tcp_len % 2) {
-    JRLDBG("Odd tcp_len: %hu\n", tcp_len);
+    vtl_debug("Odd tcp_len: %hu\n", tcp_len);
     *(((char*)buf) + 2 * 6 + tcp_len) = 0;
   }
 
   //  memcpy(buf + 6, (pkt->data + ETH_HDR_LEN + GET_IP_HDR_LEN(pkt->data)), udp_len);
   memcpy(buf + 6, UDP_HDR(pkt->data), udp_len);
   if (udp_len % 2) {
-    JRLDBG("Odd udp_len: %hu\n", udp_len);
+    vtl_debug("Odd udp_len: %hu\n", udp_len);
     *(((char*)buf) + 2 * 6 + udp_len) = 0;
   }