/* Keep alive routine for the DEQNA.  Just periodically sends a packet
 * to a net.  This was written just as a simple way to use an extra
 * deqna as a robustness card.  The deqna isn't actually connected to
 * anything.  If it were, then running rip would keep the deqna alive.
 */

#include <types.h>
#include <sys.h>
#include "../src/const.h"
#include "../src/param.h"
#include "../src/defs.h"
#include "../src/macs.h"
#include "../src/net.h"
#include "../src/ext.h"


#define KA_TIME 29

KEEP_ALIVE(netnum)
int netnum;
{
    void ka_tmr();

    itime(ka_tmr, netnum, KA_TIME, 0200);
}

ka_tmr(netnum)
int netnum;
{
    int code;
    iorb *iob;
    static byte ipbrd[4] = { 255, 255, 255, 255 };

    if ((iob = getbuf()) == NULL)
      return;

    mkinpkt(iob, ipbrd, ipbrd, 0, 0);
    if ((code = (nets[netnum].n_send)(iob, &nets[netnum], P_IN, ANYHOST)) != D_OK) {
	iflog(L_ERRU)
	  dolog("Error %d snding keepalive\n", code);
	freebuf(iob);
	return;
    }
}
