nslookup implementation
This commit is contained in:
parent
0cb9503b70
commit
038ec56a31
8 changed files with 27 additions and 14 deletions
|
@ -1598,6 +1598,7 @@ module = {
|
|||
module = {
|
||||
name = net;
|
||||
common = net/net.c;
|
||||
common = net/dns.c;
|
||||
common = net/bootp.c;
|
||||
common = net/ip.c;
|
||||
common = net/udp.c;
|
||||
|
|
|
@ -541,7 +541,7 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)),
|
|||
return err;
|
||||
}
|
||||
|
||||
static grub_command_t cmd_dhcp, cmd_getdhcp, cmd_bootp;
|
||||
static grub_command_t cmd_getdhcp, cmd_bootp;
|
||||
|
||||
void
|
||||
grub_bootp_init (void)
|
||||
|
@ -549,9 +549,6 @@ grub_bootp_init (void)
|
|||
cmd_bootp = grub_register_command ("net_bootp", grub_cmd_bootp,
|
||||
"[CARD]",
|
||||
N_("perform a bootp autoconfiguration"));
|
||||
cmd_dhcp = grub_register_command ("net_dhcp", grub_cmd_bootp,
|
||||
"[CARD]",
|
||||
N_("perform a bootp autoconfiguration"));
|
||||
cmd_getdhcp = grub_register_command ("net_get_dhcp_option", grub_cmd_dhcpopt,
|
||||
N_("VAR INTERFACE NUMBER DESCRIPTION"),
|
||||
N_("retrieve DHCP option and save it into VAR. If VAR is - then print the value."));
|
||||
|
@ -561,6 +558,5 @@ void
|
|||
grub_bootp_fini (void)
|
||||
{
|
||||
grub_unregister_command (cmd_getdhcp);
|
||||
grub_unregister_command (cmd_dhcp);
|
||||
grub_unregister_command (cmd_bootp);
|
||||
}
|
||||
|
|
|
@ -1491,6 +1491,7 @@ GRUB_MOD_INIT(net)
|
|||
cmd_lsaddr = grub_register_command ("net_ls_addr", grub_cmd_listaddrs,
|
||||
"", N_("list network addresses"));
|
||||
grub_bootp_init ();
|
||||
grub_dns_init ();
|
||||
|
||||
grub_fs_register (&grub_net_fs);
|
||||
grub_net_open = grub_net_open_real;
|
||||
|
@ -1503,6 +1504,7 @@ GRUB_MOD_INIT(net)
|
|||
GRUB_MOD_FINI(net)
|
||||
{
|
||||
grub_bootp_fini ();
|
||||
grub_dns_fini ();
|
||||
grub_unregister_command (cmd_addaddr);
|
||||
grub_unregister_command (cmd_deladdr);
|
||||
grub_unregister_command (cmd_addroute);
|
||||
|
|
|
@ -279,6 +279,7 @@ tftp_open (struct grub_file *file, const char *filename)
|
|||
tftp_data_t data;
|
||||
grub_err_t err;
|
||||
grub_uint8_t *nbd;
|
||||
grub_net_network_level_address_t addr;
|
||||
|
||||
data = grub_zalloc (sizeof (*data));
|
||||
if (!data)
|
||||
|
@ -335,7 +336,14 @@ tftp_open (struct grub_file *file, const char *filename)
|
|||
if (!data->pq)
|
||||
return grub_errno;
|
||||
|
||||
data->sock = grub_net_udp_open (file->device->net->server,
|
||||
err = grub_net_resolve_address (file->device->net->server, &addr);
|
||||
if (err)
|
||||
{
|
||||
destroy_pq (data);
|
||||
return err;
|
||||
}
|
||||
|
||||
data->sock = grub_net_udp_open (addr,
|
||||
TFTP_SERVER_PORT, tftp_receive,
|
||||
file);
|
||||
if (!data->sock)
|
||||
|
|
|
@ -59,7 +59,7 @@ grub_net_udp_close (grub_net_udp_socket_t sock)
|
|||
}
|
||||
|
||||
grub_net_udp_socket_t
|
||||
grub_net_udp_open (char *server,
|
||||
grub_net_udp_open (grub_net_network_level_address_t addr,
|
||||
grub_uint16_t out_port,
|
||||
grub_err_t (*recv_hook) (grub_net_udp_socket_t sock,
|
||||
struct grub_net_buff *nb,
|
||||
|
@ -67,17 +67,12 @@ grub_net_udp_open (char *server,
|
|||
void *recv_hook_data)
|
||||
{
|
||||
grub_err_t err;
|
||||
grub_net_network_level_address_t addr;
|
||||
struct grub_net_network_level_interface *inf;
|
||||
grub_net_network_level_address_t gateway;
|
||||
grub_net_udp_socket_t socket;
|
||||
static int in_port = 25300;
|
||||
grub_net_link_level_address_t ll_target_addr;
|
||||
|
||||
err = grub_net_resolve_address (server, &addr);
|
||||
if (err)
|
||||
return NULL;
|
||||
|
||||
if (addr.type != GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4
|
||||
&& addr.type != GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6)
|
||||
{
|
||||
|
|
|
@ -65,7 +65,8 @@ typedef enum
|
|||
GRUB_ERR_NET_PORT_CLOSED,
|
||||
GRUB_ERR_NET_INVALID_RESPONSE,
|
||||
GRUB_ERR_NET_UNKNOWN_ERROR,
|
||||
GRUB_ERR_NET_PACKET_TOO_BIG
|
||||
GRUB_ERR_NET_PACKET_TOO_BIG,
|
||||
GRUB_ERR_NET_NO_DOMAIN
|
||||
}
|
||||
grub_err_t;
|
||||
|
||||
|
|
|
@ -446,6 +446,9 @@ grub_net_poll_cards (unsigned time);
|
|||
void grub_bootp_init (void);
|
||||
void grub_bootp_fini (void);
|
||||
|
||||
void grub_dns_init (void);
|
||||
void grub_dns_fini (void);
|
||||
|
||||
static inline void
|
||||
grub_net_network_level_interface_unregister (struct grub_net_network_level_interface *inter)
|
||||
{
|
||||
|
@ -472,6 +475,13 @@ grub_err_t
|
|||
grub_net_link_layer_resolve (struct grub_net_network_level_interface *inf,
|
||||
const grub_net_network_level_address_t *proto_addr,
|
||||
grub_net_link_level_address_t *hw_addr);
|
||||
grub_err_t
|
||||
grub_net_dns_lookup (const char *name,
|
||||
const struct grub_net_network_level_address *servers,
|
||||
grub_size_t n_servers,
|
||||
grub_size_t *naddresses,
|
||||
struct grub_net_network_level_address **addresses,
|
||||
int cache);
|
||||
|
||||
extern char *grub_net_default_server;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ struct grub_net_udp_socket;
|
|||
typedef struct grub_net_udp_socket *grub_net_udp_socket_t;
|
||||
|
||||
grub_net_udp_socket_t
|
||||
grub_net_udp_open (char *server,
|
||||
grub_net_udp_open (grub_net_network_level_address_t addr,
|
||||
grub_uint16_t out_port,
|
||||
grub_err_t (*recv_hook) (grub_net_udp_socket_t sock,
|
||||
struct grub_net_buff *nb,
|
||||
|
|
Loading…
Reference in a new issue