mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-23 10:11:53 +00:00
2ce8589753
Changes: - Remove -R command line option (it's automatic, system dependent) - Fix mixing of broadcast and binding - Add -c command line option for count of packet - Fix receiving broadcast - Scan all interfaces via device protocol (unfortunately it is ugly)
64 lines
1.3 KiB
C
64 lines
1.3 KiB
C
#define _GNU_SOURCE 1
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
#include <sys/time.h>
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <sys/uio.h>
|
|
#include <sys/un.h>
|
|
#include <unistd.h>
|
|
#include <fcntl.h>
|
|
#include <errno.h>
|
|
#include <net/if.h>
|
|
#include <netinet/in.h>
|
|
#include <netinet/tcp.h>
|
|
#include <netinet/udp.h>
|
|
#include <netinet/icmp6.h>
|
|
#include <string.h>
|
|
|
|
#include "nest/bird.h"
|
|
#include "lib/lists.h"
|
|
#include "lib/resource.h"
|
|
#include "lib/timer.h"
|
|
#include "lib/socket.h"
|
|
#include "lib/event.h"
|
|
#include "lib/string.h"
|
|
#include "nest/iface.h"
|
|
#include "lib/string.h"
|
|
|
|
#include "lib/unix.h"
|
|
|
|
|
|
//#define PKT_MAGIC 0x12345678
|
|
#define PKT_MAGIC 42
|
|
|
|
#define PKT_PORT 100
|
|
#define PKT_VALUE 0
|
|
|
|
struct my_packet
|
|
{
|
|
u32 magic;
|
|
u32 value;
|
|
u32 count;
|
|
};
|
|
|
|
int cf_mcast; /* Set up multicast */
|
|
int cf_bcast; /* Enable broadcast */
|
|
int cf_bind; /* Bind by address */
|
|
uint cf_count; /* How many packets send */
|
|
uint counter; /* global counter of send/recv packets */
|
|
uint cf_value; /* a value in packet */
|
|
uint cf_ttl;
|
|
|
|
#define SKT_ERR(x) do { perror(x); exit(-1); } while(0)
|
|
|
|
sock *skt_parse_args(int argc, char **argv, int is_send);
|
|
void bird_init(void);
|
|
void skt_open(sock *s);
|
|
|
|
/* implementation in io.c */
|
|
int sk_write(sock *s);
|
|
int sk_read(sock *s);
|