summaryrefslogtreecommitdiff
path: root/proto/ospf/packet.c
diff options
context:
space:
mode:
authorOndrej Filip <feela@network.cz>2000-06-06 01:23:03 +0000
committerOndrej Filip <feela@network.cz>2000-06-06 01:23:03 +0000
commitc1824c4d4c7753246ba26d27c7a3b7be3006d46b (patch)
tree428682b51c5ae4ed3f5d2523ab24a35d78cfde68 /proto/ospf/packet.c
parentfef1badfcfb0519cca10f3561e5cb79ef9f9e969 (diff)
Simple autentication added.
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)
{