ospf_hdr
if (ibuf_set(buf, sizeof(struct ospf_hdr), &dd_hdr,
int offset = offsetof(struct ospf_hdr, chksum);
if (ibuf_set_n32(buf, sizeof(struct ospf_hdr), nlsa) == -1)
struct ospf_hdr *ospf_hdr;
if (len < sizeof(*ospf_hdr)) {
ospf_hdr = (struct ospf_hdr *)buf;
if ((l = ospf_hdr_sanity_check(ospf_hdr, len, iface, &dest)) == -1)
nbr = nbr_find_id(iface, ospf_hdr->rtr_id);
if (ospf_hdr->type != PACKET_TYPE_HELLO && nbr == NULL) {
buf += sizeof(*ospf_hdr);
len = l - sizeof(*ospf_hdr);
switch (ospf_hdr->type) {
recv_hello(iface, &src.sin6_addr, ospf_hdr->rtr_id, buf, len);
ospf_hdr_sanity_check(struct ospf_hdr *ospf_hdr, u_int16_t len,
if (ospf_hdr->version != OSPF6_VERSION) {
ospf_hdr->version);
if (ntohs(ospf_hdr->len) > len ||
len <= sizeof(struct ospf_hdr)) {
ntohs(ospf_hdr->len));
if (ospf_hdr->area_id != iface->area->id.s_addr) {
id.s_addr = ospf_hdr->area_id;
if (ospf_hdr->area_id != 0) {
id.s_addr = ospf_hdr->area_id;
return (ntohs(ospf_hdr->len));
int ospf_hdr_sanity_check(struct ospf_hdr *, u_int16_t,
struct ospf_hdr ospf_hdr;
bzero(&ospf_hdr, sizeof(ospf_hdr));
ospf_hdr.version = OSPF6_VERSION;
ospf_hdr.type = type;
ospf_hdr.rtr_id = ospfe_router_id();
ospf_hdr.area_id = iface->area->id.s_addr;
ospf_hdr.instance = DEFAULT_INSTANCE_ID;
ospf_hdr.zero = 0; /* must be zero */
return (ibuf_add(buf, &ospf_hdr, sizeof(ospf_hdr)));
if (ibuf_set_n16(buf, offsetof(struct ospf_hdr, len),
if (ibuf_set_n16(buf, offsetof(struct ospf_hdr, chksum), 0) == -1)
auth_data += ntohs(ospf_hdr->len);
MD5Update(&hash, buf, ntohs(ospf_hdr->len));
ntohl(ospf_hdr->auth_key.crypt.seq_num);
if (ibuf_set_n16(buf, offsetof(struct ospf_hdr, len),
if (ibuf_set(buf, offsetof(struct ospf_hdr, chksum),
if (ibuf_set(buf, offsetof(struct ospf_hdr, chksum),
if (ibuf_set(buf, offsetof(struct ospf_hdr, auth_key),
if (ibuf_set(buf, offsetof(struct ospf_hdr, auth_key),
struct ospf_hdr *ospf_hdr = buf;
if (ntohs(ospf_hdr->auth_type) != (u_int16_t)iface->auth_type) {
if (memcmp(ospf_hdr->auth_key.simple, iface->auth_key,
sizeof(ospf_hdr->auth_key.simple))) {
bzero(ospf_hdr->auth_key.simple,
sizeof(ospf_hdr->auth_key.simple));
if (in_cksum(ospf_hdr, ntohs(ospf_hdr->len))) {
ospf_hdr->auth_key.crypt.keyid)) == NULL) {
"interface %s", ospf_hdr->auth_key.crypt.keyid,
if (nbr != NULL && ntohl(ospf_hdr->auth_key.crypt.seq_num) <
if (ospf_hdr->auth_key.crypt.len != MD5_DIGEST_LENGTH) {
if (len - ntohs(ospf_hdr->len) < MD5_DIGEST_LENGTH) {
if (ibuf_set(buf, sizeof(struct ospf_hdr), &dd_hdr,
if ((size_t)iface->mtu < sizeof(struct ip) + sizeof(struct ospf_hdr) +
if (ibuf_size(buf) > sizeof(struct ospf_hdr) +
if (ibuf_set_n32(buf, sizeof(struct ospf_hdr), nlsa) == -1)
IP_MAXPACKET - sizeof(struct ip) - sizeof(struct ospf_hdr) -
IP_MAXPACKET - sizeof(struct ip) - sizeof(struct ospf_hdr) -
struct ospf_hdr *ospf_hdr;
if (len < sizeof(*ospf_hdr)) {
ospf_hdr = (struct ospf_hdr *)buf;
if ((l = ospf_hdr_sanity_check(&ip_hdr, ospf_hdr, len, iface)) == -1)
nbr = nbr_find_id(iface, ospf_hdr->rtr_id);
if (ospf_hdr->type != PACKET_TYPE_HELLO && nbr == NULL) {
buf += sizeof(*ospf_hdr);
len = l - sizeof(*ospf_hdr);
switch (ospf_hdr->type) {
recv_hello(iface, ip_hdr.ip_src, ospf_hdr->rtr_id, buf, len);
ospf_hdr_sanity_check(const struct ip *ip_hdr, struct ospf_hdr *ospf_hdr,
if (ospf_hdr->version != OSPF_VERSION) {
ospf_hdr->version);
if (ntohs(ospf_hdr->len) > len ||
len <= sizeof(struct ospf_hdr)) {
ntohs(ospf_hdr->len));
if (ospf_hdr->area_id != iface->area->id.s_addr) {
addr.s_addr = ospf_hdr->area_id;
if (ospf_hdr->area_id != 0) {
addr.s_addr = ospf_hdr->area_id;
return (ntohs(ospf_hdr->len));
struct ospf_hdr *, u_int16_t, const struct iface *);
struct ospf_hdr ospf_hdr;
bzero(&ospf_hdr, sizeof(ospf_hdr));
ospf_hdr.version = OSPF_VERSION;
ospf_hdr.type = type;
ospf_hdr.rtr_id = ospfe_router_id();
ospf_hdr.area_id = iface->area->id.s_addr;
ospf_hdr.auth_type = htons(iface->auth_type);
return (ibuf_add(buf, &ospf_hdr, sizeof(ospf_hdr)));