]> git.proxmox.com Git - mirror_frr.git/blame - ospfd/ospf_api.c
Merge pull request #5468 from qlyoung/bgpd-remove-bgp-attr-dup
[mirror_frr.git] / ospfd / ospf_api.c
CommitLineData
2d33f157 1/*
2 * API message handling module for OSPF daemon and client.
3 * Copyright (C) 2001, 2002 Ralph Keller
4 *
5 * This file is part of GNU Zebra.
896014f4 6 *
2d33f157 7 * GNU Zebra is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation; either version 2, or (at your
10 * option) any later version.
11 *
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
896014f4
DL
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2d33f157 20 */
21
22#include <zebra.h>
23
24#ifdef SUPPORT_OSPF_API
2d33f157 25
26#include "linklist.h"
27#include "prefix.h"
28#include "if.h"
29#include "table.h"
30#include "memory.h"
31#include "command.h"
32#include "vty.h"
33#include "stream.h"
34#include "log.h"
35#include "thread.h"
36#include "hash.h"
d62a17ae 37#include "sockunion.h" /* for inet_aton() */
2d33f157 38#include "buffer.h"
39#include "network.h"
40
41#include "ospfd/ospfd.h"
42#include "ospfd/ospf_interface.h"
43#include "ospfd/ospf_ism.h"
44#include "ospfd/ospf_asbr.h"
45#include "ospfd/ospf_lsa.h"
46#include "ospfd/ospf_lsdb.h"
47#include "ospfd/ospf_neighbor.h"
48#include "ospfd/ospf_nsm.h"
49#include "ospfd/ospf_flood.h"
50#include "ospfd/ospf_packet.h"
51#include "ospfd/ospf_spf.h"
52#include "ospfd/ospf_dump.h"
53#include "ospfd/ospf_route.h"
54#include "ospfd/ospf_ase.h"
55#include "ospfd/ospf_zebra.h"
56
57#include "ospfd/ospf_api.h"
58
59
60/* For debugging only, will be removed */
d62a17ae 61void api_opaque_lsa_print(struct lsa_header *data)
2d33f157 62{
d62a17ae 63 struct opaque_lsa {
64 struct lsa_header header;
d7c0a89a 65 uint8_t mydata[];
d62a17ae 66 };
2d33f157 67
d62a17ae 68 struct opaque_lsa *olsa;
69 int opaquelen;
70 int i;
2d33f157 71
d62a17ae 72 ospf_lsa_header_dump(data);
2d33f157 73
d62a17ae 74 olsa = (struct opaque_lsa *)data;
2d33f157 75
d62a17ae 76 opaquelen = ntohs(data->length) - OSPF_LSA_HEADER_SIZE;
9165c5f5 77 zlog_debug("apiserver_lsa_print: opaquelen=%d", opaquelen);
2d33f157 78
d62a17ae 79 for (i = 0; i < opaquelen; i++) {
80 zlog_debug("0x%x ", olsa->mydata[i]);
81 }
9165c5f5 82 zlog_debug(" ");
2d33f157 83}
84
85/* -----------------------------------------------------------
86 * Generic messages
87 * -----------------------------------------------------------
88 */
89
d7c0a89a
QY
90struct msg *msg_new(uint8_t msgtype, void *msgbody, uint32_t seqnum,
91 uint16_t msglen)
2d33f157 92{
d62a17ae 93 struct msg *new;
2d33f157 94
d62a17ae 95 new = XCALLOC(MTYPE_OSPF_API_MSG, sizeof(struct msg));
2d33f157 96
d62a17ae 97 new->hdr.version = OSPF_API_VERSION;
98 new->hdr.msgtype = msgtype;
99 new->hdr.msglen = htons(msglen);
100 new->hdr.msgseq = htonl(seqnum);
2d33f157 101
d62a17ae 102 new->s = stream_new(msglen);
103 assert(new->s);
104 stream_put(new->s, msgbody, msglen);
2d33f157 105
d62a17ae 106 return new;
2d33f157 107}
108
109
110/* Duplicate a message by copying content. */
d62a17ae 111struct msg *msg_dup(struct msg *msg)
2d33f157 112{
d62a17ae 113 struct msg *new;
2d33f157 114
d62a17ae 115 assert(msg);
2d33f157 116
d62a17ae 117 new = msg_new(msg->hdr.msgtype, STREAM_DATA(msg->s),
118 ntohl(msg->hdr.msgseq), ntohs(msg->hdr.msglen));
119 return new;
2d33f157 120}
121
122
123/* XXX only for testing, will be removed */
124
125struct nametab {
d62a17ae 126 int value;
127 const char *name;
2d33f157 128};
129
d62a17ae 130const char *ospf_api_typename(int msgtype)
2d33f157 131{
d62a17ae 132 struct nametab NameTab[] = {
133 {
9d303b37 134 MSG_REGISTER_OPAQUETYPE, "Register opaque-type",
d62a17ae 135 },
136 {
9d303b37 137 MSG_UNREGISTER_OPAQUETYPE, "Unregister opaque-type",
d62a17ae 138 },
139 {
9d303b37 140 MSG_REGISTER_EVENT, "Register event",
d62a17ae 141 },
142 {
9d303b37 143 MSG_SYNC_LSDB, "Sync LSDB",
d62a17ae 144 },
145 {
9d303b37 146 MSG_ORIGINATE_REQUEST, "Originate request",
d62a17ae 147 },
148 {
9d303b37 149 MSG_DELETE_REQUEST, "Delete request",
d62a17ae 150 },
151 {
9d303b37 152 MSG_REPLY, "Reply",
d62a17ae 153 },
154 {
9d303b37 155 MSG_READY_NOTIFY, "Ready notify",
d62a17ae 156 },
157 {
9d303b37 158 MSG_LSA_UPDATE_NOTIFY, "LSA update notify",
d62a17ae 159 },
160 {
9d303b37 161 MSG_LSA_DELETE_NOTIFY, "LSA delete notify",
d62a17ae 162 },
163 {
9d303b37 164 MSG_NEW_IF, "New interface",
d62a17ae 165 },
166 {
9d303b37 167 MSG_DEL_IF, "Del interface",
d62a17ae 168 },
169 {
9d303b37 170 MSG_ISM_CHANGE, "ISM change",
d62a17ae 171 },
172 {
9d303b37 173 MSG_NSM_CHANGE, "NSM change",
d62a17ae 174 },
175 };
176
177 int i, n = array_size(NameTab);
178 const char *name = NULL;
179
180 for (i = 0; i < n; i++) {
181 if (NameTab[i].value == msgtype) {
182 name = NameTab[i].name;
183 break;
184 }
185 }
186
187 return name ? name : "?";
2d33f157 188}
189
d62a17ae 190const char *ospf_api_errname(int errcode)
2d33f157 191{
d62a17ae 192 struct nametab NameTab[] = {
193 {
9d303b37 194 OSPF_API_OK, "OK",
d62a17ae 195 },
196 {
9d303b37 197 OSPF_API_NOSUCHINTERFACE, "No such interface",
d62a17ae 198 },
199 {
9d303b37 200 OSPF_API_NOSUCHAREA, "No such area",
d62a17ae 201 },
202 {
9d303b37 203 OSPF_API_NOSUCHLSA, "No such LSA",
d62a17ae 204 },
205 {
9d303b37 206 OSPF_API_ILLEGALLSATYPE, "Illegal LSA type",
d62a17ae 207 },
208 {
9d303b37 209 OSPF_API_OPAQUETYPEINUSE, "Opaque type in use",
d62a17ae 210 },
211 {
212 OSPF_API_OPAQUETYPENOTREGISTERED,
213 "Opaque type not registered",
214 },
215 {
9d303b37 216 OSPF_API_NOTREADY, "Not ready",
d62a17ae 217 },
218 {
9d303b37 219 OSPF_API_NOMEMORY, "No memory",
d62a17ae 220 },
221 {
9d303b37 222 OSPF_API_ERROR, "Other error",
d62a17ae 223 },
224 {
9d303b37 225 OSPF_API_UNDEF, "Undefined",
d62a17ae 226 },
227 };
228
229 int i, n = array_size(NameTab);
230 const char *name = NULL;
231
232 for (i = 0; i < n; i++) {
233 if (NameTab[i].value == errcode) {
234 name = NameTab[i].name;
235 break;
236 }
237 }
238
239 return name ? name : "?";
2d33f157 240}
241
d62a17ae 242void msg_print(struct msg *msg)
2d33f157 243{
d62a17ae 244 if (!msg) {
9165c5f5 245 zlog_debug("msg_print msg=NULL!");
d62a17ae 246 return;
247 }
2d33f157 248
d62a17ae 249 /* API message common header part. */
250 zlog_debug("API-msg [%s]: type(%d),len(%d),seq(%lu),data(%p),size(%zd)",
251 ospf_api_typename(msg->hdr.msgtype), msg->hdr.msgtype,
252 ntohs(msg->hdr.msglen),
253 (unsigned long)ntohl(msg->hdr.msgseq), STREAM_DATA(msg->s),
254 STREAM_SIZE(msg->s));
255
d62a17ae 256 return;
2d33f157 257}
258
d62a17ae 259void msg_free(struct msg *msg)
2d33f157 260{
d62a17ae 261 if (msg->s)
262 stream_free(msg->s);
2d33f157 263
d62a17ae 264 XFREE(MTYPE_OSPF_API_MSG, msg);
2d33f157 265}
266
267
268/* Set sequence number of message */
d7c0a89a 269void msg_set_seq(struct msg *msg, uint32_t seqnr)
2d33f157 270{
d62a17ae 271 assert(msg);
272 msg->hdr.msgseq = htonl(seqnr);
2d33f157 273}
274
275/* Get sequence number of message */
d7c0a89a 276uint32_t msg_get_seq(struct msg *msg)
2d33f157 277{
d62a17ae 278 assert(msg);
279 return ntohl(msg->hdr.msgseq);
2d33f157 280}
281
282/* -----------------------------------------------------------
283 * Message fifo queues
284 * -----------------------------------------------------------
285 */
286
4d762f26 287struct msg_fifo *msg_fifo_new(void)
2d33f157 288{
d62a17ae 289 return XCALLOC(MTYPE_OSPF_API_FIFO, sizeof(struct msg_fifo));
2d33f157 290}
291
292/* Add new message to fifo. */
d62a17ae 293void msg_fifo_push(struct msg_fifo *fifo, struct msg *msg)
2d33f157 294{
d62a17ae 295 if (fifo->tail)
296 fifo->tail->next = msg;
297 else
298 fifo->head = msg;
2d33f157 299
d62a17ae 300 fifo->tail = msg;
301 fifo->count++;
2d33f157 302}
303
304
305/* Remove first message from fifo. */
d62a17ae 306struct msg *msg_fifo_pop(struct msg_fifo *fifo)
2d33f157 307{
d62a17ae 308 struct msg *msg;
2d33f157 309
d62a17ae 310 msg = fifo->head;
311 if (msg) {
312 fifo->head = msg->next;
2d33f157 313
d62a17ae 314 if (fifo->head == NULL)
315 fifo->tail = NULL;
2d33f157 316
d62a17ae 317 fifo->count--;
318 }
319 return msg;
2d33f157 320}
321
322/* Return first fifo entry but do not remove it. */
d62a17ae 323struct msg *msg_fifo_head(struct msg_fifo *fifo)
2d33f157 324{
d62a17ae 325 return fifo->head;
2d33f157 326}
327
328/* Flush message fifo. */
d62a17ae 329void msg_fifo_flush(struct msg_fifo *fifo)
2d33f157 330{
d62a17ae 331 struct msg *op;
332 struct msg *next;
2d33f157 333
d62a17ae 334 for (op = fifo->head; op; op = next) {
335 next = op->next;
336 msg_free(op);
337 }
2d33f157 338
d62a17ae 339 fifo->head = fifo->tail = NULL;
340 fifo->count = 0;
2d33f157 341}
342
343/* Free API message fifo. */
d62a17ae 344void msg_fifo_free(struct msg_fifo *fifo)
2d33f157 345{
d62a17ae 346 msg_fifo_flush(fifo);
2d33f157 347
d62a17ae 348 XFREE(MTYPE_OSPF_API_FIFO, fifo);
2d33f157 349}
350
d62a17ae 351struct msg *msg_read(int fd)
2d33f157 352{
d62a17ae 353 struct msg *msg;
354 struct apimsghdr hdr;
d7c0a89a 355 uint8_t buf[OSPF_API_MAX_MSG_SIZE];
d62a17ae 356 int bodylen;
357 int rlen;
358
359 /* Read message header */
d7c0a89a 360 rlen = readn(fd, (uint8_t *)&hdr, sizeof(struct apimsghdr));
d62a17ae 361
362 if (rlen < 0) {
363 zlog_warn("msg_read: readn %s", safe_strerror(errno));
364 return NULL;
365 } else if (rlen == 0) {
366 zlog_warn("msg_read: Connection closed by peer");
367 return NULL;
368 } else if (rlen != sizeof(struct apimsghdr)) {
369 zlog_warn("msg_read: Cannot read message header!");
370 return NULL;
2d33f157 371 }
d62a17ae 372
373 /* Check version of API protocol */
374 if (hdr.version != OSPF_API_VERSION) {
375 zlog_warn("msg_read: OSPF API protocol version mismatch");
376 return NULL;
2d33f157 377 }
d62a17ae 378
379 /* Determine body length. */
380 bodylen = ntohs(hdr.msglen);
381 if (bodylen > 0) {
382
383 /* Read message body */
384 rlen = readn(fd, buf, bodylen);
385 if (rlen < 0) {
386 zlog_warn("msg_read: readn %s", safe_strerror(errno));
387 return NULL;
388 } else if (rlen == 0) {
389 zlog_warn("msg_read: Connection closed by peer");
390 return NULL;
391 } else if (rlen != bodylen) {
392 zlog_warn("msg_read: Cannot read message body!");
393 return NULL;
394 }
2d33f157 395 }
2d33f157 396
d62a17ae 397 /* Allocate new message */
398 msg = msg_new(hdr.msgtype, buf, ntohl(hdr.msgseq), ntohs(hdr.msglen));
2d33f157 399
d62a17ae 400 return msg;
2d33f157 401}
402
d62a17ae 403int msg_write(int fd, struct msg *msg)
2d33f157 404{
d7c0a89a 405 uint8_t buf[OSPF_API_MAX_MSG_SIZE];
d62a17ae 406 int l;
407 int wlen;
408
409 assert(msg);
410 assert(msg->s);
411
412 /* Length of message including header */
413 l = sizeof(struct apimsghdr) + ntohs(msg->hdr.msglen);
414
415 /* Make contiguous memory buffer for message */
416 memcpy(buf, &msg->hdr, sizeof(struct apimsghdr));
417 memcpy(buf + sizeof(struct apimsghdr), STREAM_DATA(msg->s),
418 ntohs(msg->hdr.msglen));
419
420 wlen = writen(fd, buf, l);
421 if (wlen < 0) {
422 zlog_warn("msg_write: writen %s", safe_strerror(errno));
423 return -1;
424 } else if (wlen == 0) {
425 zlog_warn("msg_write: Connection closed by peer");
426 return -1;
427 } else if (wlen != l) {
428 zlog_warn("msg_write: Cannot write API message");
429 return -1;
430 }
431 return 0;
2d33f157 432}
433
434/* -----------------------------------------------------------
435 * Specific messages
436 * -----------------------------------------------------------
437 */
438
d7c0a89a
QY
439struct msg *new_msg_register_opaque_type(uint32_t seqnum, uint8_t ltype,
440 uint8_t otype)
2d33f157 441{
d62a17ae 442 struct msg_register_opaque_type rmsg;
2d33f157 443
d62a17ae 444 rmsg.lsatype = ltype;
445 rmsg.opaquetype = otype;
446 memset(&rmsg.pad, 0, sizeof(rmsg.pad));
2d33f157 447
d62a17ae 448 return msg_new(MSG_REGISTER_OPAQUETYPE, &rmsg, seqnum,
449 sizeof(struct msg_register_opaque_type));
2d33f157 450}
451
d7c0a89a 452struct msg *new_msg_register_event(uint32_t seqnum,
d62a17ae 453 struct lsa_filter_type *filter)
2d33f157 454{
d7c0a89a 455 uint8_t buf[OSPF_API_MAX_MSG_SIZE];
d62a17ae 456 struct msg_register_event *emsg;
457 unsigned int len;
458
459 emsg = (struct msg_register_event *)buf;
460 len = sizeof(struct msg_register_event)
461 + filter->num_areas * sizeof(struct in_addr);
462 emsg->filter.typemask = htons(filter->typemask);
463 emsg->filter.origin = filter->origin;
464 emsg->filter.num_areas = filter->num_areas;
465 if (len > sizeof(buf))
466 len = sizeof(buf);
467 /* API broken - missing memcpy to fill data */
468 return msg_new(MSG_REGISTER_EVENT, emsg, seqnum, len);
2d33f157 469}
470
d7c0a89a 471struct msg *new_msg_sync_lsdb(uint32_t seqnum, struct lsa_filter_type *filter)
2d33f157 472{
d7c0a89a 473 uint8_t buf[OSPF_API_MAX_MSG_SIZE];
d62a17ae 474 struct msg_sync_lsdb *smsg;
475 unsigned int len;
476
477 smsg = (struct msg_sync_lsdb *)buf;
478 len = sizeof(struct msg_sync_lsdb)
479 + filter->num_areas * sizeof(struct in_addr);
480 smsg->filter.typemask = htons(filter->typemask);
481 smsg->filter.origin = filter->origin;
482 smsg->filter.num_areas = filter->num_areas;
483 if (len > sizeof(buf))
484 len = sizeof(buf);
485 /* API broken - missing memcpy to fill data */
486 return msg_new(MSG_SYNC_LSDB, smsg, seqnum, len);
2d33f157 487}
488
489
d7c0a89a 490struct msg *new_msg_originate_request(uint32_t seqnum, struct in_addr ifaddr,
d62a17ae 491 struct in_addr area_id,
492 struct lsa_header *data)
2d33f157 493{
d62a17ae 494 struct msg_originate_request *omsg;
495 unsigned int omsglen;
496 char buf[OSPF_API_MAX_MSG_SIZE];
c23bc38a 497 size_t off_data = offsetof(struct msg_originate_request, data);
498 size_t data_maxs = sizeof(buf) - off_data;
499 struct lsa_header *omsg_data = (struct lsa_header *)&buf[off_data];
d62a17ae 500
501 omsg = (struct msg_originate_request *)buf;
502 omsg->ifaddr = ifaddr;
503 omsg->area_id = area_id;
504
505 omsglen = ntohs(data->length);
c23bc38a 506 if (omsglen > data_maxs)
507 omsglen = data_maxs;
508 memcpy(omsg_data, data, omsglen);
d62a17ae 509 omsglen += sizeof(struct msg_originate_request)
510 - sizeof(struct lsa_header);
511
512 return msg_new(MSG_ORIGINATE_REQUEST, omsg, seqnum, omsglen);
2d33f157 513}
514
d7c0a89a
QY
515struct msg *new_msg_delete_request(uint32_t seqnum, struct in_addr area_id,
516 uint8_t lsa_type, uint8_t opaque_type,
517 uint32_t opaque_id)
2d33f157 518{
d62a17ae 519 struct msg_delete_request dmsg;
520 dmsg.area_id = area_id;
521 dmsg.lsa_type = lsa_type;
522 dmsg.opaque_type = opaque_type;
523 dmsg.opaque_id = htonl(opaque_id);
524 memset(&dmsg.pad, 0, sizeof(dmsg.pad));
525
526 return msg_new(MSG_DELETE_REQUEST, &dmsg, seqnum,
527 sizeof(struct msg_delete_request));
2d33f157 528}
529
530
d7c0a89a 531struct msg *new_msg_reply(uint32_t seqnr, uint8_t rc)
2d33f157 532{
d62a17ae 533 struct msg *msg;
534 struct msg_reply rmsg;
2d33f157 535
d62a17ae 536 /* Set return code */
537 rmsg.errcode = rc;
538 memset(&rmsg.pad, 0, sizeof(rmsg.pad));
2d33f157 539
d62a17ae 540 msg = msg_new(MSG_REPLY, &rmsg, seqnr, sizeof(struct msg_reply));
2d33f157 541
d62a17ae 542 return msg;
2d33f157 543}
544
d7c0a89a
QY
545struct msg *new_msg_ready_notify(uint32_t seqnr, uint8_t lsa_type,
546 uint8_t opaque_type, struct in_addr addr)
2d33f157 547{
d62a17ae 548 struct msg_ready_notify rmsg;
2d33f157 549
d62a17ae 550 rmsg.lsa_type = lsa_type;
551 rmsg.opaque_type = opaque_type;
552 memset(&rmsg.pad, 0, sizeof(rmsg.pad));
553 rmsg.addr = addr;
2d33f157 554
d62a17ae 555 return msg_new(MSG_READY_NOTIFY, &rmsg, seqnr,
556 sizeof(struct msg_ready_notify));
2d33f157 557}
558
d7c0a89a 559struct msg *new_msg_new_if(uint32_t seqnr, struct in_addr ifaddr,
d62a17ae 560 struct in_addr area_id)
2d33f157 561{
d62a17ae 562 struct msg_new_if nmsg;
2d33f157 563
d62a17ae 564 nmsg.ifaddr = ifaddr;
565 nmsg.area_id = area_id;
2d33f157 566
d62a17ae 567 return msg_new(MSG_NEW_IF, &nmsg, seqnr, sizeof(struct msg_new_if));
2d33f157 568}
569
d7c0a89a 570struct msg *new_msg_del_if(uint32_t seqnr, struct in_addr ifaddr)
2d33f157 571{
d62a17ae 572 struct msg_del_if dmsg;
2d33f157 573
d62a17ae 574 dmsg.ifaddr = ifaddr;
2d33f157 575
d62a17ae 576 return msg_new(MSG_DEL_IF, &dmsg, seqnr, sizeof(struct msg_del_if));
2d33f157 577}
578
d7c0a89a
QY
579struct msg *new_msg_ism_change(uint32_t seqnr, struct in_addr ifaddr,
580 struct in_addr area_id, uint8_t status)
2d33f157 581{
d62a17ae 582 struct msg_ism_change imsg;
2d33f157 583
d62a17ae 584 imsg.ifaddr = ifaddr;
585 imsg.area_id = area_id;
586 imsg.status = status;
587 memset(&imsg.pad, 0, sizeof(imsg.pad));
2d33f157 588
d62a17ae 589 return msg_new(MSG_ISM_CHANGE, &imsg, seqnr,
590 sizeof(struct msg_ism_change));
2d33f157 591}
592
d7c0a89a 593struct msg *new_msg_nsm_change(uint32_t seqnr, struct in_addr ifaddr,
d62a17ae 594 struct in_addr nbraddr, struct in_addr router_id,
d7c0a89a 595 uint8_t status)
2d33f157 596{
d62a17ae 597 struct msg_nsm_change nmsg;
2d33f157 598
d62a17ae 599 nmsg.ifaddr = ifaddr;
600 nmsg.nbraddr = nbraddr;
601 nmsg.router_id = router_id;
602 nmsg.status = status;
603 memset(&nmsg.pad, 0, sizeof(nmsg.pad));
2d33f157 604
d62a17ae 605 return msg_new(MSG_NSM_CHANGE, &nmsg, seqnr,
606 sizeof(struct msg_nsm_change));
2d33f157 607}
608
d7c0a89a 609struct msg *new_msg_lsa_change_notify(uint8_t msgtype, uint32_t seqnum,
d62a17ae 610 struct in_addr ifaddr,
611 struct in_addr area_id,
d7c0a89a 612 uint8_t is_self_originated,
d62a17ae 613 struct lsa_header *data)
2d33f157 614{
d7c0a89a 615 uint8_t buf[OSPF_API_MAX_MSG_SIZE];
d62a17ae 616 struct msg_lsa_change_notify *nmsg;
617 unsigned int len;
c23bc38a 618 size_t off_data = offsetof(struct msg_lsa_change_notify, data);
619 size_t data_maxs = sizeof(buf) - off_data;
620 struct lsa_header *nmsg_data = (struct lsa_header *)&buf[off_data];
d62a17ae 621
622 assert(data);
623
624 nmsg = (struct msg_lsa_change_notify *)buf;
625 nmsg->ifaddr = ifaddr;
626 nmsg->area_id = area_id;
627 nmsg->is_self_originated = is_self_originated;
628 memset(&nmsg->pad, 0, sizeof(nmsg->pad));
629
630 len = ntohs(data->length);
c23bc38a 631 if (len > data_maxs)
632 len = data_maxs;
633 memcpy(nmsg_data, data, len);
d62a17ae 634 len += sizeof(struct msg_lsa_change_notify) - sizeof(struct lsa_header);
635
636 return msg_new(msgtype, nmsg, seqnum, len);
2d33f157 637}
638
639#endif /* SUPPORT_OSPF_API */