|
AM263x 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_STDIN_FILENO STDIN_FILENO
84 #define CB_STDOUT_FILENO STDOUT_FILENO
85 #define CB_STDERR_FILENO STDERR_FILENO
86 #define CB_SOCKET_INC(x) ((x)+1)
87 #define CB_ETHHDR_T struct ethhdr
88 #define CB_SOCKLEN_T socklen_t
89 #define CB_SOCKADDR_T struct sockaddr
90 #define CB_SOCKADDR_LL_T struct sockaddr_ll
91 #define CB_SOCKADDR_IN_T struct sockaddr_in
92 #define CB_SOCKADDR_IN6_T struct sockaddr_in6
93 #define CB_SOCKADDR_STORAGE_T struct sockaddr_storage
94 #define CB_IN_ADDR_T struct in_addr
95 #define CB_IN6_ADDR_T struct in6_addr
96 #define CB_IFREQ_T struct ifreq
99 #define CB_CLOSE close
100 #define CB_WRITE write
101 #define CB_SOCKET socket
102 #define CB_IF_NAMETOINDEX if_nametoindex
103 #define CB_SOCK_BIND bind
104 #define CB_SOCK_IOCTL ioctl
105 #define CB_SOCK_CLOSE close
106 #define CB_SETSOCKOPT setsockopt
107 #define CB_SOCK_SENDTO sendto
108 #define CB_SELECT select
109 #define CB_SOCK_RECVFROM recvfrom
110 #define CB_SOCK_RECVMSG recvmsg
111 #define CB_SOCK_WRITE write
112 #define CB_SOCK_CONNECT connect
114 #define CB_FCNTL fcntl
115 #define CB_FD_SET_T fd_set
116 #define CB_FDSET FD_SET
117 #define CB_FDCLR FD_CLR
118 #define CB_FDISSET FD_ISSET
119 #define CB_FDZERO FD_ZERO
121 #endif // CB_ETHERNET_NON_POSIX_H
129 #define CB_VIRTUAL_ETHDEV_PREFIX "cbeth"
135 #define CB_VIRTUAL_PTPDEV_PREFIX "cbptp"
141 #define CB_VIRTUAL_ETHDEV_MACU32 {0x02,0x01,0x45,0x10}
145 #define H_SOURCE h_source
149 #define H_DEST h_dest
153 #define H_PROTO h_proto
162 #define PTP_HEAD_MSGTYPE(x) ((*(uint8_t *) (&((uint8_t *)(x))[0])) & 0x0F)
167 #define PTP_HEAD_SEQID(x) ((((uint8_t *)(x))[30]<<8u)|(((uint8_t *)(x))[31]))
172 #define PTP_HEAD_DOMAIN_NUMBER(x) (*(uint8_t *)(&((uint8_t *)(x))[4]))
175 #define MAX_PTPDEV_NAME 32
201 typedef struct cb_rawsock_ovip_para {
217 typedef struct cb_rawsock_paras{
330 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
Normal L2 raw socket.
Definition: cb_ethernet.h:210
cb_sock_mode_t sock_mode
-1:raw socket over udp, 0:normal,
Definition: cb_ethernet.h:223
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
L2 packets over IP socket for testing.
Definition: cb_ethernet.h:209
#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:175
uint32_t laddr
local IP address
Definition: cb_ethernet.h:202
@ CB_RAWSOCK_RDWR
Definition: cb_ethernet.h:193
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:195
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:227
uint16_t vlan_proto
protocol value in VLAN tag, not used in non-tagged
Definition: cb_ethernet.h:220
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:225
char netdevname_t[CB_MAX_NETDEVNAME]
network device name.
Definition: cb_ethernet.h:233
uint32_t daddr
destination IP address
Definition: cb_ethernet.h:204
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:222
cb_rawsock_rw_t
this enumeration defines permission for raw socket.
Definition: cb_ethernet.h:192
raw socket parameters.to open or create raw socket this structure must be filled.
Definition: cb_ethernet.h:217
uint16_t proto
protocol value like ETH_P_1588
Definition: cb_ethernet.h:219
uint16_t dport
destination IP port
Definition: cb_ethernet.h:205
int priority
PCP priority value in VLAN tag.
Definition: cb_ethernet.h:221
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:224
uint32_t sndbuf
socket send buffer size, set to 0 to use default value
Definition: cb_ethernet.h:226
#define CB_SOCKADDR_LL_T
Definition: cb_ethernet.h:90
parameters to open the over IP mode raw socket, the values are in host order
Definition: cb_ethernet.h:201
@ CB_RAWSOCK_RDONLY
Definition: cb_ethernet.h:194
const char * dev
ethernet device name
Definition: cb_ethernet.h:218
@ CB_SOCK_MODE_LSM
L2 raw socket for QNX LSM mode.
Definition: cb_ethernet.h:211
uint16_t lport
local IP port
Definition: cb_ethernet.h:203
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:179
cb_sock_mode_t
Definition: cb_ethernet.h:208
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:94
#define CB_MAX_NETDEVNAME
Definition: cb_ethernet.h:79