3 #include <sys/socket.h>
5 #include <netinet/in.h>
6 #include <netax25/ax25.h>
7 #include "maps.h" // page_rand
10 #include "utils.h" // ARRAY_SIZE
13 void ax25_gen_sockaddr(struct sockaddr
**addr
, socklen_t
*addrlen
)
15 struct sockaddr_ax25
*ax25
;
17 ax25
= malloc(sizeof(struct sockaddr_ax25
));
21 ax25
->sax25_family
= PF_AX25
;
22 memcpy(ax25
->sax25_call
.ax25_call
, page_rand
, 7);
23 ax25
->sax25_ndigis
= rand();
24 *addr
= (struct sockaddr
*) ax25
;
25 *addrlen
= sizeof(struct sockaddr_ax25
);
28 #define NR_AX25_PROTOS 13
29 static int ax25_protocols
[NR_AX25_PROTOS
] = {
31 0x06, /* Compressed TCP/IP packet *//* Van Jacobsen (RFC 1144) */
32 0x07, /* Uncompressed TCP/IP packet *//* Van Jacobsen (RFC 1144) */
33 0x08, /* Segmentation fragment */
34 0xc3, /* TEXTNET datagram protocol */
35 0xc4, /* Link Quality Protocol */
37 0xcb, /* Appletalk ARP */
38 0xcc, /* ARPA Internet Protocol */
39 0xcd, /* ARPA Address Resolution */
42 0xF0 /* No layer 3 protocol impl. */
45 void ax25_rand_socket(struct socket_triplet
*st
)
48 case 0: st
->type
= SOCK_DGRAM
;
51 case 1: st
->type
= SOCK_SEQPACKET
;
52 st
->protocol
= ax25_protocols
[rand() % NR_AX25_PROTOS
];
54 case 2: st
->type
= SOCK_RAW
;
60 #define NR_SOL_AX25_OPTS ARRAY_SIZE(ax25_opts)
61 static const unsigned int ax25_opts
[] = {
62 AX25_WINDOW
, AX25_T1
, AX25_N2
, AX25_T3
,
63 AX25_T2
, AX25_BACKOFF
, AX25_EXTSEQ
, AX25_PIDINCL
,
64 AX25_IDLE
, AX25_PACLEN
, AX25_IAMDIGI
,
67 void ax25_setsockopt(struct sockopt
*so
)
73 val
= rand() % NR_SOL_AX25_OPTS
;
74 so
->optname
= ax25_opts
[val
];