'This method crafts the DHCP header using parts of the message.'

def craft_header(self, message):

    (xid, flags, yiaddr, giaddr, chaddr) = struct.unpack('!4x4s2x2s4x4s4x4s16s', message[:44])
    client_mac = chaddr[:6]
    response = struct.pack('!BBBB4s', 2, 1, 6, 0, xid)
    if (not self.mode_proxy):
        response += struct.pack('!HHI', 0, 0, 0)
    else:
        response += struct.pack('!HHI', 0, 32768, 0)
    if (not self.mode_proxy):
        if self.leases[client_mac]['ip']:
            offer = self.leases[client_mac]['ip']
        else:
            offer = self.get_namespaced_static('dhcp.binding.{0}.ipaddr'.format(self.get_mac(client_mac)))
            offer = (offer if offer else self.next_ip())
            self.leases[client_mac]['ip'] = offer
            self.leases[client_mac]['expire'] = (time.time() + 86400)
        response += socket.inet_aton(offer)
    else:
        response += socket.inet_aton('0.0.0.0')
    response += socket.inet_aton(self.file_server)
    response += socket.inet_aton('0.0.0.0')
    response += chaddr
    response += (chr(0) * 64)
    if self.mode_proxy:
        response += self.file_name
        response += (chr(0) * (128 - len(self.file_name)))
    else:
        response += (chr(0) * 128)
    response += self.magic
    return (client_mac, response)
