-.. code-block:: c
-
- void
- parse_ptp_frames(uint16_t portid, struct rte_mbuf *m) {
- struct ptp_header *ptp_hdr;
- struct rte_ether_hdr *eth_hdr;
- uint16_t eth_type;
-
- eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
- eth_type = rte_be_to_cpu_16(eth_hdr->ether_type);
-
- if (eth_type == PTP_PROTOCOL) {
- ptp_data.m = m;
- ptp_data.portid = portid;
- ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(m, char *)
- + sizeof(struct rte_ether_hdr));
-
- switch (ptp_hdr->msgtype) {
- case SYNC:
- parse_sync(&ptp_data);
- break;
- case FOLLOW_UP:
- parse_fup(&ptp_data);
- break;
- case DELAY_RESP:
- parse_drsp(&ptp_data);
- print_clock_info(&ptp_data);
- break;
- default:
- break;
- }
- }
- }
+.. literalinclude:: ../../../examples/ptpclient/ptpclient.c
+ :language: c
+ :start-after: Parse ptp frames. 8<
+ :end-before: >8 End of function processes PTP packets.