Fixes compatibility with Mikrotik.

This commit is contained in:
Ondrej Zajicek 2011-05-19 01:20:00 +02:00
parent b54ad333b3
commit 1155c79209

View file

@ -60,12 +60,16 @@ ospf_pkt_finalize(struct ospf_iface *ifa, struct ospf_packet *pkt)
struct MD5Context ctxt; struct MD5Context ctxt;
char password[OSPF_AUTH_CRYPT_SIZE]; char password[OSPF_AUTH_CRYPT_SIZE];
pkt->checksum = 0;
pkt->autype = htons(ifa->autype); pkt->autype = htons(ifa->autype);
bzero(&pkt->u, sizeof(union ospf_auth));
/* Compatibility note: pkt->u may contain anything if autype is
none, but nonzero values do not work with Mikrotik OSPF */
switch(ifa->autype) switch(ifa->autype)
{ {
case OSPF_AUTH_SIMPLE: case OSPF_AUTH_SIMPLE:
bzero(&pkt->u, sizeof(union ospf_auth));
passwd = password_find(ifa->passwords, 1); passwd = password_find(ifa->passwords, 1);
if (!passwd) if (!passwd)
{ {
@ -74,7 +78,6 @@ ospf_pkt_finalize(struct ospf_iface *ifa, struct ospf_packet *pkt)
} }
password_cpy(pkt->u.password, passwd->password, sizeof(union ospf_auth)); password_cpy(pkt->u.password, passwd->password, sizeof(union ospf_auth));
case OSPF_AUTH_NONE: case OSPF_AUTH_NONE:
pkt->checksum = 0;
pkt->checksum = ipsum_calculate(pkt, sizeof(struct ospf_packet) - pkt->checksum = ipsum_calculate(pkt, sizeof(struct ospf_packet) -
sizeof(union ospf_auth), (pkt + 1), sizeof(union ospf_auth), (pkt + 1),
ntohs(pkt->length) - ntohs(pkt->length) -
@ -88,8 +91,6 @@ ospf_pkt_finalize(struct ospf_iface *ifa, struct ospf_packet *pkt)
return; return;
} }
pkt->checksum = 0;
/* Perhaps use random value to prevent replay attacks after /* Perhaps use random value to prevent replay attacks after
reboot when system does not have independent RTC? */ reboot when system does not have independent RTC? */
if (!ifa->csn) if (!ifa->csn)