summaryrefslogtreecommitdiff
path: root/lib/ipv4.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ipv4.h')
-rw-r--r--lib/ipv4.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/ipv4.h b/lib/ipv4.h
index 4c4fab90..b64d9b2a 100644
--- a/lib/ipv4.h
+++ b/lib/ipv4.h
@@ -35,6 +35,7 @@ typedef u32 ip_addr;
#endif
+#define MAX_PREFIX_LENGTH 32
#define BITS_PER_IP_ADDRESS 32
#define STD_ADDRESS_P_LENGTH 15
#define SIZE_OF_IP_HEADER 24
@@ -58,6 +59,9 @@ typedef u32 ip_addr;
#define ipa_from_u32(x) _MI(x)
#define ipa_to_u32(x) _I(x)
#define ipa_compare(x,y) ipv4_compare(_I(x),_I(y))
+/* ipa_pxlen() requires that x != y */
+#define ipa_pxlen(x, y) ipv4_pxlen(_I(x), _I(y))
+#define ipa_getbit(x, y) (_I(x) & (0x80000000 >> (y)))
#define ip_skip_header(x, y) ipv4_skip_header(x, y)
@@ -78,6 +82,12 @@ static inline int ipv4_compare(u32 x, u32 y)
return (x > y) - (x < y);
}
+static inline u32 ipv4_pxlen(u32 a, u32 b)
+{
+ return 31 - u32_log2(a ^ b);
+}
+
+
#define IP_PREC_INTERNET_CONTROL 0xc0
#endif