MCPcopy Create free account
hub / github.com/apache/trafficserver / SendUDPPacket

Method SendUDPPacket

src/iocore/net/UnixUDPNet.cc:1443–1608  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1441}
1442
1443void
1444UDPQueue::SendUDPPacket(UDPPacket *p)
1445{
1446 struct msghdr msg;
1447 struct iovec iov[32];
1448 int n, count = 0;
1449
1450 p->p.conn->lastSentPktStartTime = p->p.delivery_time;
1451 Dbg(dbg_ctl_udp_send, "Sending %p", p);
1452
1453 msg.msg_control = nullptr;
1454 msg.msg_controllen = 0;
1455 msg.msg_flags = 0;
1456 msg.msg_name = reinterpret_cast<caddr_t>(&p->to.sa);
1457 msg.msg_namelen = ats_ip_size(p->to);
1458
1459#if defined(SOL_UDP) || defined(HAVE_SO_TXTIME) // to avoid unused variables compiler warning.
1460 struct cmsghdr *cm = nullptr;
1461 uint8_t msg_ctrl[0
1462#ifdef SOL_UDP
1463 + CMSG_SPACE(sizeof(uint16_t))
1464#endif
1465#ifdef HAVE_SO_TXTIME
1466 + CMSG_SPACE(sizeof(uint64_t))
1467#endif
1468 ];
1469 memset(msg_ctrl, 0, sizeof(msg_ctrl));
1470#endif // defined(SOL_UDP) || defined(HAVE_SO_TXTIME)
1471
1472#ifdef HAVE_SO_TXTIME
1473 if (p->p.send_at.tv_sec > 0) {
1474 msg.msg_control = msg_ctrl;
1475 msg.msg_controllen = CMSG_SPACE(sizeof(uint64_t));
1476 cm = CMSG_FIRSTHDR(&msg);
1477
1478 cm->cmsg_level = SOL_SOCKET;
1479 cm->cmsg_type = SCM_TXTIME;
1480 cm->cmsg_len = CMSG_LEN(sizeof(uint64_t));
1481
1482 // Convert struct timespec to nanoseconds.
1483 *(reinterpret_cast<uint64_t *>(CMSG_DATA(cm))) = p->p.send_at.tv_sec * (1000ULL * 1000 * 1000) + p->p.send_at.tv_nsec;
1484 }
1485#endif
1486
1487 if (p->p.segment_size > 0) {
1488 ink_assert(p->p.chain->next == nullptr);
1489 msg.msg_iov = iov;
1490 msg.msg_iovlen = 1;
1491#ifdef SOL_UDP
1492 if (use_udp_gso) {
1493 iov[0].iov_base = p->p.chain.get()->start();
1494 iov[0].iov_len = p->p.chain.get()->size();
1495
1496 union udp_segment_hdr {
1497 char buf[CMSG_SPACE(sizeof(uint16_t))];
1498 struct cmsghdr align;
1499 } u;
1500

Callers

nothing calls this directly

Calls 7

ats_ip_sizeFunction · 0.85
memsetFunction · 0.85
getFdMethod · 0.80
startMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected