0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-23 02:01:55 +00:00
bird/socktest/snd.c
2016-04-06 15:57:26 +02:00

48 lines
757 B
C

#include "common.h"
static int
do_sendmsg(sock *s, void *pkt, size_t len)
{
memcpy(s->ttx, pkt, len);
s->tpos = s->ttx + len;
if (cf_count && ++counter > cf_count)
exit(0);
return sk_write(s);
}
static void
connected_hook(sock *s)
{
printf("Start sending...\n");
s->tx_hook = NULL;
}
int
main(int argc, char *argv[])
{
socktest_bird_init();
sock *s = socktest_parse_args(argc, argv, 1);
s->tx_hook = connected_hook;
s->tbsize = 1500;
s->tos = IP_PREC_INTERNET_CONTROL;
socktest_open(s);
struct socktest_packet pkt = {
.magic = htonl(PKT_MAGIC),
.value = htonl(cf_value),
};
int count = 0;
while (1)
{
pkt.count = htonl(++count);
do_sendmsg(s, &pkt, sizeof(pkt));
usleep(200000);
}
}