MINOR: tools: add port for ipcmp as optional criteria

Complete ipcmp() function with a new argument <check_port>. If this
argument is true, the function will compare port values besides IP
addresses and return true only if both are identical.

This commit will simplify QUIC connection migration detection. As such,
it should be backported to 2.7.
diff --git a/src/tools.c b/src/tools.c
index a392fe5..1f4feda 100644
--- a/src/tools.c
+++ b/src/tools.c
@@ -3323,12 +3323,13 @@
 	return 0;
 }
 
-/* compare two struct sockaddr_storage and return:
+/* compare two struct sockaddr_storage, including port if <check_port> is true,
+ * and return:
  *  0 (true)  if the addr is the same in both
  *  1 (false) if the addr is not the same in both
  *  -1 (unable) if one of the addr is not AF_INET*
  */
-int ipcmp(struct sockaddr_storage *ss1, struct sockaddr_storage *ss2)
+int ipcmp(struct sockaddr_storage *ss1, struct sockaddr_storage *ss2, int check_port)
 {
 	if ((ss1->ss_family != AF_INET) && (ss1->ss_family != AF_INET6))
 		return -1;
@@ -3341,13 +3342,15 @@
 
 	switch (ss1->ss_family) {
 		case AF_INET:
-			return memcmp(&((struct sockaddr_in *)ss1)->sin_addr,
+			return (memcmp(&((struct sockaddr_in *)ss1)->sin_addr,
 				      &((struct sockaddr_in *)ss2)->sin_addr,
-				      sizeof(struct in_addr)) != 0;
+				      sizeof(struct in_addr)) != 0) ||
+			       (check_port && get_net_port(ss1) != get_net_port(ss2));
 		case AF_INET6:
-			return memcmp(&((struct sockaddr_in6 *)ss1)->sin6_addr,
+			return (memcmp(&((struct sockaddr_in6 *)ss1)->sin6_addr,
 				      &((struct sockaddr_in6 *)ss2)->sin6_addr,
-				      sizeof(struct in6_addr)) != 0;
+				      sizeof(struct in6_addr)) != 0) ||
+			       (check_port && get_net_port(ss1) != get_net_port(ss2));
 	}
 
 	return 1;