2011-03-31 09:29:22 +05:30
|
|
|
/* arp.h - functions to call the interface change daemon
|
|
|
|
*
|
2015-02-13 12:24:57 +05:30
|
|
|
* Copyright (c) 2010-2015 Nicholas J. Kain <njkain at gmail dot com>
|
2011-07-25 12:00:57 +05:30
|
|
|
* All rights reserved.
|
2011-03-31 09:29:22 +05:30
|
|
|
*
|
2011-07-25 12:00:57 +05:30
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
2011-03-31 09:29:22 +05:30
|
|
|
*
|
2011-07-25 12:00:57 +05:30
|
|
|
* - Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
2011-03-31 09:29:22 +05:30
|
|
|
*
|
2011-07-25 12:00:57 +05:30
|
|
|
* - Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
2011-03-31 09:29:22 +05:30
|
|
|
*/
|
2011-07-05 05:37:16 +05:30
|
|
|
#ifndef ARP_H_
|
|
|
|
#define ARP_H_
|
2010-11-16 06:36:50 +05:30
|
|
|
|
2014-04-15 00:36:31 +05:30
|
|
|
#include <stdbool.h>
|
2010-12-02 10:03:25 +05:30
|
|
|
#include <stdint.h>
|
|
|
|
#include <net/if_arp.h>
|
2014-03-13 02:35:43 +05:30
|
|
|
#include "ndhc.h"
|
2011-07-02 13:21:44 +05:30
|
|
|
#include "dhcp.h"
|
2010-12-24 20:02:58 +05:30
|
|
|
|
2010-12-02 10:03:25 +05:30
|
|
|
struct arpMsg {
|
2011-07-02 16:01:57 +05:30
|
|
|
// Ethernet header
|
|
|
|
uint8_t h_dest[6]; // 00 destination ether addr
|
|
|
|
uint8_t h_source[6]; // 06 source ether addr
|
|
|
|
uint16_t h_proto; // 0c packet type ID field
|
2010-12-02 10:03:25 +05:30
|
|
|
|
2011-07-02 16:01:57 +05:30
|
|
|
// ARP packet
|
|
|
|
uint16_t htype; // 0e hardware type (must be ARPHRD_ETHER)
|
|
|
|
uint16_t ptype; // 10 protocol type (must be ETH_P_IP)
|
|
|
|
uint8_t hlen; // 12 hardware address length (must be 6)
|
|
|
|
uint8_t plen; // 13 protocol address length (must be 4)
|
|
|
|
uint16_t operation; // 14 ARP opcode
|
|
|
|
uint8_t smac[6]; // 16 sender's hardware address
|
|
|
|
uint8_t sip4[4]; // 1c sender's IP address
|
|
|
|
uint8_t dmac[6]; // 20 target's hardware address
|
|
|
|
uint8_t dip4[4]; // 26 target's IP address
|
|
|
|
uint8_t pad[18]; // 2a pad for min. ethernet payload (60 bytes)
|
2010-12-02 10:03:25 +05:30
|
|
|
};
|
|
|
|
|
2013-02-09 11:00:19 +05:30
|
|
|
extern int arp_probe_wait;
|
|
|
|
extern int arp_probe_num;
|
|
|
|
extern int arp_probe_min;
|
|
|
|
extern int arp_probe_max;
|
2011-07-05 22:33:55 +05:30
|
|
|
|
2014-04-15 00:36:31 +05:30
|
|
|
void set_arp_relentless_def(bool v);
|
2014-03-18 07:40:58 +05:30
|
|
|
void arp_reset_send_stats(void);
|
2015-02-14 08:59:03 +05:30
|
|
|
void arp_close_fd(struct client_state_t cs[static 1]);
|
2015-02-14 09:44:08 +05:30
|
|
|
int arp_check(struct client_state_t cs[static 1],
|
|
|
|
struct dhcpmsg packet[static 1]);
|
2015-02-14 08:59:03 +05:30
|
|
|
int arp_gw_check(struct client_state_t cs[static 1]);
|
|
|
|
void arp_set_defense_mode(struct client_state_t cs[static 1]);
|
|
|
|
void arp_success(struct client_state_t cs[static 1]);
|
|
|
|
void handle_arp_response(struct client_state_t cs[static 1]);
|
|
|
|
void handle_arp_timeout(struct client_state_t cs[static 1], long long nowts);
|
2014-03-18 07:40:58 +05:30
|
|
|
long long arp_get_wake_ts(void);
|
2010-11-16 06:36:50 +05:30
|
|
|
|
2011-07-05 05:37:16 +05:30
|
|
|
#endif /* ARP_H_ */
|