1#include "../../network_stack_driver.h"
3#include "../../ptp_defs.h"
4#include "../../ptp_types.h"
5#include "../../task_ptp.h"
7#include "etherlib/cbd_table.h"
8#include "etherlib/connection_block.h"
9#include "etherlib/eth_interface.h"
10#include "etherlib/global_state.h"
11#include "etherlib/prefab/conn_blocks/custom_ethertype_connblock.h"
12#include "etherlib/prefab/conn_blocks/igmp_connblock.h"
13#include "etherlib/prefab/packet_parsers/ethernet_frame.h"
14#include "etherlib/prefab/packet_parsers/ipv4_types.h"
15#include "etherlib/timestamping.h"
37static void ptp_transmit_cb(uint32_t ts_s, uint32_t ts_ns, uint32_t tag);
38static int ptp_receive_cb(
const Pckt *packet, PcktSieveLayerTag tag);
43 ConnBlock cb = igmp_new_connblock(get_default_interface());
45 void (*igmp_fn)(ConnBlock *, ip4_addr) = join ? igmp_report_membership : igmp_leave_group;
57#define CLOSE_CONNECTION_IF_EXISTS(d) \
58 if (d >= CBD_LOWEST_DESCRIPTOR) { \
59 close_connection(d); \
75 if ((init->
tp == -1) || (init->
dm == -1)) {
83 EthInterface *intf = get_default_interface();
113 uint8_t mac_size =
sizeof(
zero_mac);
134 uint16_t pcktClass = packet->header->props.ownPacketClass;
136 case ETH_UDP_PACKET_CLASS:
147 ptp_receive_enqueue(packet->payload, packet->payloadSize, packet->time_s, packet->time_ns, tp);
149 MSG(
"Unknown PTP packet class: '%d'!\n", tp);
171 udp_sendto_arg(conn, pMsg->
data, pMsg->
size, ipaddr, port, uid);
179 memcpy(hwa, get_default_interface()->mac, ETH_HW_ADDR_LEN);
static int ptp_receive_cb(const Pckt *packet, PcktSieveLayerTag tag)
static cbd PTP_L4_PDELAY_GENERAL
void ptp_nsd_transmit_msg(RawPtpMessage *pMsg, uint32_t uid)
static cbd PTP_L4_PRIMARY_EVENT
void ptp_nsd_init(const NsdInitSettings *init)
#define CLOSE_CONNECTION_IF_EXISTS(d)
static PtpDelayMechanism DM
static cbd PTP_L4_PDELAY_EVENT
void ptp_nsd_igmp_join_leave(bool join)
static bool custom_p2p_8023_primary_dest_valid
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 cbd PTP_L4_PRIMARY_GENERAL
static PtpTransportType TP
static void ptp_transmit_cb(uint32_t ts_s, uint32_t ts_ns, uint32_t tag)
static const uint8_t zero_mac[6]
static uint8_t custom_p2p_8023_pdel_dest[6]
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)