• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification,
5  * are permitted provided that the following conditions are met:
6  *
7  * 1. Redistributions of source code must retain the above copyright notice, this list of
8  *    conditions and the following disclaimer.
9  *
10  * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11  *    of conditions and the following disclaimer in the documentation and/or other materials
12  *    provided with the distribution.
13  *
14  * 3. Neither the name of the copyright holder nor the names of its contributors may be used
15  *    to endorse or promote products derived from this software without specific prior written
16  *    permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
22  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef _ADAPT_NET_IF_ARP_H
32 #define _ADAPT_NET_IF_ARP_H
33 
34 #include <inttypes.h>
35 #include <sys/types.h>
36 #include <sys/socket.h>
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 #define MAX_ADDR_LEN        7
43 
44 #define ARPOP_REQUEST       1
45 #define ARPOP_REPLY         2
46 #define ARPOP_RREQUEST      3
47 #define ARPOP_RREPLY        4
48 #define ARPOP_InREQUEST     8
49 #define ARPOP_InREPLY       9
50 #define ARPOP_NAK           10
51 
52 #define ATF_INUSE           0x01
53 #define ATF_COM             0x02
54 #define ATF_PERM            0x04
55 #define ATF_PUBL            0x08
56 #define ATF_USETRAILERS     0x10
57 
58 #define ARPD_UPDATE         0x01
59 #define ARPD_LOOKUP         0x02
60 #define ARPD_FLUSH          0x03
61 
62 struct arphdr {
63     uint16_t ar_hrd;
64     uint16_t ar_pro;
65     uint8_t ar_hln;
66     uint8_t ar_pln;
67     uint16_t ar_op;
68 };
69 
70 #define ARP_DEV_LEN         16
71 struct arpreq {
72     struct sockaddr arp_pa;
73     struct sockaddr arp_ha;
74     int arp_flags;
75     struct sockaddr arp_netmask;
76     char arp_dev[ARP_DEV_LEN];
77 };
78 
79 struct arpreq_old {
80     struct sockaddr arp_pa;
81     struct sockaddr arp_ha;
82     int arp_flags;
83     struct sockaddr arp_netmask;
84 };
85 
86 struct arpd_request {
87     unsigned short req;
88     uint32_t ip;
89     unsigned long dev;
90     unsigned long stamp;
91     unsigned long updated;
92     unsigned char ha[MAX_ADDR_LEN];
93 };
94 
95 #ifdef __cplusplus
96 }
97 #endif
98 
99 #endif /* !_ADAPT_NET_IF_ARP_H */
100