1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <linux/if.h>
#include <linux/if_arp.h>
#include <linux/llc.h>
#include <stdlib.h>
#include "config.h"
#include "net.h"
#include "maps.h" // page_rand
#include "random.h"
#include "utils.h" // ARRAY_SIZE
#include "compat.h"
void llc_gen_sockaddr(struct sockaddr **addr, socklen_t *addrlen)
{
struct sockaddr_llc *llc;
unsigned int i;
llc = malloc(sizeof(struct sockaddr_llc));
if (llc == NULL)
return;
llc->sllc_family = AF_LLC;
llc->sllc_arphrd = ARPHRD_ETHER;
llc->sllc_test = rand();
llc->sllc_xid = rand();
llc->sllc_ua = rand();
llc->sllc_sap = rand();
for (i = 0; i < IFHWADDRLEN; i++)
llc->sllc_mac[i] = rand();
*addr = (struct sockaddr *) llc;
*addrlen = sizeof(struct sockaddr_llc);
}
void llc_rand_socket(struct socket_triplet *st)
{
st->protocol = rand() % PROTO_MAX;
if (rand_bool())
st->type = SOCK_STREAM;
else
st->type = SOCK_DGRAM;
}
#define SOL_LLC 268
#ifndef USE_LLC_OPT_PKTINFO
#define LLC_OPT_PKTINFO LLC_OPT_UNKNOWN
#endif
#define NR_SOL_LLC_OPTS ARRAY_SIZE(llc_opts)
static const unsigned int llc_opts[] = {
LLC_OPT_RETRY, LLC_OPT_SIZE, LLC_OPT_ACK_TMR_EXP, LLC_OPT_P_TMR_EXP,
LLC_OPT_REJ_TMR_EXP, LLC_OPT_BUSY_TMR_EXP, LLC_OPT_TX_WIN, LLC_OPT_RX_WIN,
LLC_OPT_PKTINFO
};
void llc_setsockopt(struct sockopt *so)
{
unsigned char val;
so->level = SOL_LLC;
val = rand() % NR_SOL_LLC_OPTS;
so->optname = llc_opts[val];
}
|