| TYPE PTP { OSPF_PATT->type = OSPF_IT_PTP ; }
| TYPE POINTOMULTIPOINT { OSPF_PATT->type = OSPF_IT_PTMP ; }
| TYPE PTMP { OSPF_PATT->type = OSPF_IT_PTMP ; }
- | REAL BROADCAST bool { OSPF_PATT->real_bcast = $3; if (OSPF_VERSION != 2) cf_error("Real broadcast option requires OSPFv2"); }
- | PTP NETMASK bool { OSPF_PATT->ptp_netmask = $3; if (OSPF_VERSION != 2) cf_error("Real netmask option requires OSPFv2"); }
+ | REAL BROADCAST bool { OSPF_PATT->real_bcast = $3; if (!ospf_cfg_is_v2()) cf_error("Real broadcast option requires OSPFv2"); }
++ | PTP NETMASK bool { OSPF_PATT->ptp_netmask = $3; if (!ospf_cfg_is_v2()) cf_error("Real netmask option requires OSPFv2"); }
| TRANSMIT DELAY expr { OSPF_PATT->inftransdelay = $3 ; if (($3<=0) || ($3>65535)) cf_error("Transmit delay must be in range 1-65535"); }
| PRIORITY expr { OSPF_PATT->priority = $2 ; if (($2<0) || ($2>255)) cf_error("Priority must be in range 0-255"); }
| STRICT NONBROADCAST bool { OSPF_PATT->strictnbma = $3 ; }
DBG("%s: Hello/Poll timer fired on interface %s with IP %I\n",
p->name, ifa->iface->name, ifa->addr->ip);
- /* Now we should send a hello packet */
pkt = ospf_tx_buffer(ifa);
- op = &pkt->ospf_packet;
-
- /* Now fill ospf_hello header */
ospf_pkt_fill_hdr(ifa, pkt, HELLO_P);
-#ifdef OSPFv2
- pkt->netmask = ipa_mkmask(ifa->addr->pxlen);
- ipa_hton(pkt->netmask);
- if ((ifa->type == OSPF_IT_VLINK) ||
- ((ifa->type == OSPF_IT_PTP) && !ifa->ptp_netmask))
- pkt->netmask = IPA_NONE;
-#endif
-
- pkt->helloint = ntohs(ifa->helloint);
- pkt->priority = ifa->priority;
-
-#ifdef OSPFv3
- pkt->iface_id = htonl(ifa->iface_id);
-
- pkt->options3 = ifa->oa->options >> 16;
- pkt->options2 = ifa->oa->options >> 8;
-#endif
- pkt->options = ifa->oa->options;
-
-#ifdef OSPFv2
- pkt->deadint = htonl(ifa->deadint);
- pkt->dr = htonl(ipa_to_u32(ifa->drip));
- pkt->bdr = htonl(ipa_to_u32(ifa->bdrip));
-#else /* OSPFv3 */
- pkt->deadint = htons(ifa->deadint);
- pkt->dr = htonl(ifa->drid);
- pkt->bdr = htonl(ifa->bdrid);
-#endif
+ if (ospf_is_v2(po))
+ {
+ struct ospf_hello2_packet *ps = (void *) pkt;
+
+ ps->netmask = htonl(u32_mkmask(ifa->addr->pxlen));
+
- if ((ifa->type == OSPF_IT_VLINK) || (ifa->type == OSPF_IT_PTP))
++ if ((ifa->type == OSPF_IT_VLINK) ||
++ ((ifa->type == OSPF_IT_PTP) && !ifa->ptp_netmask))
+ ps->netmask = 0;
+
+ ps->helloint = ntohs(ifa->helloint);
+ ps->options = ifa->oa->options;
+ ps->priority = ifa->priority;
+ ps->deadint = htonl(ifa->deadint);
+ ps->dr = htonl(ipa_to_u32(ifa->drip));
+ ps->bdr = htonl(ipa_to_u32(ifa->bdrip));
+
+ length = sizeof(struct ospf_hello2_packet);
+ neighbors = ps->neighbors;
+ }
+ else
+ {
+ struct ospf_hello3_packet *ps = (void *) pkt;
+
+ ps->iface_id = htonl(ifa->iface_id);
+ ps->priority = ifa->priority;
+ ps->options3 = ifa->oa->options >> 16;
+ ps->options2 = ifa->oa->options >> 8;
+ ps->options = ifa->oa->options;
+ ps->helloint = ntohs(ifa->helloint);
+ ps->deadint = htons(ifa->deadint);
+ ps->dr = htonl(ifa->drid);
+ ps->bdr = htonl(ifa->bdrid);
+
+ length = sizeof(struct ospf_hello3_packet);
+ neighbors = ps->neighbors;
+ }
- /* Fill all neighbors */
i = 0;
+ max = (ospf_pkt_bufsize(ifa) - length) / sizeof(u32);
+ /* Fill all neighbors */
if (kind != OHS_SHUTDOWN)
{
- u32 *pp = (u32 *) (((u8 *) pkt) + sizeof(struct ospf_hello_packet));
WALK_LIST(neigh, ifa->neigh_list)
{
- if ((i+1) * sizeof(u32) + sizeof(struct ospf_hello_packet) > ospf_pkt_bufsize(ifa))
+ if (i == max)
{
log(L_WARN "%s: Too many neighbors on interface %s", p->name, ifa->iface->name);
break;