ptpd 源码解析_PTPD2源码解析之:packet的接收和发送

本文详细解析了PTPD中处理网络包的发送与接收的源码流程,包括unicast和multicast的判断,以及在不同情况下的处理方式。netSendGeneral函数用于发送PTP消息,根据destinationAddress决定unicast或multicast,并调整TTL。netRecvGeneral函数负责接收消息,通过recvfrom或pcap_next_ex进行数据捕获,并更新统计数据。
摘要由CSDN通过智能技术生成

整个流程大概是:

do_state(ptp_master状态)

issueAnnounce

netSendGeneral

handle

netRecvGeneral

ssize_t

netSendGeneral(Octet * buf, UInteger16 length, NetPath * netPath,

const const RunTimeOpts *rtOpts, Integer32 destinationAddress)

{

ssize_t ret;

struct sockaddr_in addr;

addr.sin_family = AF_INET;

addr.sin_port = htons(PTP_GENERAL_PORT);

#ifdef PTPD_PCAP

if ((netPath->pcapGeneral != NULL) && (rtOpts->transport == IEEE_802_3)) {

ret = netSendPcapEther(buf, length,

&netPath->etherDest,

(struct ether_addr *)netPath->interfaceID,

netPath->pcapGeneral);

if (ret <= 0)

DBG("Error sending ether multicast general message\n");

else {

netPath->sentPackets++;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值