/* put a series of object offsets/lengths from a linked list */ void util_put_ll_objs (LINKED_LIST *ll, char **cp) { objlist_t *obj_p; u_short _type; char *c = *cp; LL_Iterate (ll, obj_p) { UTIL_PUT_NETLONG (obj_p->offset, c); UTIL_PUT_NETLONG (obj_p->len, c); _type = (u_short) obj_p->type; UTIL_PUT_NETSHORT (_type, c); /* type */ }
/* ospf_send_database */ int ospf_send_database (ospf_neighbor_t *neighbor) { u_char buf[1024], *cp = buf; u_short length, checksum; ospf_interface_t *ospf_interface = neighbor->ospf_interface; memset (buf, 0, 1023); UTIL_PUT_BYTE (OSPF_VERSION, cp); UTIL_PUT_BYTE (OSPF_DATABASE_DESCRIPTION, cp); cp += 2; /* skip length for now */ UTIL_PUT_NETLONG (OSPF.router_id, cp); UTIL_PUT_NETLONG (ospf_interface->area->area_id, cp); cp += 2; /* skip checksum for now */ UTIL_PUT_NETSHORT (ospf_interface->authentication_type, cp); if (ospf_interface->authentication_type == OSPF_AUTH_NULL) { cp += 8; /* skip authentication */ } if (ospf_interface->authentication_type == OSPF_AUTH_PASSWORD) { memcpy (cp, ospf_interface->password, 8); cp += 8; } /* network mask */ UTIL_PUT_NETSHORT (1500, cp); /* mtu */ UTIL_PUT_BYTE (2, cp); /* options */ /* build bits */ UTIL_PUT_BYTE (neighbor->I_M_MS, cp); /* flags */ UTIL_PUT_NETLONG (neighbor->dd_seq_num, cp); trace (NORM, OSPF.trace, "\n"); if (ospf_interface->authentication_type == OSPF_AUTH_PASSWORD) trace (NORM, OSPF.trace, "Send OSPF Database password: %s\n", ospf_interface->password); trace (NORM, OSPF.trace, "Send OSPF Database seq: %d, options 0x%x, flags %s\n", neighbor->dd_seq_num, neighbor->options, ospf_neighbor_database_flags (neighbor->I_M_MS)); /* no LSA header for time being -- just doing exstart stuff * right now */ /* go back and fill in length */ length = cp - buf; if (length % 2 != 0) { length++; /* pad */ } cp = buf; cp += 2; UTIL_PUT_SHORT (length, cp); /* go back and checksum */ cp = buf; checksum = in_cksum (cp, length); cp += 12; UTIL_PUT_NETSHORT (checksum, cp); packet_send_wire_unicast (neighbor->prefix, buf, length); /*packet_send_wire_multicast (OSPF_ALLSPFRouters, ospf_interface->interface, buf, length);*/ return (1); }