2016-03-29 06:24:54 +00:00
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
int
|
|
|
|
do_sendmsg(sock *s, void *pkt, size_t len)
|
|
|
|
{
|
|
|
|
memcpy(s->ttx, pkt, len);
|
|
|
|
s->tpos = s->ttx + len;
|
2016-04-01 07:38:14 +00:00
|
|
|
|
|
|
|
if (cf_count && ++counter > cf_count)
|
|
|
|
exit(0);
|
|
|
|
|
2016-03-29 06:24:54 +00:00
|
|
|
return sk_write(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
connected_hook(sock *s)
|
|
|
|
{
|
|
|
|
printf("Start sending...\n");
|
|
|
|
s->tx_hook = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2016-04-01 07:38:14 +00:00
|
|
|
main(int argc, char *argv[])
|
2016-03-29 06:24:54 +00:00
|
|
|
{
|
|
|
|
bird_init();
|
|
|
|
|
|
|
|
sock *s = skt_parse_args(argc, argv, 1);
|
|
|
|
s->tx_hook = connected_hook;
|
|
|
|
s->tbsize = 1500;
|
|
|
|
s->tos = IP_PREC_INTERNET_CONTROL;
|
|
|
|
|
|
|
|
skt_open(s);
|
|
|
|
|
|
|
|
struct my_packet pkt = {
|
|
|
|
.magic = htonl(PKT_MAGIC),
|
|
|
|
.value = htonl(cf_value),
|
|
|
|
};
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
while (1)
|
|
|
|
{
|
2016-04-01 07:38:14 +00:00
|
|
|
pkt.count = htonl(++count);
|
2016-03-29 06:24:54 +00:00
|
|
|
do_sendmsg(s, &pkt, sizeof(pkt));
|
|
|
|
|
|
|
|
usleep(200000);
|
|
|
|
}
|
|
|
|
}
|