+static bool _is_mapped4(cidr_t *p)
+{
+ return (p->family == AF_INET6 &&
+ p->addr.v6.s6_addr[0] == 0 &&
+ p->addr.v6.s6_addr[1] == 0 &&
+ p->addr.v6.s6_addr[2] == 0 &&
+ p->addr.v6.s6_addr[3] == 0 &&
+ p->addr.v6.s6_addr[4] == 0 &&
+ p->addr.v6.s6_addr[5] == 0 &&
+ p->addr.v6.s6_addr[6] == 0 &&
+ p->addr.v6.s6_addr[7] == 0 &&
+ p->addr.v6.s6_addr[8] == 0 &&
+ p->addr.v6.s6_addr[9] == 0 &&
+ p->addr.v6.s6_addr[10] == 0xFF &&
+ p->addr.v6.s6_addr[11] == 0xFF);
+}
+
+static int cidr_is6mapped4(lua_State *L)
+{
+ cidr_t *p = L_checkcidr(L, 1, NULL);
+
+ lua_pushboolean(L, _is_mapped4(p));
+ return 1;
+}
+