aboutsummaryrefslogtreecommitdiffstats
path: root/firmware/microblaze/lib/net_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/microblaze/lib/net_common.c')
-rw-r--r--firmware/microblaze/lib/net_common.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/firmware/microblaze/lib/net_common.c b/firmware/microblaze/lib/net_common.c
index 6c9509c92..0a085db3a 100644
--- a/firmware/microblaze/lib/net_common.c
+++ b/firmware/microblaze/lib/net_common.c
@@ -291,8 +291,17 @@ handle_icmp_packet(struct ip_addr src, struct ip_addr dst,
{
switch (icmp->type){
case ICMP_DUR: // Destinatino Unreachable
- //stop_streaming(); //FIXME
if (icmp->code == ICMP_DUR_PORT){ // port unreachable
+ //handle destination port unreachable (the host ctrl+c'd the app):
+
+ //end async update packets per second
+ sr_tx_ctrl->cyc_per_up = 0;
+
+ //the end continuous streaming command
+ sr_rx_ctrl->cmd = (1 << 31) | 1; //one sample, asap
+ sr_rx_ctrl->time_secs = 0;
+ sr_rx_ctrl->time_ticks = 0; //latch the command
+
//struct udp_hdr *udp = (struct udp_hdr *)((char *)icmp + 28);
//printf("icmp port unr %d\n", udp->dest);
putchar('i');
@@ -351,6 +360,22 @@ send_arp_reply(struct arp_eth_ipv4 *req, eth_mac_addr_t our_mac)
send_pkt(t, ETHERTYPE_ARP, &reply, sizeof(reply), 0, 0, 0, 0);
}
+void send_gratuitous_arp(void){
+ struct arp_eth_ipv4 req _AL4;
+ req.ar_hrd = ARPHRD_ETHER;
+ req.ar_pro = ETHERTYPE_IPV4;
+ req.ar_hln = sizeof(eth_mac_addr_t);
+ req.ar_pln = sizeof(struct ip_addr);
+ req.ar_op = ARPOP_REQUEST;
+ memcpy(req.ar_sha, ethernet_mac_addr(), sizeof(eth_mac_addr_t));
+ memcpy(req.ar_sip, get_ip_addr(), sizeof(struct ip_addr));
+ memset(req.ar_tha, 0x00, sizeof(eth_mac_addr_t));
+ memcpy(req.ar_tip, get_ip_addr(), sizeof(struct ip_addr));
+
+ //send the request with a broadcast ethernet mac address
+ eth_mac_addr_t t; memset(&t, 0xff, sizeof(t));
+ send_pkt(t, ETHERTYPE_ARP, &req, sizeof(req), 0, 0, 0, 0);
+}
static void
handle_arp_packet(struct arp_eth_ipv4 *p, size_t size)