mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-23 02:01:55 +00:00
b4c639d9ae
Using `make sockettest` generetes `snd` and `rcv` binaries. It can be used for testing BIRD's sockets. Based on code by Ondrej Zajicek
46 lines
730 B
C
46 lines
730 B
C
#include "common.h"
|
|
|
|
int
|
|
do_sendmsg(sock *s, void *pkt, size_t len)
|
|
{
|
|
memcpy(s->ttx, pkt, len);
|
|
s->tpos = s->ttx + len;
|
|
return sk_write(s);
|
|
}
|
|
|
|
void
|
|
connected_hook(sock *s)
|
|
{
|
|
printf("Iface %s \n", s->iface->name, s->iface->addr);
|
|
printf("Start sending...\n");
|
|
s->tx_hook = NULL;
|
|
}
|
|
|
|
int
|
|
main(int argc, char **argv)
|
|
{
|
|
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)
|
|
{
|
|
pkt.count = htonl(count);
|
|
do_sendmsg(s, &pkt, sizeof(pkt));
|
|
count++;
|
|
|
|
usleep(200000);
|
|
}
|
|
}
|