2 #include <sys/socket.h>
4 #include <netinet/in.h>
5 #include <linux/tipc.h>
9 #include "utils.h" // ARRAY_SIZE
12 void tipc_gen_sockaddr(struct sockaddr
**addr
, socklen_t
*addrlen
)
14 struct sockaddr_tipc
*tipc
;
16 tipc
= malloc(sizeof(struct sockaddr_tipc
));
19 tipc
->family
= AF_TIPC
;
20 tipc
->addrtype
= rand();
22 tipc
->addr
.id
.ref
= rand();
23 tipc
->addr
.id
.node
= rand();
24 tipc
->addr
.nameseq
.type
= rand();
25 tipc
->addr
.nameseq
.lower
= rand();
26 tipc
->addr
.nameseq
.upper
= rand();
27 tipc
->addr
.name
.name
.type
= rand();
28 tipc
->addr
.name
.name
.instance
= rand();
29 tipc
->addr
.name
.domain
= rand();
30 *addr
= (struct sockaddr
*) tipc
;
31 *addrlen
= sizeof(struct sockaddr_tipc
);
34 void tipc_rand_socket(struct socket_triplet
*st
)
39 case 0: st
->type
= SOCK_STREAM
;
41 case 1: st
->type
= SOCK_SEQPACKET
;
43 case 2: st
->type
= SOCK_DGRAM
;
49 #define NR_SOL_TIPC_OPTS ARRAY_SIZE(tipc_opts)
50 static const unsigned int tipc_opts
[] = {
51 TIPC_IMPORTANCE
, TIPC_SRC_DROPPABLE
, TIPC_DEST_DROPPABLE
, TIPC_CONN_TIMEOUT
,
52 TIPC_NODE_RECVQ_DEPTH
, TIPC_SOCK_RECVQ_DEPTH
};
54 void tipc_setsockopt(struct sockopt
*so
)
60 val
= rand() % NR_SOL_TIPC_OPTS
;
61 so
->optname
= tipc_opts
[val
];
63 so
->optval
= sizeof(__u32
);