1#include "../../network_stack_driver.h"
3#include "../../ptp_defs.h"
4#include "../../task_ptp.h"
8#include "lwip/ip4_addr.h"
9#include "lwip/ip_addr.h"
10#include "lwip/netif.h"
12#include "netif/ethernet.h"
24static void ptp_transmit_cb(uint32_t ts_s, uint32_t ts_ns, uint32_t tag);
30 err_t (*igmp_fn)(
const ip_addr_t *,
const ip_addr_t *) = join ? igmp_joingroup : igmp_leavegroup;
57 if ((tp == -1) || (dm == -1)) {
100 if (pMsg->
pTs != NULL) {
121 struct pbuf *p = NULL;
122 p = pbuf_alloc((
TP ==
PTP_TP_IPv4) ? PBUF_TRANSPORT : PBUF_LINK, pMsg->
size, PBUF_RAM);
125 memcpy(p->payload, pMsg->
data, pMsg->
size);
136 udp_sendto(conn, p, &ipaddr, port);
139 ethernet_output(netif_default, p, (
struct eth_addr *)netif_default->hwaddr, (
struct eth_addr *)ethaddr,
ETHERTYPE_PTP);
150 memcpy(hwa, netif_default->hwaddr, netif_default->hwaddr_len);
153#define ETHERNET_HEADER_LENGTH (14)
158 uint16_t etherType = 0;
159 memcpy(ðerType, ((uint8_t *)pbuf->payload) + 12, 2);
PtpCircBuf gRawTxMsgBuf
Output circular buffers.
void ptp_nsd_transmit_msg(RawPtpMessage *pMsg)
void ptp_transmit_free(struct pbuf *pPBuf)
err_t hook_unknown_ethertype(struct pbuf *pbuf, struct netif *netif)
static PtpDelayMechanism DM
void ptp_nsd_igmp_join_leave(bool join)
void ptp_nsd_init(PtpTransportType tp, PtpDelayMechanism dm)
static struct udp_pcb * PTP_L4_GENERAL
#define ETHERNET_HEADER_LENGTH
static void ptp_receive_cb(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
void ptp_nsd_get_interface_address(uint8_t *hwa)
static PtpTransportType TP
static void ptp_transmit_cb(uint32_t ts_s, uint32_t ts_ns, uint32_t tag)
static struct udp_pcb * PTP_L4_EVENT
const uint8_t PTP_ETHERNET_PEER_DELAY[6]
PTP's L2 Peer_Delay Ethernet address.
const uint8_t PTP_ETHERNET_PRIMARY[6]
PTP's L2 Primary Ethernet address.
const ip_addr_t PTP_IGMP_PRIMARY
Primary IGMP address.
#define ETHERTYPE_PTP
(for lwIP conformity)
#define PTP_PORT_EVENT
PTP event message port.
#define PTP_PORT_GENERAL
PTP general message port.
const ip_addr_t PTP_IGMP_PEER_DELAY
Peer_Delay IGMP address.
void ptp_circ_buf_free(PtpCircBuf *pCircBuf)
PtpTransportType
PTP transport type enumeration.
@ PTP_TP_IPv4
IPv4 Transport Type.
@ PTP_TP_802_3
Ethernet Transport Type.
PtpMessageClass
Enumeration for different PTP message classes.
@ PTP_MC_EVENT
Event Message Class.
PtpDelayMechanism
PTP Delay mechanism enumeration.
@ PTP_DM_E2E
End-to-End Delay Mechanism.
@ PTP_DM_P2P
Peer-to-Peer Delay Mechanism.
Raw PTP message structure.
PtpMessageClass tx_mc
transmit message class
void(* pTxCb)(const struct RawPtpMessage_ *pMsg)
transmit callback function
uint32_t size
Packet size.
TimestampI * pTs
pointer to timestamp
uint8_t data[(128)]
raw packet data
int32_t nanosec
nanoseconds
void ptp_receive_enqueue(const void *pPayload, uint32_t len, uint32_t ts_sec, uint32_t ts_ns, int tp)