aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/include/odp_socket_common.h
blob: f48dabc3b1cff230f9e00d0c7fd6469ae720c201 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* Copyright (c) 2018, Linaro Limited
 * Copyright (c) 2019, Nokia
 * All rights reserved.
 *
 * SPDX-License-Identifier:     BSD-3-Clause
 */

#ifndef ODP_SOCKET_COMMON_H_
#define ODP_SOCKET_COMMON_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <odp/api/packet_io.h>
#include <protocols/eth.h>

#include <string.h>

#define _ODP_SOCKET_MTU_MIN (68 + _ODP_ETHHDR_LEN)
#define _ODP_SOCKET_MTU_MAX (9000 + _ODP_ETHHDR_LEN)

static inline void
ethaddr_copy(unsigned char mac_dst[], unsigned char mac_src[])
{
	memcpy(mac_dst, mac_src, _ODP_ETHADDR_LEN);
}

static inline int
ethaddrs_equal(unsigned char mac_a[], unsigned char mac_b[])
{
	return !memcmp(mac_a, mac_b, _ODP_ETHADDR_LEN);
}

/**
 * Read the MAC address from a packet socket
 */
int _odp_mac_addr_get_fd(int fd, const char *name, unsigned char mac_dst[]);

/**
 * Read the MTU from a packet socket
 */
uint32_t _odp_mtu_get_fd(int fd, const char *name);

/**
 * Set a packet socket MTU
 */
int _odp_mtu_set_fd(int fd, const char *name, int mtu);

/**
 * Enable/Disable promisc mode for a packet socket
 */
int _odp_promisc_mode_set_fd(int fd, const char *name, int enable);

/**
 * Return promisc mode of a packet socket
 */
int _odp_promisc_mode_get_fd(int fd, const char *name);

/**
 * Return link status of a packet socket (up/down)
 */
int _odp_link_status_fd(int fd, const char *name);

/**
 * Read link information from a packet socket
 */
int _odp_link_info_fd(int fd, const char *name, odp_pktio_link_info_t *info);

#ifdef __cplusplus
}
#endif
#endif /* ODP_SOCKET_COMMON_H_ */