#ifndef _S_ARP_SESSION_H
#define _S_ARP_SESSION_H
#include "FDSet.h"
#include "interfaces.h"
#define ARP_PROBE_COUNT 3
#define ARP_GRATUITOUS_COUNT 2
#define ARP_RETRY_SECS 0
#define ARP_RETRY_USECS 320000
#define ARP_DETECT_COUNT 3
#define ARP_DETECT_RETRY_SECS 0
#define ARP_DETECT_RETRY_USECS 15000
#define ARP_CONFLICT_RETRY_COUNT 2
#define ARP_CONFLICT_RETRY_DELAY_SECS 0
#define ARP_CONFLICT_RETRY_DELAY_USECS 750000
#define ARP_RESOLVE_RETRY_SECS 0
#define ARP_RESOLVE_RETRY_USECS 320000
typedef struct arp_session_values {
int * probe_count;
int * probe_gratuitous_count;
struct timeval * probe_interval;
int * detect_count;
struct timeval * detect_interval;
int * conflict_retry_count;
struct timeval * conflict_delay_interval;
struct timeval * resolve_interval;
} arp_session_values_t;
typedef struct arp_client arp_client_t;
typedef struct {
struct in_addr sender_ip;
struct in_addr target_ip;
uint8_t target_hardware[MAX_LINK_ADDR_LEN];
} arp_address_info_t;
typedef struct {
arp_client_t * client;
boolean_t error;
boolean_t in_use;
arp_address_info_t addr;
} arp_result_t;
typedef void (arp_result_func_t)(void * arg1, void * arg2,
const arp_result_t * result);
typedef boolean_t (arp_our_address_func_t)(interface_t * if_p,
int hwtype, void * hwaddr,
int hwlen);
typedef struct arp_session arp_session_t;
arp_session_t *
arp_session_init(arp_our_address_func_t * func,
arp_session_values_t * values);
void
arp_session_free(arp_session_t * * session_p);
void
arp_session_set_debug(arp_session_t * session, int debug);
void
arp_client_set_probes_are_collisions(arp_client_t * client,
boolean_t probes_are_collisions);
arp_client_t *
arp_client_init(arp_session_t * session, interface_t * if_p);
void
arp_client_free(arp_client_t * * client_p);
const char *
arp_client_errmsg(arp_client_t * client);
void
arp_client_set_probe_info(arp_client_t * client,
const struct timeval * retry_interval,
const int * probe_count,
const int * gratuitous_count);
void
arp_client_restore_default_probe_info(arp_client_t * client);
void
arp_client_probe(arp_client_t * client,
arp_result_func_t * func, void * arg1, void * arg2,
struct in_addr sender_ip, struct in_addr target_ip);
void
arp_client_resolve(arp_client_t * client,
arp_result_func_t * func, void * arg1, void * arg2,
struct in_addr sender_ip, struct in_addr target_ip,
uint32_t resolve_secs);
void
arp_client_detect(arp_client_t * client,
arp_result_func_t * func, void * arg1, void * arg2,
const arp_address_info_t * list, int list_count,
boolean_t resolve);
void
arp_client_cancel(arp_client_t * client);
boolean_t
arp_client_defend(arp_client_t * client, struct in_addr our_ip);
boolean_t
arp_client_is_active(arp_client_t * client);
void
arp_client_announce(arp_client_t * client,
arp_result_func_t * func, void * arg1, void * arg2,
struct in_addr sender_ip, struct in_addr target_ip,
boolean_t skip);
#endif