#!/usr/bin/env python

# Not useful with Busybox udhcpc, which does not accept BOOTP replies.
#
# Also, for this to work properly with tap interfaces and PCAP, your
# QEMU instances really need to be in sync with the addresses
# assigned to the tap interfaces -- otherwise the outgoing traffic
# will just get dropped, unless you source the traffic from a bridge
# interface.

# TODO: Update for the new checksum world order.

import random

from pcs.packets.localhost import *
from pcs.packets.ethernet import *
from pcs.packets.ipv4 import *
from pcs.packets.udpv4 import *
from pcs.packets.dhcpv4 import *
from pcs import *
from time import sleep

gw = "10.1.1.17"
subnet = "255.255.255.0"

# note: leading zeroes must be trimmed.
map = {
	"52:54:0:12:34:56":	"192.168.0.2"
}

def main():

    from optparse import OptionParser

    parser = OptionParser()

    parser.add_option("-d", "--devname",
                      dest="devname", default=None,
                      help="The name of the tap device to open.")

    parser.add_option("-i", "--ifname",
                      dest="ifname", default=None,