#ifndef _NDBOOTD_H
#define _NDBOOTD_H
#if 0
static const char _ndbootd_h_rcsid[] = "<<Id: ndbootd.h,v 1.3 2001/05/22 13:13:20 fredette Exp >>";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <assert.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <net/if.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
#if defined(HAVE_SYS_SOCKIO_H)
#include <sys/sockio.h>
#elif defined(HAVE_SYS_SOCKETIO_H)
#include <sys/socketio.h>
#endif
#include <sys/ioctl.h>
#ifdef HAVE_IOCTLS_H
#include <ioctls.h>
#endif
#ifdef HAVE_NET_IF_ETHER_H
#include <net/if_ether.h>
#endif
#ifdef HAVE_NET_ETHERNET_H
#include <net/ethernet.h>
#endif
#include <netinet/ip.h>
#ifdef HAVE_NET_IF_DL_H
#include <net/if_dl.h>
#endif
#include <arpa/inet.h>
#include <ifaddrs.h>
#ifdef __STDC__
#define _NDBOOTD_P(x) x
#else
#define _NDBOOTD_P(x)
#endif
#undef FALSE
#undef TRUE
#define FALSE (0)
#define TRUE (!FALSE)
#ifndef HAVE_STRERROR
#define strerror(e) ((e) < sys_nerr ? sys_errlist[e] : "unknown error")
#endif
#ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
#if 1
#define _NDBOOTD_DO_DEBUG
#endif
#ifdef _NDBOOTD_DO_DEBUG
#define _NDBOOTD_DEBUG(x) do { if (_ndbootd_debug) { FILE *fp; int saved_errno; fp = stderr; saved_errno = errno; fprintf(fp, "%s: ", _ndbootd_argv0); errno = saved_errno; fprintf x ; fputc('\n', fp); errno = saved_errno; } } while(0)
#else
#define _NDBOOTD_DEBUG(x)
#endif
#define NDBOOTD_PID_FILE "/var/run/ndbootd.pid"
#define NDBOOTD_OFFSETOF(t, m) (((char *) &(((t *) NULL)-> m)) - ((char *) ((t *) NULL)))
#define NDBOOT_OP_READ (0x01)
#define NDBOOT_OP_WRITE (0x02)
#define NDBOOT_OP_ERROR (0x03)
#define NDBOOT_OP_MASK (0x07)
#define NDBOOT_OP_FLAG_WAIT (1 << 3)
#define NDBOOT_OP_FLAG_DONE (1 << 4)
#define NDBOOT_MAX_PACKET_DATA (1024)
#define NDBOOT_MAX_BYTE_COUNT (63 * 1024)
#define NDBOOT_WINDOW_SIZE_DEFAULT (6)
#define NDBOOT_BSIZE (512)
#define NDBOOT_MINOR_NDP0 (0x40)
#undef IPPROTO_ND
#define IPPROTO_ND 77
struct ndbootd_interface {
struct ifreq *ndbootd_interface_ifreq;
u_int8_t ndbootd_interface_ether[ETHER_ADDR_LEN];
int ndbootd_interface_fd;
void *_ndbootd_interface_raw_private;
};
struct ndboot_packet {
u_int8_t ndboot_packet_op;
u_int8_t ndboot_packet_minor;
int8_t ndboot_packet_error;
int8_t ndboot_packet_disk_version;
int32_t ndboot_packet_sequence;
int32_t ndboot_packet_block_number;
int32_t ndboot_packet_byte_count;
int32_t ndboot_packet_residual_byte_count;
int32_t ndboot_packet_current_byte_offset;
int32_t ndboot_packet_current_byte_count;
};
int ndbootd_raw_open _NDBOOTD_P((struct ndbootd_interface *));
int ndbootd_raw_read _NDBOOTD_P((struct ndbootd_interface *, void *, size_t));
int ndbootd_raw_write _NDBOOTD_P((struct ndbootd_interface *, void *, size_t));
#endif