OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [bootloaders/] [orpmon/] [services/] [arp.c] - Diff between revs 175 and 406

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 175 Rev 406
Line 30... Line 30...
#include "string.h"
#include "string.h"
 
 
#define TIMEOUT         5               /* Seconds before trying ARP again */
#define TIMEOUT         5               /* Seconds before trying ARP again */
#define TIMEOUT_COUNT   1               /* # of timeouts before giving up  */
#define TIMEOUT_COUNT   1               /* # of timeouts before giving up  */
#define DEBUG // jb
#define DEBUG // jb
static void ArpHandler(unsigned char *pkt, unsigned dest, unsigned src, unsigned len);
static void ArpHandler(unsigned char *pkt, unsigned dest, unsigned src,
 
                       unsigned len);
static void ArpTimeout(void);
static void ArpTimeout(void);
 
 
int     ArpTry = 0;
int     ArpTry = 0;
 
 
/*
/*
Line 50... Line 51...
#endif
#endif
                TftpStart ();
                TftpStart ();
        }
        }
}
}
 
 
 
 
/*
/*
 *      Timeout on ARP request.
 *      Timeout on ARP request.
 */
 */
static void
static void ArpTimeout(void)
ArpTimeout(void)
 
{
{
        if (ArpTry >= TIMEOUT_COUNT) {
        if (ArpTry >= TIMEOUT_COUNT) {
                printf("\nRetry count exceeded; starting again\n");
                printf("\nRetry count exceeded; starting again\n");
                NetStartAgain ();
                NetStartAgain ();
        } else {
        } else {
                NetSetTimeout (TIMEOUT * TICKS_PER_SEC, ArpTimeout);
                NetSetTimeout (TIMEOUT * TICKS_PER_SEC, ArpTimeout);
                ArpRequest ();
                ArpRequest ();
        }
        }
}
}
 
 
 
void ArpRequest(void)
void
 
ArpRequest (void)
 
{
{
        int i;
        int i;
        volatile unsigned char *pkt;
        volatile unsigned char *pkt;
        ARP_t * arp;
        ARP_t * arp;
#ifdef  DEBUG
#ifdef  DEBUG
        printf("ARP broadcast %d\n", ++ArpTry);
        printf("ARP broadcast %d\n", ++ArpTry);
#endif  
#endif  
 
        // NetTxPacket is a char* to global buffer used for constructing 
 
        // a packet to send.
        pkt = NetTxPacket;
        pkt = NetTxPacket;
 
 
 
        // Setup an ethernet header for ARP protocol in packet
        NetSetEther(pkt, NetBcastAddr, PROT_ARP);
        NetSetEther(pkt, NetBcastAddr, PROT_ARP);
        pkt += ETHER_HDR_SIZE;
        pkt += ETHER_HDR_SIZE;
 
 
        arp = (ARP_t *)pkt;
        arp = (ARP_t *)pkt;
 
 
Line 112... Line 112...
 
 
        NetSetTimeout(TIMEOUT * TICKS_PER_SEC, ArpTimeout);
        NetSetTimeout(TIMEOUT * TICKS_PER_SEC, ArpTimeout);
        NetSetHandler(ArpHandler);
        NetSetHandler(ArpHandler);
}
}
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.