projects
/
oweals
/
u-boot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
arm64: zynqmp: Enables SPI_FLASH_BAR
[oweals/u-boot.git]
/
net
/
dns.c
diff --git
a/net/dns.c
b/net/dns.c
index 6f8b1f2596cdbd1bf858be5acbdb4870400438f7..67d761d7c0f5f81e32b5f4e633b7f66dd076ce16 100644
(file)
--- a/
net/dns.c
+++ b/
net/dns.c
@@
-24,18
+24,18
@@
#include <common.h>
#include <command.h>
#include <common.h>
#include <command.h>
+#include <env.h>
#include <net.h>
#include <asm/unaligned.h>
#include "dns.h"
#include <net.h>
#include <asm/unaligned.h>
#include "dns.h"
-char *
NetDNSResolve;
/* The host to resolve */
-char *
NetDNSenvvar;
/* The envvar to store the answer in */
+char *
net_dns_resolve;
/* The host to resolve */
+char *
net_dns_env_var;
/* The envvar to store the answer in */
-static int
DnsOurP
ort;
+static int
dns_our_p
ort;
-static void
-DnsSend(void)
+static void dns_send(void)
{
struct header *header;
int n, name_len;
{
struct header *header;
int n, name_len;
@@
-44,11
+44,12
@@
DnsSend(void)
const char *name;
enum dns_query_type qtype = DNS_A_RECORD;
const char *name;
enum dns_query_type qtype = DNS_A_RECORD;
- name = NetDNSResolve;
- pkt = p = (uchar *)(NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE);
+ name = net_dns_resolve;
+ pkt = (uchar *)(net_tx_packet + net_eth_hdr_size() + IP_UDP_HDR_SIZE);
+ p = pkt;
/* Prepare DNS packet header */
/* Prepare DNS packet header */
- header = (struct header *)
pkt;
+ header = (struct header *)pkt;
header->tid = 1;
header->flags = htons(0x100); /* standard query */
header->nqueries = htons(1); /* Just one query */
header->tid = 1;
header->flags = htons(0x100); /* standard query */
header->nqueries = htons(1); /* Just one query */
@@
-58,7
+59,7
@@
DnsSend(void)
/* Encode DNS name */
name_len = strlen(name);
/* Encode DNS name */
name_len = strlen(name);
- p = (uchar *)
&header->data;
/* For encoding host name into packet */
+ p = (uchar *)
&header->data;
/* For encoding host name into packet */
do {
s = strchr(name, '.');
do {
s = strchr(name, '.');
@@
-87,15
+88,14
@@
DnsSend(void)
n = p - pkt; /* Total packet length */
debug("Packet size %d\n", n);
n = p - pkt; /* Total packet length */
debug("Packet size %d\n", n);
-
DnsOurP
ort = random_port();
+
dns_our_p
ort = random_port();
-
NetSendUDPPacket(NetServerEther, net_dns_server, DNS_SERVICE_PORT
,
-
DnsOurP
ort, n);
+
net_send_udp_packet(net_server_ethaddr, net_dns_server
,
+
DNS_SERVICE_PORT, dns_our_p
ort, n);
debug("DNS packet sent\n");
}
debug("DNS packet sent\n");
}
-static void
-DnsTimeout(void)
+static void dns_timeout_handler(void)
{
puts("Timeout\n");
net_set_state(NETLOOP_FAIL);
{
puts("Timeout\n");
net_set_state(NETLOOP_FAIL);
@@
-108,20
+108,20
@@
static void dns_handler(uchar *pkt, unsigned dest, struct in_addr sip,
const unsigned char *p, *e, *s;
u16 type, i;
int found, stop, dlen;
const unsigned char *p, *e, *s;
u16 type, i;
int found, stop, dlen;
- char
IPS
tr[22];
+ char
ip_s
tr[22];
struct in_addr ip_addr;
debug("%s\n", __func__);
struct in_addr ip_addr;
debug("%s\n", __func__);
- if (dest !=
DnsOurP
ort)
+ if (dest !=
dns_our_p
ort)
return;
for (i = 0; i < len; i += 4)
debug("0x%p - 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n",
return;
for (i = 0; i < len; i += 4)
debug("0x%p - 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n",
-
pkt+i, pkt[i], pkt[i+1], pkt[i+2], pkt[i+3]);
+ pkt+i, pkt[i], pkt[i+1], pkt[i+2], pkt[i+3]);
/* We sent one query. We want to have a single answer: */
/* We sent one query. We want to have a single answer: */
- header = (struct header *)
pkt;
+ header = (struct header *)pkt;
if (ntohs(header->nqueries) != 1)
return;
if (ntohs(header->nqueries) != 1)
return;
@@
-150,7
+150,6
@@
static void dns_handler(uchar *pkt, unsigned dest, struct in_addr sip,
/* Loop through the answers, we want A type answer */
for (found = stop = 0; !stop && &p[12] < e; ) {
/* Loop through the answers, we want A type answer */
for (found = stop = 0; !stop && &p[12] < e; ) {
-
/* Skip possible name in CNAME answer */
if (*p != 0xc0) {
while (*p && &p[12] < e)
/* Skip possible name in CNAME answer */
if (*p != 0xc0) {
while (*p && &p[12] < e)
@@
-169,7
+168,8
@@
static void dns_handler(uchar *pkt, unsigned dest, struct in_addr sip,
p += 12 + dlen;
} else if (type == DNS_A_RECORD) {
debug("Found A-record\n");
p += 12 + dlen;
} else if (type == DNS_A_RECORD) {
debug("Found A-record\n");
- found = stop = 1;
+ found = 1;
+ stop = 1;
} else {
debug("Unknown type\n");
stop = 1;
} else {
debug("Unknown type\n");
stop = 1;
@@
-177,33
+177,32
@@
static void dns_handler(uchar *pkt, unsigned dest, struct in_addr sip,
}
if (found && &p[12] < e) {
}
if (found && &p[12] < e) {
-
dlen = get_unaligned_be16(p+10);
p += 12;
memcpy(&ip_addr, p, 4);
if (p + dlen <= e) {
dlen = get_unaligned_be16(p+10);
p += 12;
memcpy(&ip_addr, p, 4);
if (p + dlen <= e) {
- ip_to_string(ip_addr,
IPS
tr);
- printf("%s\n",
IPS
tr);
- if (
NetDNSenv
var)
-
setenv(NetDNSenvvar, IPS
tr);
- } else
+ ip_to_string(ip_addr,
ip_s
tr);
+ printf("%s\n",
ip_s
tr);
+ if (
net_dns_env_
var)
+
env_set(net_dns_env_var, ip_s
tr);
+ } else
{
puts("server responded with invalid IP number\n");
puts("server responded with invalid IP number\n");
+ }
}
net_set_state(NETLOOP_SUCCESS);
}
}
net_set_state(NETLOOP_SUCCESS);
}
-void
-DnsStart(void)
+void dns_start(void)
{
debug("%s\n", __func__);
{
debug("%s\n", __func__);
-
NetSetTimeout(DNS_TIMEOUT, DnsTimeout
);
+
net_set_timeout_handler(DNS_TIMEOUT, dns_timeout_handler
);
net_set_udp_handler(dns_handler);
/* Clear a previous MAC address, the server IP might have changed. */
net_set_udp_handler(dns_handler);
/* Clear a previous MAC address, the server IP might have changed. */
- memset(
NetServerEther, 0, sizeof(NetServerEthe
r));
+ memset(
net_server_ethaddr, 0, sizeof(net_server_ethadd
r));
-
DnsS
end();
+
dns_s
end();
}
}