45 protocolId_ = dest.
port();
53 reinterpret_cast<void*
> (&*packet.
data().
begin()),
55 reinterpret_cast<in_addr*
> (&destination_),
57 reinterpret_cast<in_addr*> (&source_)) > 0;
60 prefix_ int senf::ppi::IPv4SourceForcingDgramWriter::sendtoandfrom(
68 uint8_t cbuf[CMSG_SPACE(
sizeof(
struct in_pktinfo))];
69 struct cmsghdr *c =
reinterpret_cast<cmsghdr *
>(cbuf);
70 struct in_pktinfo *pi;
74 c->cmsg_len = CMSG_LEN(
sizeof(
struct in_pktinfo));
75 c->cmsg_level = IPPROTO_IP;
76 c->cmsg_type = IP_PKTINFO;
78 pi =
reinterpret_cast<in_pktinfo *
>(CMSG_DATA(c));
80 memcpy(&pi->ipi_addr, &src->s_addr,
sizeof(src->s_addr));
82 iov.iov_base =
const_cast<void *
>(
data);
83 iov.iov_len = dataLen;
86 memset(&dstpeer, 0,
sizeof(dstpeer));
87 dstpeer.sin_family = AF_INET;
88 dstpeer.sin_addr = *dst;
89 dstpeer.sin_port = htons(port);
91 memset(&h, 0,
sizeof(h));
92 h.msg_name = (
struct sockaddr *)&dstpeer;
93 h.msg_namelen =
sizeof(dstpeer);
97 h.msg_controllen =
sizeof(cbuf);
99 return sendmsg(sock, &h, 0);
124 protocolId_ = dest.
port();
130 return sendtoandfrom(
132 reinterpret_cast<void*
> (&*packet.
data().
begin()),
134 reinterpret_cast<in6_addr*
> (&destination_),
136 reinterpret_cast<in6_addr*> (&source_)) > 0;
139 prefix_ int senf::ppi::IPv6SourceForcingDgramWriter::sendtoandfrom(
147 uint8_t cbuf[CMSG_SPACE(
sizeof(
struct in6_pktinfo))];
148 struct cmsghdr *c =
reinterpret_cast<cmsghdr *
>(cbuf);
149 struct in6_pktinfo *pi;
153 c->cmsg_len = CMSG_LEN(
sizeof(
struct in6_pktinfo));
154 c->cmsg_level = IPPROTO_IPV6;
155 c->cmsg_type = IPV6_PKTINFO;
157 pi =
reinterpret_cast<in6_pktinfo *
>(CMSG_DATA(c));
158 pi->ipi6_ifindex = 0;
159 memcpy(&pi->ipi6_addr, src, 16);
161 iov.iov_base =
const_cast<void *
>(
data);
162 iov.iov_len = dataLen;
164 sockaddr_in6 dstpeer;
165 memset(&dstpeer, 0,
sizeof(dstpeer));
166 dstpeer.sin6_family = AF_INET6;
167 dstpeer.sin6_addr = *dst;
168 dstpeer.sin6_port = htons(port);
170 memset(&h, 0,
sizeof(h));
171 h.msg_name = (
struct sockaddr *)&dstpeer;
172 h.msg_namelen =
sizeof(dstpeer);
176 h.msg_controllen =
sizeof(cbuf);
178 return sendmsg(sock, &h, 0);
bool operator()(Handle &handle, Packet const &packet)
Write packet to handle.
senf::PacketSocketHandle Handle
static INet6Address from_string(std::string const &s, Resolve_t resolve=ResolveINet6)
u8 data[SPECTRAL_HT20_NUM_BINS]
IPv4SourceForcingDgramWriter()
PacketData & data() const
bool operator()(Handle &handle, Packet const &packet)
Write packet to handle.
struct sockaddr * sockaddr_p()
senf::INet6SocketAddress destination()
void socklen(socklen_t len)
SocketSink public header.
static INet4Address from_string(std::string const &s)
senf::INet4Address source()
IPv6SourceForcingDgramWriter()
void target(LLSocketAddress const &target)
senf::INet6Address source()
senf::INet4SocketAddress destination()
INet6Address address() const
INet4Address address() const
void source(Handle &, LLSocketAddress source)