mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-09 20:58:44 +00:00
Added skeleton of static route protocol.
This commit is contained in:
parent
980ffedbb0
commit
a1bf6440b5
2
Makefile
2
Makefile
@ -9,7 +9,7 @@ OPT=-O2
|
|||||||
DEBUG=-g#gdb
|
DEBUG=-g#gdb
|
||||||
CFLAGS=$(OPT) $(DEBUG) -Wall -W -Wstrict-prototypes -Wno-unused -Wno-parentheses
|
CFLAGS=$(OPT) $(DEBUG) -Wall -W -Wstrict-prototypes -Wno-unused -Wno-parentheses
|
||||||
|
|
||||||
PROTOCOLS=rip
|
PROTOCOLS=rip static
|
||||||
LIBDIRS=sysdep/linux sysdep/unix lib
|
LIBDIRS=sysdep/linux sysdep/unix lib
|
||||||
BASEDIRS=nest $(addprefix proto/,$(PROTOCOLS))
|
BASEDIRS=nest $(addprefix proto/,$(PROTOCOLS))
|
||||||
STDDIRS=$(BASEDIRS) $(OBJDIR)/conf
|
STDDIRS=$(BASEDIRS) $(OBJDIR)/conf
|
||||||
|
2
TODO
2
TODO
@ -16,6 +16,8 @@ Core
|
|||||||
- default preferences of protocols: prefer BGP over OSPF/RIP external routes?
|
- default preferences of protocols: prefer BGP over OSPF/RIP external routes?
|
||||||
- secondary addresses -> subinterfaces
|
- secondary addresses -> subinterfaces
|
||||||
- check if all protocols set proper packet priorities and TTL's.
|
- check if all protocols set proper packet priorities and TTL's.
|
||||||
|
- better default protocol names
|
||||||
|
- config: comments at end of line -> explicit ';' needed?
|
||||||
|
|
||||||
- filter: logging of dropped routes (?)
|
- filter: logging of dropped routes (?)
|
||||||
- limitation of memory consumption: per-process and total (?)
|
- limitation of memory consumption: per-process and total (?)
|
||||||
|
@ -23,3 +23,7 @@ protocol kernel {
|
|||||||
learn; # Learn all routes from the kernel
|
learn; # Learn all routes from the kernel
|
||||||
scan time 10; # Scan kernel tables every 10 seconds
|
scan time 10; # Scan kernel tables every 10 seconds
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protocol static {
|
||||||
|
disabled
|
||||||
|
}
|
||||||
|
@ -47,6 +47,7 @@ extern list protocol_list;
|
|||||||
|
|
||||||
extern struct protocol proto_device;
|
extern struct protocol proto_device;
|
||||||
extern struct protocol proto_rip;
|
extern struct protocol proto_rip;
|
||||||
|
extern struct protocol proto_static;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Routing Protocol Instance
|
* Routing Protocol Instance
|
||||||
|
4
proto/static/Makefile
Normal file
4
proto/static/Makefile
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
THISDIR=proto/static
|
||||||
|
OBJS=static.o
|
||||||
|
|
||||||
|
include ../../Rules
|
34
proto/static/config.Y
Normal file
34
proto/static/config.Y
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* BIRD -- Static Protocol Configuration
|
||||||
|
*
|
||||||
|
* (c) 1998 Martin Mares <mj@ucw.cz>
|
||||||
|
*
|
||||||
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
|
*/
|
||||||
|
|
||||||
|
CF_HDR
|
||||||
|
|
||||||
|
#include "proto/static/static.h"
|
||||||
|
|
||||||
|
CF_DECLS
|
||||||
|
|
||||||
|
CF_KEYWORDS(STATIC)
|
||||||
|
|
||||||
|
CF_GRAMMAR
|
||||||
|
|
||||||
|
CF_ADDTO(proto, static_proto '}')
|
||||||
|
|
||||||
|
static_proto_start: proto_start STATIC {
|
||||||
|
this_proto = proto_new(&proto_static, sizeof(struct static_proto));
|
||||||
|
static_init_instance((struct static_proto *) this_proto);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
static_proto:
|
||||||
|
static_proto_start proto_name '{'
|
||||||
|
| static_proto proto_item ';'
|
||||||
|
;
|
||||||
|
|
||||||
|
CF_CODE
|
||||||
|
|
||||||
|
CF_END
|
73
proto/static/static.c
Normal file
73
proto/static/static.c
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* BIRD -- Static Route Generator
|
||||||
|
*
|
||||||
|
* (c) 1998 Martin Mares <mj@ucw.cz>
|
||||||
|
*
|
||||||
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define LOCAL_DEBUG
|
||||||
|
|
||||||
|
#include "nest/bird.h"
|
||||||
|
#include "nest/iface.h"
|
||||||
|
#include "nest/protocol.h"
|
||||||
|
#include "nest/route.h"
|
||||||
|
#include "conf/conf.h"
|
||||||
|
|
||||||
|
#include "static.h"
|
||||||
|
|
||||||
|
#define GET_DATA struct static_proto *p = (struct static_proto *) P
|
||||||
|
|
||||||
|
static void
|
||||||
|
static_start(struct proto *P)
|
||||||
|
{
|
||||||
|
DBG("Static: take off!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
static_neigh_notify(struct neighbor *n)
|
||||||
|
{
|
||||||
|
DBG("Static: neighbor notify got, don't know why.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
static_dump(struct proto *P)
|
||||||
|
{
|
||||||
|
DBG("Static: no dumps available in demo version.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
static_init_instance(struct static_proto *P)
|
||||||
|
{
|
||||||
|
struct proto *p = &P->p;
|
||||||
|
|
||||||
|
p->preference = DEF_PREF_STATIC;
|
||||||
|
p->start = static_start;
|
||||||
|
p->neigh_notify = static_neigh_notify;
|
||||||
|
p->dump = static_dump;
|
||||||
|
/* FIXME: Should shutdown remove all routes? */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
static_init(struct protocol *p)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
static_preconfig(struct protocol *x)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
static_postconfig(struct protocol *p)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
struct protocol proto_static = {
|
||||||
|
{ NULL, NULL },
|
||||||
|
"Static",
|
||||||
|
0,
|
||||||
|
static_init,
|
||||||
|
static_preconfig,
|
||||||
|
static_postconfig
|
||||||
|
};
|
30
proto/static/static.h
Normal file
30
proto/static/static.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* BIRD -- Static Route Generator
|
||||||
|
*
|
||||||
|
* (c) 1998 Martin Mares <mj@ucw.cz>
|
||||||
|
*
|
||||||
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _BIRD_STATIC_H_
|
||||||
|
#define _BIRD_STATIC_H_
|
||||||
|
|
||||||
|
struct static_proto {
|
||||||
|
struct proto p;
|
||||||
|
list routes;
|
||||||
|
};
|
||||||
|
|
||||||
|
void static_init_instance(struct static_proto *);
|
||||||
|
|
||||||
|
struct static_route {
|
||||||
|
node n;
|
||||||
|
u32 net; /* Network we route */
|
||||||
|
int masklen; /* Mask length */
|
||||||
|
int dest; /* Destination type (RTD_*) */
|
||||||
|
u32 via; /* Destination router */
|
||||||
|
struct neighbor *neigh;
|
||||||
|
/* FIXME: Device routes, maybe via device patterns? */
|
||||||
|
/* FIXME: More route attributes, probably via filter syntax */
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user