]> git.ipfire.org Git - thirdparty/pdns.git/blobdiff - pdns/iputils.hh
Merge pull request #8223 from PowerDNS/omoerbeek-patch-1
[thirdparty/pdns.git] / pdns / iputils.hh
index 6454c342cfbf51f28e9ccf0ea6df61668d6185fe..d0b01adddb47be1f3e0b19e0a189cc1869d07554 100644 (file)
 union ComboAddress {
   struct sockaddr_in sin4;
   struct sockaddr_in6 sin6;
-  // struct sockaddr_in6 is *not* defined as containing two uint64_t for the
-  // address , but we like to read or write it like that.
-  // Force alignment by adding an uint64_t in the union. This makes sure
-  // the start of the struct and s6_addr gets aligned.
-  // This works because of the spot of s6_addr in struct sockaddr_in6.
-  // Needed for strict alignment architectures like sparc64.
-  uint64_t     force_align;
 
   bool operator==(const ComboAddress& rhs) const
   {
@@ -675,7 +668,8 @@ public:
       }
       value = node->node4.get();
     } else {
-      uint64_t* addr = (uint64_t*)key.getNetwork().sin6.sin6_addr.s6_addr;
+      uint64_t addr[2];
+      memcpy(addr, key.getNetwork().sin6.sin6_addr.s6_addr, sizeof(addr));
       std::bitset<64> addr_low(be64toh(addr[1]));
       std::bitset<64> addr_high(be64toh(addr[0]));
       int bits = 0;
@@ -756,7 +750,8 @@ public:
       // needed if we did not find one in loop
       if (node->node4) ret = node->node4.get();
     } else {
-      uint64_t* addr = (uint64_t*)value.sin6.sin6_addr.s6_addr;
+      uint64_t addr[2];
+      memcpy(addr, value.sin6.sin6_addr.s6_addr, sizeof(addr));
       max_bits = std::max(0,std::min(max_bits,128));
       std::bitset<64> addr_low(be64toh(addr[1]));
       std::bitset<64> addr_high(be64toh(addr[0]));
@@ -828,7 +823,8 @@ public:
           cleanup_tree(node);
       }
     } else {
-      uint64_t* addr = (uint64_t*)key.getNetwork().sin6.sin6_addr.s6_addr;
+      uint64_t addr[2];
+      memcpy(addr, key.getNetwork().sin6.sin6_addr.s6_addr, sizeof(addr));
       std::bitset<64> addr_low(be64toh(addr[1]));
       std::bitset<64> addr_high(be64toh(addr[0]));
       int bits = 0;
@@ -1050,6 +1046,7 @@ int SBind(int sockfd, const ComboAddress& local);
 int SAccept(int sockfd, ComboAddress& remote);
 int SListen(int sockfd, int limit);
 int SSetsockopt(int sockfd, int level, int opname, int value);
+void setSocketIgnorePMTU(int sockfd);
 
 #if defined(IP_PKTINFO)
   #define GEN_IP_PKTINFO IP_PKTINFO
@@ -1060,10 +1057,10 @@ int SSetsockopt(int sockfd, int level, int opname, int value);
 bool IsAnyAddress(const ComboAddress& addr);
 bool HarvestDestinationAddress(const struct msghdr* msgh, ComboAddress* destination);
 bool HarvestTimestamp(struct msghdr* msgh, struct timeval* tv);
-void fillMSGHdr(struct msghdr* msgh, struct iovec* iov, char* cbuf, size_t cbufsize, char* data, size_t datalen, ComboAddress* addr);
+void fillMSGHdr(struct msghdr* msgh, struct iovec* iov, cmsgbuf_aligned* cbuf, size_t cbufsize, char* data, size_t datalen, ComboAddress* addr);
 ssize_t sendfromto(int sock, const char* data, size_t len, int flags, const ComboAddress& from, const ComboAddress& to);
-size_t sendMsgWithTimeout(int fd, const char* buffer, size_t len, int idleTimeout, const ComboAddress* dest, const ComboAddress* local, unsigned int localItf, int totalTimeout, int flags);
-bool sendSizeAndMsgWithTimeout(int sock, uint16_t bufferLen, const char* buffer, int idleTimeout, const ComboAddress* dest, const ComboAddress* local, unsigned int localItf, int totalTimeout, int flags);
+size_t sendMsgWithOptions(int fd, const char* buffer, size_t len, const ComboAddress* dest, const ComboAddress* local, unsigned int localItf, int flags);
+
 /* requires a non-blocking, connected TCP socket */
 bool isTCPSocketUsable(int sock);