]> git.proxmox.com Git - mirror_frr.git/blame - ospfd/ospf_api.c
Merge pull request #1653 from Orange-OpenSource/SR-Routing
[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;
65 u_char mydata[];
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;
77 zlog_debug("apiserver_lsa_print: opaquelen=%d\n", opaquelen);
2d33f157 78
d62a17ae 79 for (i = 0; i < opaquelen; i++) {
80 zlog_debug("0x%x ", olsa->mydata[i]);
81 }
82 zlog_debug("\n");
2d33f157 83}
84
85/* -----------------------------------------------------------
86 * Generic messages
87 * -----------------------------------------------------------
88 */
89
d62a17ae 90struct msg *msg_new(u_char msgtype, void *msgbody, u_int32_t seqnum,
91 u_int16_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) {
245 zlog_debug("msg_print msg=NULL!\n");
246 return;
247 }
2d33f157 248
249#ifdef ORIGINAL_CODING
d62a17ae 250 zlog_debug(
251 "msg=%p msgtype=%d msglen=%d msgseq=%d streamdata=%p streamsize=%lu\n",
252 msg, msg->hdr.msgtype, ntohs(msg->hdr.msglen),
253 ntohl(msg->hdr.msgseq), STREAM_DATA(msg->s),
254 STREAM_SIZE(msg->s));
2d33f157 255#else /* ORIGINAL_CODING */
d62a17ae 256 /* API message common header part. */
257 zlog_debug("API-msg [%s]: type(%d),len(%d),seq(%lu),data(%p),size(%zd)",
258 ospf_api_typename(msg->hdr.msgtype), msg->hdr.msgtype,
259 ntohs(msg->hdr.msglen),
260 (unsigned long)ntohl(msg->hdr.msgseq), STREAM_DATA(msg->s),
261 STREAM_SIZE(msg->s));
262
263/* API message body part. */
2d33f157 264#ifdef ndef
d62a17ae 265 /* Generic Hex/Ascii dump */
266 DumpBuf(STREAM_DATA(msg->s), STREAM_SIZE(msg->s)); /* Sorry, deleted! */
267#else /* ndef */
268/* Message-type dependent dump function. */
2d33f157 269#endif /* ndef */
270
d62a17ae 271 return;
2d33f157 272#endif /* ORIGINAL_CODING */
273}
274
d62a17ae 275void msg_free(struct msg *msg)
2d33f157 276{
d62a17ae 277 if (msg->s)
278 stream_free(msg->s);
2d33f157 279
d62a17ae 280 XFREE(MTYPE_OSPF_API_MSG, msg);
2d33f157 281}
282
283
284/* Set sequence number of message */
d62a17ae 285void msg_set_seq(struct msg *msg, u_int32_t seqnr)
2d33f157 286{
d62a17ae 287 assert(msg);
288 msg->hdr.msgseq = htonl(seqnr);
2d33f157 289}
290
291/* Get sequence number of message */
d62a17ae 292u_int32_t msg_get_seq(struct msg *msg)
2d33f157 293{
d62a17ae 294 assert(msg);
295 return ntohl(msg->hdr.msgseq);
2d33f157 296}
297
298/* -----------------------------------------------------------
299 * Message fifo queues
300 * -----------------------------------------------------------
301 */
302
d62a17ae 303struct msg_fifo *msg_fifo_new()
2d33f157 304{
d62a17ae 305 return XCALLOC(MTYPE_OSPF_API_FIFO, sizeof(struct msg_fifo));
2d33f157 306}
307
308/* Add new message to fifo. */
d62a17ae 309void msg_fifo_push(struct msg_fifo *fifo, struct msg *msg)
2d33f157 310{
d62a17ae 311 if (fifo->tail)
312 fifo->tail->next = msg;
313 else
314 fifo->head = msg;
2d33f157 315
d62a17ae 316 fifo->tail = msg;
317 fifo->count++;
2d33f157 318}
319
320
321/* Remove first message from fifo. */
d62a17ae 322struct msg *msg_fifo_pop(struct msg_fifo *fifo)
2d33f157 323{
d62a17ae 324 struct msg *msg;
2d33f157 325
d62a17ae 326 msg = fifo->head;
327 if (msg) {
328 fifo->head = msg->next;
2d33f157 329
d62a17ae 330 if (fifo->head == NULL)
331 fifo->tail = NULL;
2d33f157 332
d62a17ae 333 fifo->count--;
334 }
335 return msg;
2d33f157 336}
337
338/* Return first fifo entry but do not remove it. */
d62a17ae 339struct msg *msg_fifo_head(struct msg_fifo *fifo)
2d33f157 340{
d62a17ae 341 return fifo->head;
2d33f157 342}
343
344/* Flush message fifo. */
d62a17ae 345void msg_fifo_flush(struct msg_fifo *fifo)
2d33f157 346{
d62a17ae 347 struct msg *op;
348 struct msg *next;
2d33f157 349
d62a17ae 350 for (op = fifo->head; op; op = next) {
351 next = op->next;
352 msg_free(op);
353 }
2d33f157 354
d62a17ae 355 fifo->head = fifo->tail = NULL;
356 fifo->count = 0;
2d33f157 357}
358
359/* Free API message fifo. */
d62a17ae 360void msg_fifo_free(struct msg_fifo *fifo)
2d33f157 361{
d62a17ae 362 msg_fifo_flush(fifo);
2d33f157 363
d62a17ae 364 XFREE(MTYPE_OSPF_API_FIFO, fifo);
2d33f157 365}
366
d62a17ae 367struct msg *msg_read(int fd)
2d33f157 368{
d62a17ae 369 struct msg *msg;
370 struct apimsghdr hdr;
371 u_char buf[OSPF_API_MAX_MSG_SIZE];
372 int bodylen;
373 int rlen;
374
375 /* Read message header */
376 rlen = readn(fd, (u_char *)&hdr, sizeof(struct apimsghdr));
377
378 if (rlen < 0) {
379 zlog_warn("msg_read: readn %s", safe_strerror(errno));
380 return NULL;
381 } else if (rlen == 0) {
382 zlog_warn("msg_read: Connection closed by peer");
383 return NULL;
384 } else if (rlen != sizeof(struct apimsghdr)) {
385 zlog_warn("msg_read: Cannot read message header!");
386 return NULL;
2d33f157 387 }
d62a17ae 388
389 /* Check version of API protocol */
390 if (hdr.version != OSPF_API_VERSION) {
391 zlog_warn("msg_read: OSPF API protocol version mismatch");
392 return NULL;
2d33f157 393 }
d62a17ae 394
395 /* Determine body length. */
396 bodylen = ntohs(hdr.msglen);
397 if (bodylen > 0) {
398
399 /* Read message body */
400 rlen = readn(fd, buf, bodylen);
401 if (rlen < 0) {
402 zlog_warn("msg_read: readn %s", safe_strerror(errno));
403 return NULL;
404 } else if (rlen == 0) {
405 zlog_warn("msg_read: Connection closed by peer");
406 return NULL;
407 } else if (rlen != bodylen) {
408 zlog_warn("msg_read: Cannot read message body!");
409 return NULL;
410 }
2d33f157 411 }
2d33f157 412
d62a17ae 413 /* Allocate new message */
414 msg = msg_new(hdr.msgtype, buf, ntohl(hdr.msgseq), ntohs(hdr.msglen));
2d33f157 415
d62a17ae 416 return msg;
2d33f157 417}
418
d62a17ae 419int msg_write(int fd, struct msg *msg)
2d33f157 420{
d62a17ae 421 u_char buf[OSPF_API_MAX_MSG_SIZE];
422 int l;
423 int wlen;
424
425 assert(msg);
426 assert(msg->s);
427
428 /* Length of message including header */
429 l = sizeof(struct apimsghdr) + ntohs(msg->hdr.msglen);
430
431 /* Make contiguous memory buffer for message */
432 memcpy(buf, &msg->hdr, sizeof(struct apimsghdr));
433 memcpy(buf + sizeof(struct apimsghdr), STREAM_DATA(msg->s),
434 ntohs(msg->hdr.msglen));
435
436 wlen = writen(fd, buf, l);
437 if (wlen < 0) {
438 zlog_warn("msg_write: writen %s", safe_strerror(errno));
439 return -1;
440 } else if (wlen == 0) {
441 zlog_warn("msg_write: Connection closed by peer");
442 return -1;
443 } else if (wlen != l) {
444 zlog_warn("msg_write: Cannot write API message");
445 return -1;
446 }
447 return 0;
2d33f157 448}
449
450/* -----------------------------------------------------------
451 * Specific messages
452 * -----------------------------------------------------------
453 */
454
d62a17ae 455struct msg *new_msg_register_opaque_type(u_int32_t seqnum, u_char ltype,
456 u_char otype)
2d33f157 457{
d62a17ae 458 struct msg_register_opaque_type rmsg;
2d33f157 459
d62a17ae 460 rmsg.lsatype = ltype;
461 rmsg.opaquetype = otype;
462 memset(&rmsg.pad, 0, sizeof(rmsg.pad));
2d33f157 463
d62a17ae 464 return msg_new(MSG_REGISTER_OPAQUETYPE, &rmsg, seqnum,
465 sizeof(struct msg_register_opaque_type));
2d33f157 466}
467
d62a17ae 468struct msg *new_msg_register_event(u_int32_t seqnum,
469 struct lsa_filter_type *filter)
2d33f157 470{
d62a17ae 471 u_char buf[OSPF_API_MAX_MSG_SIZE];
472 struct msg_register_event *emsg;
473 unsigned int len;
474
475 emsg = (struct msg_register_event *)buf;
476 len = sizeof(struct msg_register_event)
477 + filter->num_areas * sizeof(struct in_addr);
478 emsg->filter.typemask = htons(filter->typemask);
479 emsg->filter.origin = filter->origin;
480 emsg->filter.num_areas = filter->num_areas;
481 if (len > sizeof(buf))
482 len = sizeof(buf);
483 /* API broken - missing memcpy to fill data */
484 return msg_new(MSG_REGISTER_EVENT, emsg, seqnum, len);
2d33f157 485}
486
d62a17ae 487struct msg *new_msg_sync_lsdb(u_int32_t seqnum, struct lsa_filter_type *filter)
2d33f157 488{
d62a17ae 489 u_char buf[OSPF_API_MAX_MSG_SIZE];
490 struct msg_sync_lsdb *smsg;
491 unsigned int len;
492
493 smsg = (struct msg_sync_lsdb *)buf;
494 len = sizeof(struct msg_sync_lsdb)
495 + filter->num_areas * sizeof(struct in_addr);
496 smsg->filter.typemask = htons(filter->typemask);
497 smsg->filter.origin = filter->origin;
498 smsg->filter.num_areas = filter->num_areas;
499 if (len > sizeof(buf))
500 len = sizeof(buf);
501 /* API broken - missing memcpy to fill data */
502 return msg_new(MSG_SYNC_LSDB, smsg, seqnum, len);
2d33f157 503}
504
505
d62a17ae 506struct msg *new_msg_originate_request(u_int32_t seqnum, struct in_addr ifaddr,
507 struct in_addr area_id,
508 struct lsa_header *data)
2d33f157 509{
d62a17ae 510 struct msg_originate_request *omsg;
511 unsigned int omsglen;
512 char buf[OSPF_API_MAX_MSG_SIZE];
513
514 omsg = (struct msg_originate_request *)buf;
515 omsg->ifaddr = ifaddr;
516 omsg->area_id = area_id;
517
518 omsglen = ntohs(data->length);
519 if (omsglen
520 > sizeof(buf) - offsetof(struct msg_originate_request, data))
521 omsglen = sizeof(buf)
522 - offsetof(struct msg_originate_request, data);
523 memcpy(&omsg->data, data, omsglen);
524 omsglen += sizeof(struct msg_originate_request)
525 - sizeof(struct lsa_header);
526
527 return msg_new(MSG_ORIGINATE_REQUEST, omsg, seqnum, omsglen);
2d33f157 528}
529
d62a17ae 530struct msg *new_msg_delete_request(u_int32_t seqnum, struct in_addr area_id,
531 u_char lsa_type, u_char opaque_type,
532 u_int32_t opaque_id)
2d33f157 533{
d62a17ae 534 struct msg_delete_request dmsg;
535 dmsg.area_id = area_id;
536 dmsg.lsa_type = lsa_type;
537 dmsg.opaque_type = opaque_type;
538 dmsg.opaque_id = htonl(opaque_id);
539 memset(&dmsg.pad, 0, sizeof(dmsg.pad));
540
541 return msg_new(MSG_DELETE_REQUEST, &dmsg, seqnum,
542 sizeof(struct msg_delete_request));
2d33f157 543}
544
545
d62a17ae 546struct msg *new_msg_reply(u_int32_t seqnr, u_char rc)
2d33f157 547{
d62a17ae 548 struct msg *msg;
549 struct msg_reply rmsg;
2d33f157 550
d62a17ae 551 /* Set return code */
552 rmsg.errcode = rc;
553 memset(&rmsg.pad, 0, sizeof(rmsg.pad));
2d33f157 554
d62a17ae 555 msg = msg_new(MSG_REPLY, &rmsg, seqnr, sizeof(struct msg_reply));
2d33f157 556
d62a17ae 557 return msg;
2d33f157 558}
559
d62a17ae 560struct msg *new_msg_ready_notify(u_int32_t seqnr, u_char lsa_type,
561 u_char opaque_type, struct in_addr addr)
2d33f157 562{
d62a17ae 563 struct msg_ready_notify rmsg;
2d33f157 564
d62a17ae 565 rmsg.lsa_type = lsa_type;
566 rmsg.opaque_type = opaque_type;
567 memset(&rmsg.pad, 0, sizeof(rmsg.pad));
568 rmsg.addr = addr;
2d33f157 569
d62a17ae 570 return msg_new(MSG_READY_NOTIFY, &rmsg, seqnr,
571 sizeof(struct msg_ready_notify));
2d33f157 572}
573
d62a17ae 574struct msg *new_msg_new_if(u_int32_t seqnr, struct in_addr ifaddr,
575 struct in_addr area_id)
2d33f157 576{
d62a17ae 577 struct msg_new_if nmsg;
2d33f157 578
d62a17ae 579 nmsg.ifaddr = ifaddr;
580 nmsg.area_id = area_id;
2d33f157 581
d62a17ae 582 return msg_new(MSG_NEW_IF, &nmsg, seqnr, sizeof(struct msg_new_if));
2d33f157 583}
584
d62a17ae 585struct msg *new_msg_del_if(u_int32_t seqnr, struct in_addr ifaddr)
2d33f157 586{
d62a17ae 587 struct msg_del_if dmsg;
2d33f157 588
d62a17ae 589 dmsg.ifaddr = ifaddr;
2d33f157 590
d62a17ae 591 return msg_new(MSG_DEL_IF, &dmsg, seqnr, sizeof(struct msg_del_if));
2d33f157 592}
593
d62a17ae 594struct msg *new_msg_ism_change(u_int32_t seqnr, struct in_addr ifaddr,
595 struct in_addr area_id, u_char status)
2d33f157 596{
d62a17ae 597 struct msg_ism_change imsg;
2d33f157 598
d62a17ae 599 imsg.ifaddr = ifaddr;
600 imsg.area_id = area_id;
601 imsg.status = status;
602 memset(&imsg.pad, 0, sizeof(imsg.pad));
2d33f157 603
d62a17ae 604 return msg_new(MSG_ISM_CHANGE, &imsg, seqnr,
605 sizeof(struct msg_ism_change));
2d33f157 606}
607
d62a17ae 608struct msg *new_msg_nsm_change(u_int32_t seqnr, struct in_addr ifaddr,
609 struct in_addr nbraddr, struct in_addr router_id,
610 u_char status)
2d33f157 611{
d62a17ae 612 struct msg_nsm_change nmsg;
2d33f157 613
d62a17ae 614 nmsg.ifaddr = ifaddr;
615 nmsg.nbraddr = nbraddr;
616 nmsg.router_id = router_id;
617 nmsg.status = status;
618 memset(&nmsg.pad, 0, sizeof(nmsg.pad));
2d33f157 619
d62a17ae 620 return msg_new(MSG_NSM_CHANGE, &nmsg, seqnr,
621 sizeof(struct msg_nsm_change));
2d33f157 622}
623
d62a17ae 624struct msg *new_msg_lsa_change_notify(u_char msgtype, u_int32_t seqnum,
625 struct in_addr ifaddr,
626 struct in_addr area_id,
627 u_char is_self_originated,
628 struct lsa_header *data)
2d33f157 629{
d62a17ae 630 u_char buf[OSPF_API_MAX_MSG_SIZE];
631 struct msg_lsa_change_notify *nmsg;
632 unsigned int len;
633
634 assert(data);
635
636 nmsg = (struct msg_lsa_change_notify *)buf;
637 nmsg->ifaddr = ifaddr;
638 nmsg->area_id = area_id;
639 nmsg->is_self_originated = is_self_originated;
640 memset(&nmsg->pad, 0, sizeof(nmsg->pad));
641
642 len = ntohs(data->length);
643 if (len > sizeof(buf) - offsetof(struct msg_lsa_change_notify, data))
644 len = sizeof(buf)
645 - offsetof(struct msg_lsa_change_notify, data);
646 memcpy(&nmsg->data, data, len);
647 len += sizeof(struct msg_lsa_change_notify) - sizeof(struct lsa_header);
648
649 return msg_new(msgtype, nmsg, seqnum, len);
2d33f157 650}
651
652#endif /* SUPPORT_OSPF_API */