The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
arp.h
Go to the documentation of this file.
1#pragma once
2/*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16 */
17
18/*
19 * $Id: a7bcc2eea215a780785d07b9e88b212586490818 $
20 *
21 * @file protocols/arp/arp.h
22 * @brief Structures and prototypes for base RADIUS functionality.
23 *
24 * @copyright 2020 Network RADIUS SAS (legal@networkradius.com)
25 */
26#include <freeradius-devel/util/packet.h>
27#include <freeradius-devel/util/rand.h>
28#include <freeradius-devel/util/log.h>
29#include <freeradius-devel/util/net.h>
30
31#include <freeradius-devel/protocol/arp/dictionary.h>
32#include <freeradius-devel/protocol/arp/rfc826.h>
33
34/* for SIOCSARP, and fr_arp_entry_add */
35#include <sys/ioctl.h>
36
37#define FR_ARP_PACKET_SIZE (28)
38#define ETH_TYPE_ARP (0x0806)
39
40int fr_arp_global_init(void);
41void fr_arp_global_free(void);
42
43ssize_t fr_arp_encode(fr_dbuff_t *dbuff, uint8_t const *original, fr_pair_list_t *vps);
44ssize_t fr_arp_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *packet, size_t packet_len);
45
46int fr_arp_entry_add(int fd, char const *interface, uint8_t ipaddr[static 4], uint8_t macaddr[static 6]);
47
48/*
49 * ARP for ethernet && IPv4.
50 */
51typedef struct {
52 uint8_t htype[2]; //!< Format of hardware address.
53 uint8_t ptype[2]; //!< Format of protocol address.
54 uint8_t hlen; //!< Length of hardware address.
55 uint8_t plen; //!< Length of protocol address.
56 uint8_t op[2]; //!< 1 - Request, 2 - Reply.
57 uint8_t sha[ETHER_ADDR_LEN]; //!< sender hardware address.
58 uint8_t spa[4]; //!< Sender protocol address.
59 uint8_t tha[ETHER_ADDR_LEN]; //!< Target hardware address.
60 uint8_t tpa[4]; //!< Target protocol address.
62
72
73#define FR_ARP_PACKET_CODE_VALID(_code) (((_code) > 0) && ((_code) < FR_ARP_CODE_MAX))
74
75extern char const *fr_arp_packet_codes[FR_ARP_CODE_MAX];
uint8_t hlen
Length of hardware address.
Definition arp.h:54
void fr_arp_global_free(void)
Definition base.c:284
int fr_arp_global_init(void)
Definition base.c:261
uint8_t plen
Length of protocol address.
Definition arp.h:55
fr_arp_packet_code_t
Definition arp.h:63
@ FR_ARP_CODE_MAX
Definition arp.h:69
@ FR_ARP_INVALID
Definition arp.h:64
@ FR_ARP_REVERSE_REQUEST
Definition arp.h:67
@ FR_ARP_REQUEST
Definition arp.h:65
@ FR_ARP_DO_NOT_RESPOND
Definition arp.h:70
@ FR_ARP_REVERSE_REPLY
Definition arp.h:68
@ FR_ARP_REPLY
Definition arp.h:66
ssize_t fr_arp_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *packet, size_t packet_len)
Decode a raw ARP packet into VPs.
Definition base.c:221
char const * fr_arp_packet_codes[FR_ARP_CODE_MAX]
Definition base.c:63
ssize_t fr_arp_encode(fr_dbuff_t *dbuff, uint8_t const *original, fr_pair_list_t *vps)
Encode VPS into a raw ARP packet.
Definition base.c:146
int fr_arp_entry_add(int fd, char const *interface, uint8_t ipaddr[static 4], uint8_t macaddr[static 6])
long int ssize_t
unsigned char uint8_t
#define ETHER_ADDR_LEN
Definition net.h:64
static size_t char ** out
Definition value.h:997