31 std::string localname = options.getLocalName();
32 std::string servername = options.getServerName();
33 uint16_t port = options.getLocalPort();
36 uint8_t family = (options.getIpVersion() == 6) ? AF_INET6 : AF_INET;
40 if (family != remoteaddr.getFamily()) {
42 "Values for IP version: " <<
43 static_cast<unsigned int>(options.getIpVersion()) <<
44 " and server address: " << servername <<
" are mismatched.");
48 if (family == AF_INET6) {
50 port = DHCP6_CLIENT_PORT;
52 if (options.isUseRelayedV6()) {
53 port = DHCP6_SERVER_PORT;
55 }
else if (options.getIpVersion() == 4) {
62 if (!localname.empty()) {
66 if (options.isInterface()) {
75 }
else if (!servername.empty()) {
89 if ((options.getIpVersion() == 4) && options.isBroadcast()) {
90 int broadcast_enable = 1;
91 int ret = setsockopt(sock, SOL_SOCKET, SO_BROADCAST,
92 &broadcast_enable,
sizeof(broadcast_enable));
95 "unable to set broadcast option on the socket");
97 }
else if (options.getIpVersion() == 6) {
100 if (remoteaddr.isV6Multicast()) {
102 int ret = setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
103 &hops,
sizeof(hops));
106 if ((ret >= 0) && options.isInterface()) {
111 << options.getLocalName());
113 int idx = iface->getIndex();
114 ret = setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_IF,
119 "unable to enable multicast on socket " << sock
120 <<
". errno = " << errno);