From c1824c4d4c7753246ba26d27c7a3b7be3006d46b Mon Sep 17 00:00:00 2001 From: Ondrej Filip Date: Tue, 6 Jun 2000 01:23:03 +0000 Subject: Simple autentication added. --- proto/ospf/packet.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'proto/ospf/packet.c') diff --git a/proto/ospf/packet.c b/proto/ospf/packet.c index 88234da..4b2e772 100644 --- a/proto/ospf/packet.c +++ b/proto/ospf/packet.c @@ -31,10 +31,29 @@ fill_ospf_pkt_hdr(struct ospf_iface *ifa, void *buf, u8 h_type) void ospf_tx_authenticate(struct ospf_iface *ifa, struct ospf_packet *pkt) { - /* FIXME */ + int i; + pkt->autype=ifa->autype; + memcpy(pkt->authetication, ifa->aukey, 8); return; } +int +ospf_rx_authenticate(struct ospf_iface *ifa, struct ospf_packet *pkt) +{ + int i; + if(pkt->autype!=ifa->autype) return 0; + if(ifa->autype==AU_NONE) return 1; + if(ifa->autype==AU_SIMPLE) + { + for(i=0;i<8;i++) + { + if(pkt->authetication[i]!=ifa->aukey[i]) return 0; + } + return 1; + } + return 0; +} + void ospf_pkt_finalize(struct ospf_iface *ifa, struct ospf_packet *pkt) { @@ -95,7 +114,12 @@ ospf_rx_hook(sock *sk, int size) return(1); } - /* FIXME: Do authetification */ + if(!ospf_rx_authenticate(ifa,ps)) + { + log("%s: Bad OSPF packet received: bad password", p->name); + return(1); + } + if(ps->areaid!=ifa->an) { -- cgit v1.2.3