swapon: add swapflags definitions
[trinity.git] / net / proto-nfc.c
blobe4aa370f546df58cd6babf888a9d519915bda48b
1 #include <sys/types.h>
2 #include <sys/socket.h>
3 #include <sys/un.h>
4 #include <netinet/in.h>
5 #include <stdlib.h>
6 #include "config.h"
7 #include "compat.h"
8 #include "net.h"
9 #include "random.h"
11 void nfc_gen_sockaddr(struct sockaddr **addr, socklen_t *addrlen)
13 struct sockaddr_nfc *nfc;
15 // TODO: See also sockaddr_nfc_llcp
16 nfc = malloc(sizeof(struct sockaddr_nfc));
17 if (nfc == NULL)
18 return;
20 nfc->sa_family = PF_NFC;
21 nfc->dev_idx = rand();
22 nfc->target_idx = rand();
23 nfc->nfc_protocol = rand() % 5;
24 *addr = (struct sockaddr *) nfc;
25 *addrlen = sizeof(struct sockaddr_nfc);
28 void nfc_rand_socket(struct socket_triplet *st)
30 if (rand_bool()) {
31 st->protocol = NFC_SOCKPROTO_LLCP;
32 if (rand_bool())
33 st->type = SOCK_DGRAM;
34 else
35 st->type = SOCK_STREAM;
36 return;
39 st->protocol = NFC_SOCKPROTO_RAW;
40 st->type = SOCK_SEQPACKET;
43 #define SOL_NFC 280
45 void nfc_setsockopt(struct sockopt *so)
47 so->level = SOL_NFC;