|
AM64x MCU+ SDK
10.00.00
|
|
Go to the documentation of this file.
59 #ifndef CB_ETHERNET_H_
60 #define CB_ETHERNET_H_
62 #ifdef CB_ETHERNET_NON_POSIX_H
66 #include CB_ETHERNET_NON_POSIX_H
69 #include <sys/socket.h>
70 #include <sys/ioctl.h>
71 #include <netinet/in.h>
73 #include <net/if_arp.h>
76 #include <netpacket/packet.h>
77 #include <net/ethernet.h>
79 #define CB_MAX_NETDEVNAME IFNAMSIZ
80 #define CB_SOCKET_T int
81 #define CB_SOCKET_VALID(x) ((x)>=0)
82 #define CB_SOCKET_INVALID_VALUE -1
83 #define CB_ETHHDR_T struct ethhdr
84 #define CB_SOCKLEN_T socklen_t
85 #define CB_SOCKADDR_T struct sockaddr
86 #define CB_SOCKADDR_LL_T struct sockaddr_ll
87 #define CB_SOCKADDR_IN_T struct sockaddr_in
88 #define CB_SOCKADDR_IN6_T struct sockaddr_in6
89 #define CB_SOCKADDR_STORAGE_T struct sockaddr_storage
90 #define CB_IN_ADDR_T struct in_addr
91 #define CB_IN6_ADDR_T struct in6_addr
92 #define CB_IFREQ_T struct ifreq
95 #define CB_CLOSE close
96 #define CB_WRITE write
97 #define CB_SOCKET socket
98 #define CB_IF_NAMETOINDEX if_nametoindex
99 #define CB_SOCK_BIND bind
100 #define CB_SOCK_IOCTL ioctl
101 #define CB_SOCK_CLOSE close
102 #define CB_SETSOCKOPT setsockopt
103 #define CB_SOCK_SENDTO sendto
104 #define CB_SELECT select
105 #define CB_SOCK_RECVFROM recvfrom
106 #define CB_SOCK_RECVMSG recvmsg
107 #define CB_SOCK_WRITE write
108 #define CB_SOCK_CONNECT connect
110 #define CB_FCNTL fcntl
111 #define CB_FD_SET_T fd_set
112 #define CB_FDSET FD_SET
113 #define CB_FDCLR FD_CLR
114 #define CB_FDISSET FD_ISSET
115 #define CB_FDZERO FD_ZERO
117 #endif // CB_ETHERNET_NON_POSIX_H
125 #define CB_VIRTUAL_ETHDEV_PREFIX "cbeth"
131 #define CB_VIRTUAL_PTPDEV_PREFIX "cbptp"
137 #define CB_VIRTUAL_ETHDEV_MACU32 {0x02,0x01,0x45,0x10}
141 #define H_SOURCE h_source
145 #define H_DEST h_dest
149 #define H_PROTO h_proto
158 #define PTP_HEAD_MSGTYPE(x) ((*(uint8_t *) (&((uint8_t *)(x))[0])) & 0x0F)
163 #define PTP_HEAD_SEQID(x) ((((uint8_t *)(x))[30]<<8u)|(((uint8_t *)(x))[31]))
168 #define PTP_HEAD_DOMAIN_NUMBER(x) (*(uint8_t *)(&((uint8_t *)(x))[4]))
171 #define MAX_PTPDEV_NAME 32
197 typedef struct cb_rawsock_ovip_para {
212 typedef struct cb_rawsock_paras{
325 const unsigned char *mcastmac,
int del);
int cb_expand_mtusize(CB_SOCKET_T fd, const char *dev, int *mtusize)
expand mtusize
@ CB_SOCK_MODE_NORMAL
Definition: cb_ethernet.h:206
cb_sock_mode_t sock_mode
-1:raw socket over udp, 0:normal,
Definition: cb_ethernet.h:218
int cb_get_netdev_from_ptpdev(char *ptpdev, char *netdev)
find network device name from ptp device name
int cb_set_promiscuous_mode(CB_SOCKET_T sfd, const char *dev, bool enable)
set the promiscuous mode on the socket
int cb_get_ethtool_info(CB_SOCKET_T cfd, const char *dev, uint32_t *speed, uint32_t *duplex)
get ethtool info(speed and duplex) from device name like 'eth0'
@ CB_SOCK_MODE_OVIP
Definition: cb_ethernet.h:205
#define CB_SOCKET_T
Definition: cb_ethernet.h:80
int cb_rawsock_open(cb_rawsock_paras_t *llrawp, CB_SOCKET_T *fd, CB_SOCKADDR_LL_T *addr, int *mtusize, ub_macaddr_t bmac)
generic raw ethernet open
#define MAX_PTPDEV_NAME
maximum character number of ptp device name
Definition: cb_ethernet.h:171
uint64_t addr
Definition: csl_udmap_tr.h:3
uint32_t laddr
local IP address
Definition: cb_ethernet.h:198
@ CB_RAWSOCK_RDWR
Definition: cb_ethernet.h:189
int cb_rawsock_close(CB_SOCKET_T fd)
close the socket opened by cb_rawsock_open
int cb_get_mac_bydev(CB_SOCKET_T sfd, const char *dev, ub_macaddr_t bmac)
get mac address from device name like 'eth0'
int cb_get_ethtool_linkstate(CB_SOCKET_T cfd, const char *dev, uint32_t *linkstate)
get ethtool link state from device name like 'eth0'
@ CB_RAWSOCK_WRONLY
Definition: cb_ethernet.h:191
int cb_get_ptpdev_from_netdev(char *netdev, char *ptpdev)
find ptp device name from network device name
uint32_t rcvbuf
socket receive buffer size, set to 0 to use default value
Definition: cb_ethernet.h:222
uint16_t vlan_proto
protocol value in VLAN tag, not used in non-tagged
Definition: cb_ethernet.h:215
int cb_get_brdip_bydev(CB_SOCKET_T sfd, const char *dev, CB_IN_ADDR_T *inp)
get broadcast ip address from device name like 'eth0'
uint16_t vlanid
vlan identifier
Definition: cb_ethernet.h:220
char netdevname_t[CB_MAX_NETDEVNAME]
network device name.
Definition: cb_ethernet.h:228
uint32_t daddr
destination IP address
Definition: cb_ethernet.h:200
ub_bytearray6_t ub_macaddr_t
6-byte binary array is used for MAC Address
Definition: ub_strutils.h:71
cb_rawsock_rw_t rw_type
one of RAWSOCK_WRONLY, RAWSOCK_RDONLY, RAWSOCK_RDWR
Definition: cb_ethernet.h:217
cb_rawsock_rw_t
this enumeration defines permission for raw socket.
Definition: cb_ethernet.h:188
raw socket parameters.to open or create raw socket this structure must be filled.
Definition: cb_ethernet.h:212
uint16_t proto
protocol value like ETH_P_1588
Definition: cb_ethernet.h:214
uint16_t dport
destination IP port
Definition: cb_ethernet.h:201
int priority
PCP priority value in VLAN tag.
Definition: cb_ethernet.h:216
int cb_reg_multicast_address(CB_SOCKET_T fd, const char *dev, const unsigned char *mcastmac, int del)
register/deregister multicast address to receive
cb_rawsock_ovip_para_t * ovipp
over-udp mode parameter
Definition: cb_ethernet.h:219
uint32_t sndbuf
socket send buffer size, set to 0 to use default value
Definition: cb_ethernet.h:221
#define CB_SOCKADDR_LL_T
Definition: cb_ethernet.h:86
parameters to open the over IP mode raw socket, the values are in host order
Definition: cb_ethernet.h:197
@ CB_RAWSOCK_RDONLY
Definition: cb_ethernet.h:190
const char * dev
ethernet device name
Definition: cb_ethernet.h:213
uint16_t lport
local IP port
Definition: cb_ethernet.h:199
int cb_sock_set_priority(CB_SOCKET_T fd, int priority)
set socket priority
char ptpdevname_t[MAX_PTPDEV_NAME]
ptpdevice name.
Definition: cb_ethernet.h:175
cb_sock_mode_t
Definition: cb_ethernet.h:204
int cb_get_all_netdevs(int maxdevnum, netdevname_t *netdevs)
get all network devices name availble in systems.
int cb_get_ip_bydev(CB_SOCKET_T sfd, const char *dev, CB_IN_ADDR_T *inp)
get ip address from device name like 'eth0'
#define CB_IN_ADDR_T
Definition: cb_ethernet.h:90
#define CB_MAX_NETDEVNAME
Definition: cb_ethernet.h:79