2 #include <sys/socket.h>
4 #include <netinet/in.h>
5 #include <bits/sockaddr.h>
6 #include <linux/ax25.h> /* for ax25_address in rose.h */
7 #include <netrose/rose.h>
9 #include "maps.h" // page_rand
11 #include "maps.h" // page_rand
12 #include "utils.h" // ARRAY_SIZE
15 void rose_gen_sockaddr(struct sockaddr
**addr
, socklen_t
*addrlen
)
17 struct sockaddr_rose
*rose
;
19 rose
= malloc(sizeof(struct sockaddr_rose
));
23 rose
->srose_family
= PF_ROSE
;
24 rose
->srose_addr
.rose_addr
[0] = rand();
25 rose
->srose_addr
.rose_addr
[1] = rand();
26 rose
->srose_addr
.rose_addr
[2] = rand();
27 rose
->srose_addr
.rose_addr
[3] = rand();
28 rose
->srose_addr
.rose_addr
[4] = rand();
30 memcpy(rose
->srose_call
.ax25_call
, page_rand
, 7);
32 rose
->srose_ndigis
= rand();
34 memcpy(rose
->srose_digi
.ax25_call
, page_rand
+ 7, 7);
36 *addr
= (struct sockaddr
*) rose
;
37 *addrlen
= sizeof(struct sockaddr_rose
);
40 #define NR_SOL_ROSE_OPTS ARRAY_SIZE(rose_opts)
41 static const unsigned int rose_opts
[] = {
42 ROSE_DEFER
, ROSE_T1
, ROSE_T2
, ROSE_T3
,
43 ROSE_IDLE
, ROSE_QBITINCL
, ROSE_HOLDBACK
};
45 void rose_setsockopt(struct sockopt
*so
)
51 val
= rand() % NR_SOL_ROSE_OPTS
;
52 so
->optname
= rose_opts
[val
];