olsa = (struct opaque_lsa *)data;
opaquelen = ntohs(data->length) - OSPF_LSA_HEADER_SIZE;
- zlog_debug("apiserver_lsa_print: opaquelen=%d\n", opaquelen);
+ zlog_debug("apiserver_lsa_print: opaquelen=%d", opaquelen);
for (i = 0; i < opaquelen; i++) {
zlog_debug("0x%x ", olsa->mydata[i]);
}
- zlog_debug("\n");
+ zlog_debug(" ");
}
/* -----------------------------------------------------------
void msg_print(struct msg *msg)
{
if (!msg) {
- zlog_debug("msg_print msg=NULL!\n");
+ zlog_debug("msg_print msg=NULL!");
return;
}
-#ifdef ORIGINAL_CODING
- zlog_debug(
- "msg=%p msgtype=%d msglen=%d msgseq=%d streamdata=%p streamsize=%lu\n",
- msg, msg->hdr.msgtype, ntohs(msg->hdr.msglen),
- ntohl(msg->hdr.msgseq), STREAM_DATA(msg->s),
- STREAM_SIZE(msg->s));
-#else /* ORIGINAL_CODING */
/* API message common header part. */
zlog_debug("API-msg [%s]: type(%d),len(%d),seq(%lu),data(%p),size(%zd)",
ospf_api_typename(msg->hdr.msgtype), msg->hdr.msgtype,
(unsigned long)ntohl(msg->hdr.msgseq), STREAM_DATA(msg->s),
STREAM_SIZE(msg->s));
-/* API message body part. */
-#ifdef ndef
- /* Generic Hex/Ascii dump */
- DumpBuf(STREAM_DATA(msg->s), STREAM_SIZE(msg->s)); /* Sorry, deleted! */
-#else /* ndef */
-/* Message-type dependent dump function. */
-#endif /* ndef */
-
return;
-#endif /* ORIGINAL_CODING */
}
void msg_free(struct msg *msg)
* -----------------------------------------------------------
*/
-struct msg_fifo *msg_fifo_new()
+struct msg_fifo *msg_fifo_new(void)
{
return XCALLOC(MTYPE_OSPF_API_FIFO, sizeof(struct msg_fifo));
}
struct msg_originate_request *omsg;
unsigned int omsglen;
char buf[OSPF_API_MAX_MSG_SIZE];
+ size_t off_data = offsetof(struct msg_originate_request, data);
+ size_t data_maxs = sizeof(buf) - off_data;
+ struct lsa_header *omsg_data = (struct lsa_header *)&buf[off_data];
omsg = (struct msg_originate_request *)buf;
omsg->ifaddr = ifaddr;
omsg->area_id = area_id;
omsglen = ntohs(data->length);
- if (omsglen
- > sizeof(buf) - offsetof(struct msg_originate_request, data))
- omsglen = sizeof(buf)
- - offsetof(struct msg_originate_request, data);
- memcpy(&omsg->data, data, omsglen);
+ if (omsglen > data_maxs)
+ omsglen = data_maxs;
+ memcpy(omsg_data, data, omsglen);
omsglen += sizeof(struct msg_originate_request)
- sizeof(struct lsa_header);
uint8_t buf[OSPF_API_MAX_MSG_SIZE];
struct msg_lsa_change_notify *nmsg;
unsigned int len;
+ size_t off_data = offsetof(struct msg_lsa_change_notify, data);
+ size_t data_maxs = sizeof(buf) - off_data;
+ struct lsa_header *nmsg_data = (struct lsa_header *)&buf[off_data];
assert(data);
memset(&nmsg->pad, 0, sizeof(nmsg->pad));
len = ntohs(data->length);
- if (len > sizeof(buf) - offsetof(struct msg_lsa_change_notify, data))
- len = sizeof(buf)
- - offsetof(struct msg_lsa_change_notify, data);
- memcpy(&nmsg->data, data, len);
+ if (len > data_maxs)
+ len = data_maxs;
+ memcpy(nmsg_data, data, len);
len += sizeof(struct msg_lsa_change_notify) - sizeof(struct lsa_header);
return msg_new(msgtype, nmsg, seqnum, len);