0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-01-03 15:41:54 +00:00

Socktest: Renaming

This commit is contained in:
Pavel Tvrdik 2016-04-06 15:46:02 +02:00
parent a6e111ae54
commit e4a6c41236
4 changed files with 28 additions and 30 deletions

View File

@ -39,12 +39,12 @@ err_hook(sock *s, int err)
return;
}
printf("Err(%d): %s \n", err, s->err);
perror("err_hook: ");
exit(1);
}
void
skt_open(sock *s)
socktest_open(sock *s)
{
if (sk_open(s) < 0)
{
@ -63,7 +63,7 @@ skt_open(sock *s)
}
sock *
skt_parse_args(int argc, char *argv[], int is_send)
socktest_parse_args(int argc, char *argv[], int is_send)
{
int is_recv = !is_send;
const char *opt_list = is_send ? "bumi:l:p:v:t:c:B:" : "bum:i:l:p:v:t:c:B:";
@ -128,7 +128,7 @@ skt_parse_args(int argc, char *argv[], int is_send)
goto usage;
}
if (is_recv && s->type == SK_UDP) /* XXX: Weird */
if (is_recv && s->type == SK_UDP)
s->sport = port;
else
s->dport = port;
@ -148,7 +148,7 @@ skt_parse_args(int argc, char *argv[], int is_send)
}
static void
scan_infaces(void)
scan_interfaces(void)
{
/* create mockup config */
struct config *c = config_alloc("mockup");
@ -169,11 +169,11 @@ scan_infaces(void)
}
void
bird_init(void)
socktest_bird_init(void)
{
log_switch(1, NULL, NULL);
resource_init();
io_init();
if_init();
scan_infaces();
scan_interfaces();
}

View File

@ -31,13 +31,11 @@
#include "lib/unix.h"
//#define PKT_MAGIC 0x12345678
#define PKT_MAGIC 42
#define PKT_PORT 100
#define PKT_VALUE 0
#define PKT_MAGIC 0x12345678
struct my_packet
struct socktest_packet
{
u32 magic;
u32 value;
@ -48,12 +46,12 @@ 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 counter; /* Global counter of send/recv packets */
uint cf_value; /* Value in packet */
sock *skt_parse_args(int argc, char **argv, int is_send);
void bird_init(void);
void skt_open(sock *s);
sock *socktest_parse_args(int argc, char **argv, int is_send);
void socktest_bird_init(void);
void socktest_open(sock *s);
/* implementation in io.c */
int sk_write(sock *s);

View File

@ -5,7 +5,7 @@
* <src>:<port> -> <dst> ifa(<id>) <name>: pkt <value>/<count>, ttl <ttl>
*/
static void
rcv_print(sock *sk, struct my_packet *pkt)
rcv_print(sock *sk, struct socktest_packet *pkt)
{
char ifa_name[IF_NAMESIZE];
char buf[1024];
@ -42,7 +42,7 @@ rcv_print(sock *sk, struct my_packet *pkt)
static int
rcv_hook(sock *sk, int size)
{
struct my_packet *raw;
struct socktest_packet *raw;
if (cf_count && ++counter > cf_count)
exit(0);
@ -52,13 +52,13 @@ rcv_hook(sock *sk, int size)
else
raw = (void *) sk->rbuf;
if (size != sizeof(struct my_packet))
if (size != sizeof(struct socktest_packet))
{
printf("Received a packet with unexpected length of %d bytes \n", size);
return 1;
}
struct my_packet pkt = {
struct socktest_packet pkt = {
.magic = ntohl(raw->magic),
.value = ntohl(raw->value),
.count = ntohl(raw->count),
@ -73,14 +73,14 @@ rcv_hook(sock *sk, int size)
int
main(int argc, char *argv[])
{
bird_init();
socktest_bird_init();
sock *s = skt_parse_args(argc, argv, 0);
sock *s = socktest_parse_args(argc, argv, 0);
s->rx_hook = rcv_hook;
s->rbsize = 1500;
s->flags |= SKF_LADDR_RX | SKF_TTL_RX | SKF_PKTINFO;
s->flags |= SKF_LADDR_RX | SKF_TTL_RX;
skt_open(s);
socktest_open(s);
while (1)
{

View File

@ -1,6 +1,6 @@
#include "common.h"
int
static int
do_sendmsg(sock *s, void *pkt, size_t len)
{
memcpy(s->ttx, pkt, len);
@ -12,7 +12,7 @@ do_sendmsg(sock *s, void *pkt, size_t len)
return sk_write(s);
}
void
static void
connected_hook(sock *s)
{
printf("Start sending...\n");
@ -22,16 +22,16 @@ connected_hook(sock *s)
int
main(int argc, char *argv[])
{
bird_init();
socktest_bird_init();
sock *s = skt_parse_args(argc, argv, 1);
sock *s = socktest_parse_args(argc, argv, 1);
s->tx_hook = connected_hook;
s->tbsize = 1500;
s->tos = IP_PREC_INTERNET_CONTROL;
skt_open(s);
socktest_open(s);
struct my_packet pkt = {
struct socktest_packet pkt = {
.magic = htonl(PKT_MAGIC),
.value = htonl(cf_value),
};