Skip to content

Commit f6fdf88

Browse files
zhhyu7xiaoxiang781216
authored andcommitted
if_ether: add ether_arp definition
adapts to third-party code compilation. in the process of porting ConnMan, we encounter some situations where the structure is not defined, or the returned data types do not match the expectations. Refer to the common implementation of other systems and add relevant definitions. Signed-off-by: zhanghongyu <[email protected]>
1 parent fc0ecd4 commit f6fdf88

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

include/netinet/if_ether.h

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/****************************************************************************
2+
* include/netinet/if_ether.h
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one or more
5+
* contributor license agreements. See the NOTICE file distributed with
6+
* this work for additional information regarding copyright ownership. The
7+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance with the
9+
* License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
* License for the specific language governing permissions and limitations
17+
* under the License.
18+
*
19+
****************************************************************************/
20+
21+
#ifndef _INCLUDE_NETINET_IF_ETHER_H
22+
#define _INCLUDE_NETINET_IF_ETHER_H
23+
24+
/****************************************************************************
25+
* Included Files
26+
****************************************************************************/
27+
28+
#include <stdint.h>
29+
#include <net/if_arp.h>
30+
#include <net/ethernet.h>
31+
32+
/****************************************************************************
33+
* Pre-processor Definitions
34+
****************************************************************************/
35+
36+
#define ETH_ALEN 6 /* Octets in one ethernet addr */
37+
38+
#define ETH_P_IP ETHERTYPE_IP
39+
#define ETH_P_ARP ETHERTYPE_ARP
40+
41+
/**
42+
* Ethernet Address Resolution Protocol.
43+
*
44+
* See RFC 826 for protocol description. Structure below is adapted
45+
* to resolving internet addresses. Field names used correspond to
46+
* RFC 826.
47+
*/
48+
49+
struct ether_arp
50+
{
51+
struct arphdr ea_hdr; /* fixed-size header */
52+
uint8_t arp_sha[ETH_ALEN]; /* sender hardware address */
53+
uint8_t arp_spa[4]; /* sender protocol address */
54+
uint8_t arp_tha[ETH_ALEN]; /* target hardware address */
55+
uint8_t arp_tpa[4]; /* target protocol address */
56+
};
57+
58+
#define arp_hrd ea_hdr.ar_hrd
59+
#define arp_pro ea_hdr.ar_pro
60+
#define arp_hln ea_hdr.ar_hln
61+
#define arp_pln ea_hdr.ar_pln
62+
#define arp_op ea_hdr.ar_op
63+
64+
#endif /* _INCLUDE_NETINET_IF_ETHER_H */

0 commit comments

Comments
 (0)