示例#1
0
void
send_address_withdraw(struct nbr *nbr, struct iface *iface)
{
	struct ibuf	*buf;
	u_int16_t	 size;

	if (nbr->iface->passive)
		return;

	log_debug("send_address_withdraw: neighbor ID %s", inet_ntoa(nbr->id));

	if ((buf = ibuf_open(LDP_MAX_LEN)) == NULL)
		fatal("send_address_withdraw");

	/* XXX: multiple address on the same iface? */
	size = LDP_HDR_SIZE + sizeof(struct ldp_msg) + sizeof(struct in_addr);

	gen_ldp_hdr(buf, nbr->iface, size);

	size -= LDP_HDR_SIZE;

	gen_msg_tlv(buf, MSG_TYPE_ADDRWITHDRAW, size);

	size -= sizeof(struct ldp_msg);

	gen_address_list_tlv(buf, iface, size);

	evbuf_enqueue(&nbr->wbuf, buf);
}
示例#2
0
文件: init.c 项目: SylvestreG/bitrig
void
send_init(struct nbr *nbr)
{
	struct ibuf		*buf;
	u_int16_t		 size;

	log_debug("send_init: neighbor ID %s", inet_ntoa(nbr->id));

	if ((buf = ibuf_open(LDP_MAX_LEN)) == NULL)
		fatal("send_init");

	size = LDP_HDR_SIZE + sizeof(struct ldp_msg) + SESS_PRMS_SIZE;

	gen_ldp_hdr(buf, size);

	size -= LDP_HDR_SIZE;

	gen_msg_tlv(buf, MSG_TYPE_INIT, size);

	size -= sizeof(struct ldp_msg);

	gen_init_prms_tlv(buf, nbr, size);

	evbuf_enqueue(&nbr->tcp->wbuf, buf);
}
示例#3
0
void
send_notification_nbr(struct nbr *nbr, u_int32_t status, u_int32_t msgid,
    u_int32_t type)
{
	struct ibuf	*buf;

	if (nbr->iface->passive)
		return;

	buf = send_notification(status, nbr->iface, msgid, type);
	evbuf_enqueue(&nbr->wbuf, buf);
}
示例#4
0
void
send_notification_full(struct tcp_conn *tcp, struct notify_msg *nm)
{
	struct ibuf	*buf;
	uint16_t	 size;
	int		 err = 0;

	/* calculate size */
	size = LDP_HDR_SIZE + LDP_MSG_SIZE + STATUS_SIZE;
	if (nm->flags & F_NOTIF_PW_STATUS)
		size += PW_STATUS_TLV_SIZE;
	if (nm->flags & F_NOTIF_FEC) {
		size += TLV_HDR_SIZE;
		switch (nm->fec.type) {
		case MAP_TYPE_PWID:
			size += FEC_PWID_ELM_MIN_LEN;
			if (nm->fec.flags & F_MAP_PW_ID)
				size += sizeof(uint32_t);
			break;
		}
	}

	if ((buf = ibuf_open(size)) == NULL)
		fatal(__func__);

	err |= gen_ldp_hdr(buf, size);
	size -= LDP_HDR_SIZE;
	err |= gen_msg_hdr(buf, MSG_TYPE_NOTIFICATION, size);
	err |= gen_status_tlv(buf, nm->status_code, nm->msg_id, nm->msg_type);
	/* optional tlvs */
	if (nm->flags & F_NOTIF_PW_STATUS)
		err |= gen_pw_status_tlv(buf, nm->pw_status);
	if (nm->flags & F_NOTIF_FEC)
		err |= gen_fec_tlv(buf, &nm->fec);
	if (err) {
		ibuf_free(buf);
		return;
	}

	evbuf_enqueue(&tcp->wbuf, buf);
}
示例#5
0
void
send_keepalive(struct nbr *nbr)
{
	struct ibuf	*buf;
	u_int16_t	 size;

	if (nbr->iface->passive)
		return;

	if ((buf = ibuf_open(LDP_MAX_LEN)) == NULL)
		fatal("send_keepalive");

	size = LDP_HDR_SIZE + sizeof(struct ldp_msg);

	gen_ldp_hdr(buf, nbr->iface, size);

	size -= LDP_HDR_SIZE;

	gen_msg_tlv(buf, MSG_TYPE_KEEPALIVE, size);

	evbuf_enqueue(&nbr->wbuf, buf);
}
示例#6
0
void
send_address(struct nbr *nbr, struct iface *iface)
{
	struct ibuf	*buf;
	struct iface	*niface;
	u_int16_t	 size, iface_count = 0;

	if (nbr->iface->passive)
		return;

	log_debug("send_address: neighbor ID %s", inet_ntoa(nbr->id));

	if ((buf = ibuf_open(LDP_MAX_LEN)) == NULL)
		fatal("send_address");

	/* XXX: multiple address on the same iface? */
	if (iface == NULL)
		LIST_FOREACH(niface, &leconf->iface_list, entry)
			iface_count++;
	else
		iface_count = 1;

	size = LDP_HDR_SIZE + sizeof(struct ldp_msg) +
	    sizeof(struct address_list_tlv) +
	    iface_count * sizeof(struct in_addr);

	gen_ldp_hdr(buf, nbr->iface, size);

	size -= LDP_HDR_SIZE;

	gen_msg_tlv(buf, MSG_TYPE_ADDR, size);

	size -= sizeof(struct ldp_msg);

	gen_address_list_tlv(buf, iface, size);

	evbuf_enqueue(&nbr->wbuf, buf);
}