interface {} added.

This commit is contained in:
Ondrej Filip 2000-06-03 01:29:00 +00:00
parent b36a0a799c
commit 89d6782dd1
9 changed files with 71 additions and 21 deletions

View file

@ -14,11 +14,14 @@ CF_DEFINES
#define OSPF_CFG ((struct ospf_config *) this_proto)
static struct ospf_area_config *this_area;
static struct iface_patt *this_ipatt;
#define OSPF_PATT ((struct ospf_iface_patt *) this_ipatt)
CF_DECLS
CF_KEYWORDS(OSPF, AREA, OSPF_METRIC1, OSPF_METRIC2, OSPF_TAG)
CF_KEYWORDS(NEIGHBORS, RFC1583COMPAT, STUB, TICK)
CF_KEYWORDS(NEIGHBORS, RFC1583COMPAT, STUB, TICK, COST, RETRANSMIT)
CF_KEYWORDS(HELLO)
%type <t> opttext
@ -46,6 +49,7 @@ ospf_area_start: AREA idval '{' {
this_area->areaid = $2;
this_area->tick = DISPTICK;
this_area->stub = 0;
init_list(&this_area->patt_list);
}
;
@ -56,8 +60,42 @@ ospf_area: ospf_area_start
ospf_area_item:
| STUB bool ';' { this_area->stub = $2 ; }
| TICK NUM ';' { this_area->tick = $2 ; }
| ospf_iface_list
;
ospf_iface_item:
| COST NUM { OSPF_PATT->cost = $2 ; }
| HELLO NUM { OSPF_PATT->helloint = $2 ; }
| RETRANSMIT NUM { OSPF_PATT->rxmtint = $2 ; }
;
ospf_iface_opts:
'{'
| ospf_iface_opts ospf_iface_item ';'
;
ospf_iface_opt_list: /* EMPTY */ | ospf_iface_opts '}'
;
ospf_iface_start:
{
this_ipatt = cfg_allocz(sizeof(struct ospf_iface_patt));
add_tail(&this_area->patt_list, NODE this_ipatt);
OSPF_PATT->cost=10;
OSPF_PATT->helloint=10;
OSPF_PATT->rxmtint=5;
}
;
ospf_iface:
ospf_iface_start iface_patt ospf_iface_opt_list
;
ospf_iface_list:
INTERFACE ospf_iface
| ospf_iface_list ',' ospf_iface
;
opttext:
TEXT
| /* empty */ { $$ = NULL; }

View file

@ -27,7 +27,7 @@ ospf_dbdes_tx(struct ospf_neighbor *n)
n->myimms.bit.i=1;
pkt=(struct ospf_dbdes_packet *)(ifa->ip_sk->tbuf);
op=(struct ospf_packet *)pkt;
fill_ospf_pkt_hdr(ifa, pkt, DBDES);
fill_ospf_pkt_hdr(ifa, pkt, DBDES_P);
pkt->iface_mtu=htons(ifa->iface->mtu); /*FIXME NOT for VLINK! */
pkt->options= ifa->options;
pkt->imms=n->myimms;
@ -52,7 +52,7 @@ ospf_dbdes_tx(struct ospf_neighbor *n)
pkt=n->ldbdes;
op=(struct ospf_packet *)pkt;
fill_ospf_pkt_hdr(ifa, pkt, DBDES);
fill_ospf_pkt_hdr(ifa, pkt, DBDES_P);
pkt->iface_mtu=htons(ifa->iface->mtu);
pkt->options= ifa->options;
pkt->ddseq=htonl(n->dds);

View file

@ -198,7 +198,7 @@ hello_timer_hook(timer *timer)
pkt=(struct ospf_hello_packet *)(ifa->hello_sk->tbuf);
op=(struct ospf_packet *)pkt;
fill_ospf_pkt_hdr(ifa, pkt, HELLO);
fill_ospf_pkt_hdr(ifa, pkt, HELLO_P);
pkt->netmask=ipa_mkmask(ifa->iface->addr->pxlen);
ipa_hton(pkt->netmask);

View file

@ -24,7 +24,7 @@ ospf_lsack_direct_tx(struct ospf_neighbor *n,struct ospf_lsa_header *h)
pk=(struct ospf_lsack_packet *)sk->tbuf;
op=(struct ospf_packet *)sk->tbuf;
fill_ospf_pkt_hdr(n->ifa, pk, LSACK);
fill_ospf_pkt_hdr(n->ifa, pk, LSACK_P);
memcpy(pk+1,h,sizeof(struct ospf_lsa_header));
len=sizeof(struct ospf_lsack_packet)+sizeof(struct ospf_lsa_header);
@ -79,7 +79,7 @@ ospf_lsack_delay_tx(struct ospf_neighbor *n)
pk=(struct ospf_lsack_packet *)sk->tbuf;
op=(struct ospf_packet *)sk->tbuf;
fill_ospf_pkt_hdr(n->ifa, pk, LSACK);
fill_ospf_pkt_hdr(n->ifa, pk, LSACK_P);
h=(struct ospf_lsa_header *)(pk+1);
while(!EMPTY_LIST(n->ackl))
@ -116,7 +116,7 @@ ospf_lsack_delay_tx(struct ospf_neighbor *n)
sk_send_to_agt(sk, len, ifa, NEIGHBOR_EXCHANGE);
}
fill_ospf_pkt_hdr(n->ifa, pk, LSACK);
fill_ospf_pkt_hdr(n->ifa, pk, LSACK_P);
i=0;
}
}

View file

@ -23,7 +23,7 @@ ospf_lsreq_tx(struct ospf_neighbor *n)
pk=(struct ospf_lsreq_packet *)n->ifa->ip_sk->tbuf;
op=(struct ospf_packet *)n->ifa->ip_sk->tbuf;
fill_ospf_pkt_hdr(n->ifa, pk, LSREQ);
fill_ospf_pkt_hdr(n->ifa, pk, LSREQ_P);
sn=SHEAD(n->lsrql);
if(EMPTY_SLIST(n->lsrql))

View file

@ -117,7 +117,7 @@ flood_lsa(struct ospf_neighbor *n, struct ospf_lsa_header *hn,
pk=(struct ospf_lsupd_packet *)sk->tbuf;
op=(struct ospf_packet *)sk->tbuf;
fill_ospf_pkt_hdr(ifa, pk, LSUPD);
fill_ospf_pkt_hdr(ifa, pk, LSUPD_P);
pk->lsano=htonl(1);
if(hn!=NULL)
{
@ -183,7 +183,7 @@ ospf_lsupd_tx_list(struct ospf_neighbor *n, list *l)
DBG("LSupd: 1st packet\n");
fill_ospf_pkt_hdr(n->ifa, pk, LSUPD);
fill_ospf_pkt_hdr(n->ifa, pk, LSUPD_P);
len=SIPH+sizeof(struct ospf_lsupd_packet);
lsano=0;
pktpos=(pk+1);
@ -205,7 +205,7 @@ ospf_lsupd_tx_list(struct ospf_neighbor *n, list *l)
debug("%s: LS upd sent to %I (%d LSAs)\n", p->name, n->ip, lsano);
DBG("LSupd: next packet\n");
fill_ospf_pkt_hdr(n->ifa, pk, LSUPD);
fill_ospf_pkt_hdr(n->ifa, pk, LSUPD_P);
len=SIPH+sizeof(struct ospf_lsupd_packet);
lsano=0;
pktpos=(pk+1);

View file

@ -63,6 +63,7 @@ ospf_init(struct proto_config *c)
struct proto_ospf *po=(struct proto_ospf *)p;
struct ospf_config *oc=(struct ospf_config *)c;
struct ospf_area_config *ac;
struct ospf_iface_patt *patt;
debug("OSPF: Init requested.\n");
p->import_control = ospf_import_control;
@ -77,6 +78,9 @@ ospf_init(struct proto_config *c)
WALK_LIST(ac, oc->area_list)
{
debug("OSPF: area: %I, stub=%u tick=%u\n", ac->areaid, ac->stub, ac->tick);
WALK_LIST(patt, ac->patt_list)
debug("Patt cost=%d hello=%d ret=%d\n",patt->cost, patt->helloint,
patt->rxmtint);
}
return p;

View file

@ -56,6 +56,7 @@ struct ospf_area_config {
u32 areaid;
int stub;
unsigned tick;
list patt_list;
};
struct ospf_iface {
@ -117,11 +118,11 @@ struct ospf_iface {
struct ospf_packet {
u8 version;
u8 type;
#define HELLO 1 /* Hello */
#define DBDES 2 /* Database description */
#define LSREQ 3 /* Link state request */
#define LSUPD 4 /* Link state update */
#define LSACK 5 /* Link state acknowledgement */
#define HELLO_P 1 /* Hello */
#define DBDES_P 2 /* Database description */
#define LSREQ_P 3 /* Link state request */
#define LSUPD_P 4 /* Link state update */
#define LSACK_P 5 /* Link state acknowledgement */
u16 length;
u32 routerid;
u32 areaid;
@ -356,6 +357,13 @@ struct proto_ospf {
int rfc1583;
};
struct ospf_iface_patt {
struct iface_patt i;
int cost;
int helloint;
int rxmtint;
};
static int ospf_start(struct proto *p);
static void ospf_dump(struct proto *p);
static struct proto *ospf_init(struct proto_config *c);

View file

@ -127,23 +127,23 @@ ospf_rx_hook(sock *sk, int size)
switch(ps->type)
{
case HELLO:
case HELLO_P:
DBG("%s: Hello received.\n", p->name);
ospf_hello_rx((struct ospf_hello_packet *)ps, p, ifa, size, sk->faddr);
break;
case DBDES:
case DBDES_P:
DBG("%s: Database description received.\n", p->name);
ospf_dbdes_rx((struct ospf_dbdes_packet *)ps, p, ifa, size);
break;
case LSREQ:
case LSREQ_P:
DBG("%s: Link state request received.\n", p->name);
ospf_lsreq_rx((struct ospf_lsreq_packet *)ps, p, ifa, size);
break;
case LSUPD:
case LSUPD_P:
DBG("%s: Link state update received.\n", p->name);
ospf_lsupd_rx((struct ospf_lsupd_packet *)ps, p, ifa, size);
break;
case LSACK:
case LSACK_P:
DBG("%s: Link state ack received.\n", p->name);
ospf_lsack_rx((struct ospf_lsack_packet *)ps, p, ifa, size);
break;