summaryrefslogtreecommitdiffstats
path: root/firmware/microblaze/lib
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-03-16 17:54:54 -0700
committerJosh Blum <josh@joshknows.com>2010-03-16 17:54:54 -0700
commit6458eca9540f11fb8dd5bee184e6124998023c4f (patch)
tree17d69f06e918b346e50e4b3aad24a1da071fd2cf /firmware/microblaze/lib
parent52dc73891474827a9c686f73cbfe70618a2dd6e4 (diff)
downloaduhd-6458eca9540f11fb8dd5bee184e6124998023c4f.tar.gz
uhd-6458eca9540f11fb8dd5bee184e6124998023c4f.tar.bz2
uhd-6458eca9540f11fb8dd5bee184e6124998023c4f.zip
Added recovery app to use raw socket to burn known ip addr.
Fixed up fw so the device can reply after new addrs are set.
Diffstat (limited to 'firmware/microblaze/lib')
-rw-r--r--firmware/microblaze/lib/ethernet.c2
-rw-r--r--firmware/microblaze/lib/net_common.c23
-rw-r--r--firmware/microblaze/lib/net_common.h13
3 files changed, 13 insertions, 25 deletions
diff --git a/firmware/microblaze/lib/ethernet.c b/firmware/microblaze/lib/ethernet.c
index 0e731c68c..34a3ad7c1 100644
--- a/firmware/microblaze/lib/ethernet.c
+++ b/firmware/microblaze/lib/ethernet.c
@@ -320,7 +320,7 @@ ethernet_set_mac_addr(const eth_mac_addr_t *t)
if (ok){
src_mac_addr = *t;
src_mac_addr_initialized = true;
- eth_mac_set_addr(t);
+ //eth_mac_set_addr(t); //this breaks the link
}
return ok;
diff --git a/firmware/microblaze/lib/net_common.c b/firmware/microblaze/lib/net_common.c
index 693502d18..67a3ff964 100644
--- a/firmware/microblaze/lib/net_common.c
+++ b/firmware/microblaze/lib/net_common.c
@@ -51,16 +51,14 @@ ip_addr_eq(const struct ip_addr a, const struct ip_addr b)
// ------------------------------------------------------------------------
-get_eth_mac_addr_t _get_eth_mac_addr = NULL;
-
-void register_get_eth_mac_addr(get_eth_mac_addr_t get_eth_mac_addr){
- _get_eth_mac_addr = get_eth_mac_addr;
+static eth_mac_addr_t _local_mac_addr;
+void register_mac_addr(const eth_mac_addr_t *mac_addr){
+ _local_mac_addr = *mac_addr;
}
-get_ip_addr_t _get_ip_addr = NULL;
-
-void register_get_ip_addr(get_ip_addr_t get_ip_addr){
- _get_ip_addr = get_ip_addr;
+static struct ip_addr _local_ip_addr;
+void register_ip_addr(const struct ip_addr *ip_addr){
+ _local_ip_addr = *ip_addr;
}
//-------------------------------------------------------------------------
@@ -140,7 +138,7 @@ send_pkt(eth_mac_addr_t dst, int ethertype,
padded_eth_hdr_t ehdr;
ehdr.pad = 0;
ehdr.dst = dst;
- ehdr.src = _get_eth_mac_addr();
+ ehdr.src = _local_mac_addr;
ehdr.ethertype = ethertype;
uint32_t *p = buffer_ram(CPU_TX_BUF);
@@ -218,7 +216,6 @@ send_ip_pkt(struct ip_addr dst, int protocol,
const void *buf0, size_t len0,
const void *buf1, size_t len1)
{
- struct ip_addr src = _get_ip_addr();
int ttl = 32;
struct ip_hdr ip;
@@ -228,7 +225,7 @@ send_ip_pkt(struct ip_addr dst, int protocol,
IPH_OFFSET_SET(&ip, IP_DF); /* don't fragment */
ip._ttl_proto = (ttl << 8) | (protocol & 0xff);
ip._chksum = 0;
- ip.src = src;
+ ip.src = _local_ip_addr;
ip.dest = dst;
ip._chksum = ~chksum_buffer((unsigned short *) &ip,
@@ -373,8 +370,8 @@ handle_arp_packet(struct arp_eth_ipv4 *p, size_t size)
sip.addr = get_int32(p->ar_sip);
tip.addr = get_int32(p->ar_tip);
- if (ip_addr_eq(tip, _get_ip_addr())){ // They're looking for us...
- send_arp_reply(p, _get_eth_mac_addr());
+ if (ip_addr_eq(tip, _local_ip_addr)){ // They're looking for us...
+ send_arp_reply(p, _local_mac_addr);
}
}
diff --git a/firmware/microblaze/lib/net_common.h b/firmware/microblaze/lib/net_common.h
index 6cd45bf69..112669b46 100644
--- a/firmware/microblaze/lib/net_common.h
+++ b/firmware/microblaze/lib/net_common.h
@@ -33,21 +33,12 @@ extern dbsm_t *ac_could_be_sending_to_eth;
void stop_streaming(void);
-/*!
- * Helpful typedefs for callback
- */
typedef void (*udp_receiver_t)(struct socket_address src, struct socket_address dst,
unsigned char *payload, int payload_len);
-typedef eth_mac_addr_t (*get_eth_mac_addr_t)(void);
-typedef struct ip_addr (*get_ip_addr_t)(void);
-
-/*!
- * Functions to register callbacks
- */
-void register_get_eth_mac_addr(get_eth_mac_addr_t get_eth_mac_addr);
+void register_mac_addr(const eth_mac_addr_t *mac_addr);
-void register_get_ip_addr(get_ip_addr_t get_ip_addr);
+void register_ip_addr(const struct ip_addr *ip_addr);
void register_udp_listener(int port, udp_receiver_t rcvr);