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"
38 err_t (*igmp_fn)(
const ip_addr_t *,
const ip_addr_t *) = join ? igmp_joingroup : igmp_leavegroup;
78 if ((init->
tp == -1) || (init->
dm == -1)) {
116 const uint8_t mac_size =
sizeof(
zero_mac);
163 struct pbuf *p = NULL;
164 p = pbuf_alloc((
TP ==
PTP_TP_IPv4) ? PBUF_TRANSPORT : PBUF_LINK, pMsg->
size, PBUF_RAM);
174 memcpy(p->payload, pMsg->
data, pMsg->
size);
177 p->tag = (
void *)uid;
191 udp_sendto(conn, p, &ipaddr, port);
193 const uint8_t *ethaddr = isPDel_ ?
196 ethernet_output(netif_default, p, (
struct eth_addr *)netif_default->hwaddr, (
struct eth_addr *)ethaddr,
ETHERTYPE_PTP);
224 memcpy(hwa, netif_default->hwaddr, netif_default->hwaddr_len);
227#define ETHERNET_HEADER_LENGTH (14)
232 uint16_t etherType = 0;
233 memcpy(ðerType, ((uint8_t *)pbuf->payload) + 12, 2);
void ptp_transmit_free(struct pbuf *pPBuf)
static struct udp_pcb * PTP_L4_PRIMARY_GENERAL
void ptp_nsd_transmit_msg(RawPtpMessage *pMsg, uint32_t uid)
err_t hook_unknown_ethertype(struct pbuf *pbuf, struct netif *netif)
void ptp_nsd_init(const NsdInitSettings *init)
static PtpDelayMechanism DM
void ptp_nsd_igmp_join_leave(bool join)
static bool custom_p2p_8023_primary_dest_valid
static struct udp_pcb * PTP_L4_PDELAY_EVENT
#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 uint8_t custom_p2p_8023_primary_dest[6]
static bool custom_p2p_8023_pdel_dest_valid
static void ptp_transmit_cb(uint32_t ts_s, uint32_t ts_ns, void *tag)
static PtpTransportType TP
static const uint8_t zero_mac[6]
static uint8_t custom_p2p_8023_pdel_dest[6]
static struct udp_pcb * PTP_L4_PDELAY_GENERAL
static struct udp_pcb * PTP_L4_PRIMARY_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.
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.
PtpMessageType
PTP packet type enumeration.
@ PTP_MT_PDelay_Resp
Peer Delay Response.
@ PTP_MT_PDelay_Req
Peer Delay Request.
@ PTP_MT_PDelay_Resp_Follow_Up
Peer Delay Response Follow Up.
PtpDelayMechanism
PTP Delay mechanism enumeration.
@ PTP_DM_P2P
Peer-to-Peer Delay Mechanism.
Network Stack Driver initialization object.
uint8_t primary_p2p_8023_dest[6]
Destination address for primary P2P messages over Ethernet.
uint8_t pdelay_p2p_8023_dest[6]
Destination address for PDel* P2P messages over Ethernet.
PtpDelayMechanism dm
Delay Mechanism.
PtpTransportType tp
Transport Type.
PtpMessageClass tx_mc
transmit message class
PtpMessageType tx_mt
transmit message type
uint32_t size
Packet size.
uint8_t data[(128)]
raw packet data
void ptp_receive_enqueue(const void *pPayload, uint32_t len, uint32_t ts_sec, uint32_t ts_ns, int tp)
void ptp_transmit_timestamp_cb(uint32_t uid, uint32_t seconds, uint32_t nanoseconds)