#ifndef _S_HOSTLIST_H
#define _S_HOSTLIST_H
#include <netinet/in.h>
struct hosts {
struct hosts *next;
struct hosts *prev;
struct in_addr iaddr;
u_char htype;
u_char hlen;
union {
struct ether_addr en;
u_char generic[256];
} haddr;
char * hostname;
char * bootfile;
struct timeval tv;
u_long lease;
};
struct hosts * hostadd(struct hosts * * hosts, struct timeval * tv_p,
int htype, char * haddr, int hlen,
struct in_addr * iaddr_p, char * host_name,
char * bootfile);
void hostfree(struct hosts * * hosts, struct hosts * hp);
void hostinsert(struct hosts * * hosts, struct hosts * hp);
void hostprint(struct hosts * hp);
void hostremove(struct hosts * * hosts, struct hosts * hp);
void hostlistfree(struct hosts * * hosts);
typedef boolean_t subnet_match_func_t(void * arg, struct in_addr iaddr);
static __inline__ struct hosts *
hostbyip(struct hosts * hosts, struct in_addr iaddr)
{
struct hosts * hp;
for (hp = hosts; hp; hp = hp->next) {
if (iaddr.s_addr == hp->iaddr.s_addr)
return (hp);
}
return (NULL);
}
static __inline__ struct hosts *
hostbyaddr(struct hosts * hosts, u_char hwtype, void * hwaddr, int hwlen,
subnet_match_func_t * func, void * arg)
{
struct hosts * hp;
for (hp = hosts; hp; hp = hp->next) {
if (hwtype == hp->htype
&& hwlen == hp->hlen
&& bcmp(hwaddr, &hp->haddr, hwlen) == 0) {
if (func == NULL
|| (*func)(arg, hp->iaddr)) {
return (hp);
}
}
}
return (NULL);
}
#endif _S_HOSTLIST_H