rename
[trinity.git] / net / proto-can.c
blobb3ae781736d0e7e41f9c3d924fd14a2590fecbde
1 #include <sys/types.h>
2 #include <sys/socket.h>
3 #include <sys/un.h>
4 #include <netinet/in.h>
5 #include <linux/can.h>
6 #include <stdlib.h>
7 #include "net.h"
8 #include "random.h"
9 #include "compat.h"
11 void can_gen_sockaddr(struct sockaddr **addr, socklen_t *addrlen)
13 struct sockaddr_can *can;
15 can = malloc(sizeof(struct sockaddr_can));
16 if (can == NULL)
17 return;
18 can->can_family = AF_CAN;
19 can->can_ifindex = rand();
20 can->can_addr.tp.rx_id = rand();
21 can->can_addr.tp.tx_id = rand();
22 *addr = (struct sockaddr *) can;
23 *addrlen = sizeof(struct sockaddr_can);
26 void can_rand_socket(struct socket_triplet *st)
28 st->protocol = rand() % 7; // CAN_NPROTO
29 st->type = rand() % TYPE_MAX;