2 #include <sys/socket.h>
4 #include <netinet/in.h>
7 #include "maps.h" // page_rand
10 #include "utils.h" // ARRAY_SIZE
13 void decnet_gen_sockaddr(struct sockaddr
**addr
, socklen_t
*addrlen
)
15 struct sockaddr_dn
*dn
;
18 dn
= malloc(sizeof(struct sockaddr_dn
));
22 dn
->sdn_family
= PF_DECnet
;
23 dn
->sdn_flags
= rand();
24 dn
->sdn_objnum
= rand();
25 dn
->sdn_objnamel
= rand() % 16;
26 for (i
= 0; i
< dn
->sdn_objnamel
; i
++)
27 dn
->sdn_objname
[i
] = rand();
28 dn
->sdn_add
.a_len
= rand() % 2;
29 dn
->sdn_add
.a_addr
[0] = rand();
30 dn
->sdn_add
.a_addr
[1] = rand();
31 *addr
= (struct sockaddr
*) dn
;
32 *addrlen
= sizeof(struct sockaddr_dn
);
35 void decnet_rand_socket(struct socket_triplet
*st
)
38 st
->type
= SOCK_SEQPACKET
;
39 st
->protocol
= DNPROTO_NSP
;
41 st
->type
= SOCK_STREAM
;
42 st
->protocol
= rand() % PROTO_MAX
;
46 #define NR_SOL_DECNET_OPTS ARRAY_SIZE(decnet_opts)
47 static const unsigned int decnet_opts
[] = {
48 SO_CONDATA
, SO_CONACCESS
, SO_PROXYUSR
, SO_LINKINFO
,
49 DSO_CONDATA
, DSO_DISDATA
, DSO_CONACCESS
, DSO_ACCEPTMODE
,
50 DSO_CONACCEPT
, DSO_CONREJECT
, DSO_LINKINFO
, DSO_STREAM
,
51 DSO_SEQPACKET
, DSO_MAXWINDOW
, DSO_NODELAY
, DSO_CORK
,
52 DSO_SERVICES
, DSO_INFO
55 void decnet_setsockopt(struct sockopt
*so
)
59 so
->level
= SOL_DECNET
;
61 val
= rand() % NR_SOL_DECNET_OPTS
;
62 so
->optname
= decnet_opts
[val
];
64 // TODO: set optlen correctly