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

Method UDPBind

src/iocore/net/UnixUDPNet.cc:1157–1307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1155}
1156
1157Action *
1158UDPNetProcessor::UDPBind(Continuation *cont, sockaddr const *addr, int fd, int send_bufsize, int recv_bufsize)
1159{
1160 UnixUDPConnection *n = nullptr;
1161 IpEndpoint myaddr;
1162 socklen_t myaddr_len = sizeof(myaddr);
1163 PollCont *pc = nullptr;
1164 PollDescriptor *pd = nullptr;
1165 bool need_bind = true;
1166 UnixSocket sock{fd};
1167
1168 if (!sock.is_ok()) {
1169 sock = UnixSocket{addr->sa_family, SOCK_DGRAM, 0};
1170 if (!sock.is_ok()) {
1171 goto Lerror;
1172 }
1173 } else {
1174 need_bind = false;
1175 }
1176 if (fcntl(sock.get_fd(), F_SETFL, O_NONBLOCK) < 0) {
1177 goto Lerror;
1178 }
1179
1180 if (addr->sa_family == AF_INET) {
1181 bool succeeded = false;
1182#ifdef IP_PKTINFO
1183 if (sock.enable_option(IPPROTO_IP, IP_PKTINFO) == 0) {
1184 succeeded = true;
1185 }
1186#endif
1187#ifdef IP_RECVDSTADDR
1188 if (sock.enable_option(IPPROTO_IP, IP_RECVDSTADDR) == 0) {
1189 succeeded = true;
1190 }
1191#endif
1192 if (!succeeded) {
1193 Dbg(dbg_ctl_udpnet, "setsockeopt for pktinfo failed");
1194 goto Lerror;
1195 }
1196#ifdef IP_MTU_DISCOVER
1197 int probe = IP_PMTUDISC_PROBE; // Set DF but ignore Path MTU
1198 if (safe_setsockopt(sock.get_fd(), IPPROTO_IP, IP_MTU_DISCOVER, &probe, sizeof(probe)) == -1) {
1199 Dbg(dbg_ctl_udpnet, "setsockeopt for IP_MTU_DISCOVER failed");
1200 }
1201#endif
1202 } else if (addr->sa_family == AF_INET6) {
1203 bool succeeded = false;
1204#ifdef IPV6_PKTINFO
1205 if (sock.enable_option(IPPROTO_IPV6, IPV6_PKTINFO) == 0) {
1206 succeeded = true;
1207 }
1208#endif
1209#ifdef IPV6_RECVPKTINFO
1210 if (sock.enable_option(IPPROTO_IPV6, IPV6_RECVPKTINFO) == 0) {
1211 succeeded = true;
1212 }
1213#endif
1214 if (!succeeded) {

Callers 2

startMethod · 0.80
acceptEventMethod · 0.80

Calls 15

ats_is_ip_multicastFunction · 0.85
ats_is_ip6Function · 0.85
ats_ip_sizeFunction · 0.85
get_UDPPollContFunction · 0.85
get_UDPNetHandlerFunction · 0.85
enable_optionMethod · 0.80
set_rcvbuf_sizeMethod · 0.80
set_sndbuf_sizeMethod · 0.80
getsocknameMethod · 0.80
setBindingMethod · 0.80
bindToThreadMethod · 0.80
getThreadAffinityMethod · 0.80

Tested by 1

startMethod · 0.64