'@brief This method crafts the DHCP option fields
@param opt53:
*    2 - DHCPOFFER
*    5 - DHCPACK
@see RFC2132 9.6 for details.'

def craft_options(self, opt53, client_mac):

    response = self.tlv_encode(53, chr(opt53))
    response += self.tlv_encode(54, socket.inet_aton(self.ip))
    if (not self.mode_proxy):
        subnet_mask = self.get_namespaced_static('dhcp.binding.{0}.subnet'.format(self.get_mac(client_mac)), self.subnet_mask)
        response += self.tlv_encode(1, socket.inet_aton(subnet_mask))
        router = self.get_namespaced_static('dhcp.binding.{0}.router'.format(self.get_mac(client_mac)), self.router)
        response += self.tlv_encode(3, socket.inet_aton(router))
        dns_server = self.get_namespaced_static('dhcp.binding.{0}.dns'.format(self.get_mac(client_mac)), [self.dns_server])
        dns_server = ''.join([socket.inet_aton(i) for i in dns_server])
        response += self.tlv_encode(6, dns_server)
        response += self.tlv_encode(51, struct.pack('!I', 86400))
    response += self.tlv_encode(66, self.file_server)
    if ((not self.ipxe) or (not self.leases[client_mac]['ipxe'])):
        if ((93 in self.leases[client_mac]['options']) and (not self.force_file_name)):
            [arch] = struct.unpack('!H', self.leases[client_mac]['options'][93][0])
            if (arch == 0):
                response += self.tlv_encode(67, ('pxelinux.0' + chr(0)))
            elif (arch == 6):
                response += self.tlv_encode(67, ('syslinux.efi32' + chr(0)))
            elif (arch == 7):
                response += self.tlv_encode(67, ('syslinux.efi64' + chr(0)))
            elif (arch == 9):
                response += self.tlv_encode(67, ('syslinux.efi64' + chr(0)))
        else:
            response += self.tlv_encode(67, (self.file_name + chr(0)))
    else:
        response += self.tlv_encode(67, ('chainload.kpxe' + chr(0)))
        if (opt53 == 5):
            self.leases[client_mac]['ipxe'] = False
    if self.mode_proxy:
        response += self.tlv_encode(60, 'PXEClient')
        response += struct.pack('!BBBBBBB4sB', 43, 10, 6, 1, 8, 10, 4, (chr(0) + 'PXE'), 255)
    response += '\xff'
    return response
