summaryrefslogtreecommitdiff
path: root/proto/ospf/packet.c
diff options
context:
space:
mode:
Diffstat (limited to 'proto/ospf/packet.c')
-rw-r--r--proto/ospf/packet.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/proto/ospf/packet.c b/proto/ospf/packet.c
index 88234da1..4b2e7727 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)
{