2 #include <sys/socket.h>
4 #include <netinet/in.h>
6 #include <linux/if_arp.h>
7 #include <linux/if_packet.h>
9 #include "maps.h" // page_rand
12 #include "utils.h" // ARRAY_SIZE
15 void ipv6_gen_sockaddr(struct sockaddr
**addr
, socklen_t
*addrlen
)
17 struct sockaddr_in6
*ipv6
;
19 ipv6
= malloc(sizeof(struct sockaddr_in6
));
23 ipv6
->sin6_family
= PF_INET6
;
24 ipv6
->sin6_addr
.s6_addr32
[0] = 0;
25 ipv6
->sin6_addr
.s6_addr32
[1] = 0;
26 ipv6
->sin6_addr
.s6_addr32
[2] = 0;
27 ipv6
->sin6_addr
.s6_addr32
[3] = htonl(1);
28 ipv6
->sin6_port
= htons(rand() % 65535);
29 *addr
= (struct sockaddr
*) ipv6
;
30 *addrlen
= sizeof(struct sockaddr_in6
);
33 void inet6_rand_socket(struct socket_triplet
*st
)
36 case 0: st
->type
= SOCK_STREAM
; // TCP
40 case 1: st
->type
= SOCK_DGRAM
; // UDP
44 st
->protocol
= IPPROTO_UDP
;
47 case 2: st
->type
= SOCK_RAW
;
48 st
->protocol
= rand() % PROTO_MAX
;
55 #define NR_SOL_INET6_OPTS ARRAY_SIZE(inet6_opts)
56 static const unsigned int inet6_opts
[] = {
57 IPV6_ADDRFORM
, IPV6_2292PKTINFO
, IPV6_2292HOPOPTS
, IPV6_2292DSTOPTS
,
58 IPV6_2292RTHDR
, IPV6_2292PKTOPTIONS
, IPV6_CHECKSUM
, IPV6_2292HOPLIMIT
,
59 IPV6_NEXTHOP
, IPV6_AUTHHDR
, IPV6_FLOWINFO
, IPV6_UNICAST_HOPS
,
60 IPV6_MULTICAST_IF
, IPV6_MULTICAST_HOPS
, IPV6_MULTICAST_LOOP
, IPV6_ADD_MEMBERSHIP
,
61 IPV6_DROP_MEMBERSHIP
, IPV6_ROUTER_ALERT
, IPV6_MTU_DISCOVER
, IPV6_MTU
,
62 IPV6_RECVERR
, IPV6_V6ONLY
, IPV6_JOIN_ANYCAST
, IPV6_LEAVE_ANYCAST
};
64 void inet6_setsockopt(struct sockopt
*so
)
70 val
= rand() % NR_SOL_INET6_OPTS
;
71 so
->optname
= inet6_opts
[val
];