AM64x MCU+ SDK  10.00.00
cb_ethernet.h File Reference

Introduction

Bindings to POSIX network functions.

Go to the source code of this file.

Data Structures

struct  cb_rawsock_ovip_para_t
 parameters to open the over IP mode raw socket, the values are in host order More...
 
struct  cb_rawsock_paras_t
 raw socket parameters.to open or create raw socket this structure must be filled. More...
 

Macros

#define CB_MAX_NETDEVNAME   IFNAMSIZ
 
#define CB_SOCKET_T   int
 
#define CB_SOCKET_VALID(x)   ((x)>=0)
 
#define CB_SOCKET_INVALID_VALUE   -1
 
#define CB_ETHHDR_T   struct ethhdr
 
#define CB_SOCKLEN_T   socklen_t
 
#define CB_SOCKADDR_T   struct sockaddr
 
#define CB_SOCKADDR_LL_T   struct sockaddr_ll
 
#define CB_SOCKADDR_IN_T   struct sockaddr_in
 
#define CB_SOCKADDR_IN6_T   struct sockaddr_in6
 
#define CB_SOCKADDR_STORAGE_T   struct sockaddr_storage
 
#define CB_IN_ADDR_T   struct in_addr
 
#define CB_IN6_ADDR_T   struct in6_addr
 
#define CB_IFREQ_T   struct ifreq
 
#define CB_OPEN   open
 
#define CB_CLOSE   close
 
#define CB_WRITE   write
 
#define CB_SOCKET   socket
 
#define CB_IF_NAMETOINDEX   if_nametoindex
 
#define CB_SOCK_BIND   bind
 
#define CB_SOCK_IOCTL   ioctl
 
#define CB_SOCK_CLOSE   close
 
#define CB_SETSOCKOPT   setsockopt
 
#define CB_SOCK_SENDTO   sendto
 
#define CB_SELECT   select
 
#define CB_SOCK_RECVFROM   recvfrom
 
#define CB_SOCK_RECVMSG   recvmsg
 
#define CB_SOCK_WRITE   write
 
#define CB_SOCK_CONNECT   connect
 
#define CB_FCNTL   fcntl
 
#define CB_FD_SET_T   fd_set
 
#define CB_FDSET   FD_SET
 
#define CB_FDCLR   FD_CLR
 
#define CB_FDISSET   FD_ISSET
 
#define CB_FDZERO   FD_ZERO
 
#define CB_VIRTUAL_ETHDEV_PREFIX   "cbeth"
 prefix of virtual network device, which supports raw ethernet packet over udp More...
 
#define CB_VIRTUAL_PTPDEV_PREFIX   "cbptp"
 prefix of virtual ptp device. the suffix must be common with the virtual network device. More...
 
#define CB_VIRTUAL_ETHDEV_MACU32   {0x02,0x01,0x45,0x10}
 virtual MAC address of the virtual network device. the lower 2 bytes are calculated from the suffix More...
 
#define H_SOURCE   h_source
 
#define H_DEST   h_dest
 
#define H_PROTO   h_proto
 
#define PTP_HEAD_MSGTYPE(x)   ((*(uint8_t *) (&((uint8_t *)(x))[0])) & 0x0F)
 forms ptp header msgtype. More...
 
#define PTP_HEAD_SEQID(x)   ((((uint8_t *)(x))[30]<<8u)|(((uint8_t *)(x))[31]))
 macro which is used to form ptp header sequence id. More...
 
#define PTP_HEAD_DOMAIN_NUMBER(x)   (*(uint8_t *)(&((uint8_t *)(x))[4]))
 macro used to form ptp header domain number. More...
 
#define MAX_PTPDEV_NAME   32
 maximum character number of ptp device name More...
 

Typedefs

typedef char ptpdevname_t[MAX_PTPDEV_NAME]
 ptpdevice name. More...
 
typedef char netdevname_t[CB_MAX_NETDEVNAME]
 network device name. More...
 

Enumerations

enum  cb_rawsock_rw_t { CB_RAWSOCK_RDWR = 0, CB_RAWSOCK_RDONLY, CB_RAWSOCK_WRONLY }
 this enumeration defines permission for raw socket. More...
 
enum  cb_sock_mode_t { CB_SOCK_MODE_OVIP = -1, CB_SOCK_MODE_NORMAL }
 

Functions

int cb_get_mac_bydev (CB_SOCKET_T sfd, const char *dev, ub_macaddr_t bmac)
 get mac address from device name like 'eth0' More...
 
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' More...
 
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' More...
 
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 More...
 
int cb_rawsock_close (CB_SOCKET_T fd)
 close the socket opened by cb_rawsock_open More...
 
int cb_sock_set_priority (CB_SOCKET_T fd, int priority)
 set socket priority More...
 
int cb_expand_mtusize (CB_SOCKET_T fd, const char *dev, int *mtusize)
 expand mtusize More...
 
int cb_set_promiscuous_mode (CB_SOCKET_T sfd, const char *dev, bool enable)
 set the promiscuous mode on the socket More...
 
int cb_reg_multicast_address (CB_SOCKET_T fd, const char *dev, const unsigned char *mcastmac, int del)
 register/deregister multicast address to receive More...
 
int cb_get_all_netdevs (int maxdevnum, netdevname_t *netdevs)
 get all network devices name availble in systems. More...
 
int cb_get_ethtool_linkstate (CB_SOCKET_T cfd, const char *dev, uint32_t *linkstate)
 get ethtool link state from device name like 'eth0' More...
 
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' More...
 
int cb_get_netdev_from_ptpdev (char *ptpdev, char *netdev)
 find network device name from ptp device name More...
 
int cb_get_ptpdev_from_netdev (char *netdev, char *ptpdev)
 find ptp device name from network device name More...