lldpd_clone_port(struct lldpd_port *destination, struct lldpd_port *source)
{

	u_int8_t *output = NULL;
	ssize_t output_len;
	struct lldpd_port *cloned = NULL;
	output_len = lldpd_port_serialize(source, (void**)&output);
	if (output_len == -1 ||
	    lldpd_port_unserialize(output, output_len, &cloned) <= 0) {
		log_warnx("alloc", "unable to clone default port");
		free(output);
		return -1;
	}
	memcpy(destination, cloned, sizeof(struct lldpd_port));
	free(cloned);
	free(output);
#ifdef ENABLE_DOT1
	marshal_repair_tailq(lldpd_vlan, &destination->p_vlans, v_entries);
	marshal_repair_tailq(lldpd_ppvid, &destination->p_ppvids, p_entries);
	marshal_repair_tailq(lldpd_pi, &destination->p_pids, p_entries);
#endif
#ifdef ENABLE_CUSTOM
	marshal_repair_tailq(lldpd_custom, &destination->p_custom_list, next);
#endif
	return 0;
}
lldpd_clone_port(struct lldpd_port *destination, struct lldpd_port *source)
{

	u_int8_t *output = NULL;
	ssize_t output_len;
	struct lldpd_port *cloned = NULL;
	output_len = lldpd_port_serialize(source, (void**)&output);
	if (output_len == -1 ||
	    lldpd_port_unserialize(output, output_len, &cloned) <= 0) {
		log_warnx("alloc", "unable to clone default port");
		free(output);
		return -1;
	}
	memcpy(destination, cloned, sizeof(struct lldpd_port));
	free(cloned);
	free(output);
#ifdef ENABLE_DOT1
	marshal_repair_tailq(lldpd_vlan, &destination->p_vlans, v_entries);
	marshal_repair_tailq(lldpd_ppvid, &destination->p_ppvids, p_entries);
	marshal_repair_tailq(lldpd_pi, &destination->p_pids, p_entries);
#endif
#ifdef ENABLE_CUSTOM
	marshal_repair_tailq(lldpd_custom, &destination->p_custom_list, next);
#endif
	return 0;
}