static char buf[EIGRP_IF_STRING_MAXLEN] = "";
u_int32_t ifaddr;
- ifaddr = ntohl(tn->destination_ipv4->prefix.s_addr);
+ ifaddr = ntohl(tn->destination->u.prefix4.s_addr);
snprintf(buf, EIGRP_IF_STRING_MAXLEN, "%u.%u.%u.%u",
(ifaddr >> 24) & 0xff, (ifaddr >> 16) & 0xff,
(ifaddr >> 8) & 0xff, ifaddr & 0xff);
void show_ip_eigrp_prefix_entry(struct vty *vty, struct eigrp_prefix_entry *tn)
{
struct list *successors = eigrp_topology_get_successor(tn);
+ char buffer[PREFIX_STRLEN];
vty_out(vty, "%-3c", (tn->state > 0) ? 'A' : 'P');
- vty_out(vty, "%s/%u, ", inet_ntoa(tn->destination_ipv4->prefix),
- tn->destination_ipv4->prefixlen);
+ vty_out(vty, "%s, ",
+ prefix2str(tn->destination, buffer, PREFIX_STRLEN));
vty_out(vty, "%u successors, ", successors->count);
vty_out(vty, "FD is %u, serno: %" PRIu64 " \n", tn->fdistance,
tn->serno);
ne->adv_router = eigrp->neighbor_self;
ne->flags = EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG;
- struct prefix_ipv4 dest_addr;
+ struct prefix dest_addr;
dest_addr.family = AF_INET;
- dest_addr.prefix = ei->connected->address->u.prefix4;
+ dest_addr.u.prefix4 = ei->connected->address->u.prefix4;
dest_addr.prefixlen = ei->connected->address->prefixlen;
- apply_mask_ipv4(&dest_addr);
+ apply_mask(&dest_addr);
pe = eigrp_topology_table_lookup_ipv4(eigrp->topology_table,
- &dest_addr);
+ (struct prefix_ipv4 *)&dest_addr);
if (pe == NULL) {
pe = eigrp_prefix_entry_new();
pe->serno = eigrp->serno;
- pe->destination_ipv4 = prefix_ipv4_new();
- prefix_copy((struct prefix *)pe->destination_ipv4,
- (struct prefix *)&dest_addr);
+ pe->destination = (struct prefix *)prefix_ipv4_new();
+ prefix_copy(pe->destination, &dest_addr);
pe->af = AF_INET;
pe->nt = EIGRP_TOPOLOGY_TYPE_CONNECTED;
u_int16_t length;
stream_putw(s, EIGRP_TLV_IPv4_INT);
- if (pe->destination_ipv4->prefixlen <= 8) {
+ if (pe->destination->prefixlen <= 8) {
stream_putw(s, 0x001A);
length = 0x001A;
}
- if ((pe->destination_ipv4->prefixlen > 8)
- && (pe->destination_ipv4->prefixlen <= 16)) {
+ if ((pe->destination->prefixlen > 8)
+ && (pe->destination->prefixlen <= 16)) {
stream_putw(s, 0x001B);
length = 0x001B;
}
- if ((pe->destination_ipv4->prefixlen > 16)
- && (pe->destination_ipv4->prefixlen <= 24)) {
+ if ((pe->destination->prefixlen > 16)
+ && (pe->destination->prefixlen <= 24)) {
stream_putw(s, 0x001C);
length = 0x001C;
}
- if (pe->destination_ipv4->prefixlen > 24) {
+ if (pe->destination->prefixlen > 24) {
stream_putw(s, 0x001D);
length = 0x001D;
}
stream_putc(s, pe->reported_metric.tag);
stream_putc(s, pe->reported_metric.flags);
- stream_putc(s, pe->destination_ipv4->prefixlen);
+ stream_putc(s, pe->destination->prefixlen);
- if (pe->destination_ipv4->prefixlen <= 8) {
- stream_putc(s, pe->destination_ipv4->prefix.s_addr & 0xFF);
- }
- if ((pe->destination_ipv4->prefixlen > 8)
- && (pe->destination_ipv4->prefixlen <= 16)) {
- stream_putc(s, pe->destination_ipv4->prefix.s_addr & 0xFF);
- stream_putc(s,
- (pe->destination_ipv4->prefix.s_addr >> 8) & 0xFF);
- }
- if ((pe->destination_ipv4->prefixlen > 16)
- && (pe->destination_ipv4->prefixlen <= 24)) {
- stream_putc(s, pe->destination_ipv4->prefix.s_addr & 0xFF);
+ stream_putc(s, pe->destination->u.prefix4.s_addr & 0xFF);
+ if (pe->destination->prefixlen > 8)
stream_putc(s,
- (pe->destination_ipv4->prefix.s_addr >> 8) & 0xFF);
+ (pe->destination->u.prefix4.s_addr >> 8) & 0xFF);
+ if (pe->destination->prefixlen > 16)
stream_putc(s,
- (pe->destination_ipv4->prefix.s_addr >> 16) & 0xFF);
- }
- if (pe->destination_ipv4->prefixlen > 24) {
- stream_putc(s, pe->destination_ipv4->prefix.s_addr & 0xFF);
+ (pe->destination->u.prefix4.s_addr >> 16) & 0xFF);
+ if (pe->destination->prefixlen > 24)
stream_putc(s,
- (pe->destination_ipv4->prefix.s_addr >> 8) & 0xFF);
- stream_putc(s,
- (pe->destination_ipv4->prefix.s_addr >> 16) & 0xFF);
- stream_putc(s,
- (pe->destination_ipv4->prefix.s_addr >> 24) & 0xFF);
- }
+ (pe->destination->u.prefix4.s_addr >> 24) & 0xFF);
return length;
}
/* Check if any list fits */
if ((alist
- && access_list_apply(alist, (struct prefix *)pe2->destination_ipv4)
+ && access_list_apply(alist, pe2->destination)
== FILTER_DENY)
|| (plist
&& prefix_list_apply(plist,
- (struct prefix *)pe2->destination_ipv4)
+ pe2->destination)
== PREFIX_DENY)
|| (alist_i
&& access_list_apply(alist_i,
- (struct prefix *)pe2->destination_ipv4)
+ pe2->destination)
== FILTER_DENY)
|| (plist_i
&& prefix_list_apply(plist_i,
- (struct prefix *)pe2->destination_ipv4)
+ pe2->destination)
== PREFIX_DENY)) {
zlog_info("REPLY SEND: Setting Metric to max");
pe2->reported_metric.delay = EIGRP_MAX_METRIC;
u_char af; // address family
u_char req_action; // required action
- struct prefix_ipv4
- *destination_ipv4; // pointer to struct with ipv4 address
- struct prefix_ipv6
- *destination_ipv6; // pointer to struct with ipv6 address
+ struct prefix *destination;
// If network type is REMOTE_EXTERNAL, pointer will have reference to
// its external TLV
{
if (node1->af == AF_INET) {
if (node2->af == AF_INET) {
- if (node1->destination_ipv4->prefix.s_addr
- < node2->destination_ipv4->prefix.s_addr) {
- return -1; // if it belong above node2
- } else {
- if (node1->destination_ipv4->prefix.s_addr
- > node2->destination_ipv4->prefix.s_addr) {
- return 1; // if it belongs under node2
- } else {
- return 0; // same value... ERROR...in
- // case of adding same prefix
- // again
- }
- }
- } else {
+ if (node1->destination->u.prefix4.s_addr
+ < node2->destination->u.prefix4.s_addr)
+ return -1;
+ if (node1->destination->u.prefix4.s_addr
+ > node2->destination->u.prefix4.s_addr)
+ return 1;
+ else
+ return 0;
+ } else
return 1;
- }
- } else { // TODO check if the prefix dont exists
- return 1; // add to end
- }
+ } else
+ return 1;
}
/*
new->rij = list_new();
new->entries->cmp = (int (*)(void *, void *))eigrp_neighbor_entry_cmp;
new->distance = new->fdistance = new->rdistance = EIGRP_MAX_METRIC;
- new->destination_ipv4 = NULL;
- new->destination_ipv6 = NULL;
+ new->destination = NULL;
return new;
}
static int eigrp_neighbor_entry_cmp(struct eigrp_neighbor_entry *entry1,
struct eigrp_neighbor_entry *entry2)
{
- if (entry1->distance
- < entry2->distance) // parameter used in list_add_sort ()
- return -1; // actually set to sort by distance
+ if (entry1->distance < entry2->distance)
+ return -1;
if (entry1->distance > entry2->distance)
return 1;
listnode_add_sort(node->entries, entry);
entry->prefix = node;
- eigrp_zebra_route_add(node->destination_ipv4, l);
+ eigrp_zebra_route_add((struct prefix_ipv4 *)
+ node->destination, l);
}
list_delete(l);
list_free(node->entries);
list_free(node->rij);
listnode_delete(topology, node);
- eigrp_zebra_route_delete(node->destination_ipv4);
+ eigrp_zebra_route_delete((struct prefix_ipv4 *)
+ node->destination);
XFREE(MTYPE_EIGRP_PREFIX_ENTRY, node);
}
}
{
if (listnode_lookup(node->entries, entry) != NULL) {
listnode_delete(node->entries, entry);
- eigrp_zebra_route_delete(node->destination_ipv4);
+ eigrp_zebra_route_delete((struct prefix_ipv4 *)
+ node->destination);
XFREE(MTYPE_EIGRP_NEIGHBOR_ENTRY, entry);
}
}
struct eigrp_prefix_entry *data;
struct listnode *node;
for (ALL_LIST_ELEMENTS_RO(topology_table, node, data)) {
- if ((data->af == AF_INET)
- && (data->destination_ipv4->prefix.s_addr
- == address->prefix.s_addr)
- && (data->destination_ipv4->prefixlen
- == address->prefixlen))
+ if (prefix_same(data->destination,
+ (struct prefix *)address))
return data;
}
struct eigrp_neighbor_entry *entry;
if (successors) {
- eigrp_zebra_route_add(prefix->destination_ipv4, successors);
+ eigrp_zebra_route_add((struct prefix_ipv4 *)
+ prefix->destination,
+ successors);
for (ALL_LIST_ELEMENTS_RO(successors, node, entry))
entry->flags |= EIGRP_NEIGHBOR_ENTRY_INTABLE_FLAG;
list_delete(successors);
} else {
- eigrp_zebra_route_delete(prefix->destination_ipv4);
+ eigrp_zebra_route_delete((struct prefix_ipv4 *)
+ prefix->destination);
for (ALL_LIST_ELEMENTS_RO(prefix->entries, node, entry))
entry->flags &= ~EIGRP_NEIGHBOR_ENTRY_INTABLE_FLAG;
}
/* iterate over all prefixes which weren't advertised by neighbor */
for (ALL_LIST_ELEMENTS_RO(nbr_prefixes, node1, prefix)) {
- zlog_debug("GR receive: Neighbor not advertised %s/%d",
- inet_ntoa(prefix->destination_ipv4->prefix),
- prefix->destination_ipv4->prefixlen);
+ char buffer[PREFIX_STRLEN];
+ zlog_debug("GR receive: Neighbor not advertised %s",
+ prefix2str(prefix->destination,
+ buffer, PREFIX_STRLEN));
fsm_msg.metrics = prefix->reported_metric;
/* set delay to MAX */
/*Here comes topology information save*/
pe = eigrp_prefix_entry_new();
pe->serno = eigrp->serno;
- pe->destination_ipv4 = prefix_ipv4_new();
- prefix_copy(
- (struct prefix *)pe->destination_ipv4,
+ pe->destination = (struct prefix *)prefix_ipv4_new();
+ prefix_copy(pe->destination,
(struct prefix *)&dest_addr);
pe->af = AF_INET;
pe->state = EIGRP_FSM_STATE_PASSIVE;
struct access_list *alist_i;
struct prefix_list *plist_i;
struct eigrp *e;
- struct prefix_ipv4 *dest_addr;
+ struct prefix *dest_addr;
u_int32_t seq_no = nbr->ei->eigrp->sequence_number;
ep = eigrp_packet_new(nbr->ei->ifp->mtu, nbr);
}
}
/* Get destination address from prefix */
- dest_addr = pe->destination_ipv4;
+ dest_addr = pe->destination;
/*
* Filtering
struct access_list *alist_i;
struct prefix_list *plist_i;
struct eigrp *e;
- struct prefix_ipv4 *dest_addr;
+ struct prefix *dest_addr;
u_int32_t seq_no = ei->eigrp->sequence_number;
if (ei->nbrs->count == 0)
has_tlv = 0;
}
/* Get destination address from prefix */
- dest_addr = pe->destination_ipv4;
+ dest_addr = pe->destination;
/*
* Filtering
u_int16_t length = EIGRP_HEADER_LEN;
struct listnode *node, *nnode;
struct eigrp_prefix_entry *pe;
- struct prefix_ipv4 *dest_addr;
+ struct prefix *dest_addr;
struct eigrp *e;
struct access_list *alist, *alist_i;
struct prefix_list *plist, *plist_i;
/*
* Filtering
*/
- dest_addr = pe->destination_ipv4;
+ dest_addr = pe->destination;
/* get list from eigrp process */
e = eigrp_lookup();
/* Get access-lists and prefix-lists from process and interface
/* Check if any list fits */
if ((alist
- && access_list_apply(alist, (struct prefix *)dest_addr)
+ && access_list_apply(alist, dest_addr)
== FILTER_DENY)
|| (plist
- && prefix_list_apply(plist, (struct prefix *)dest_addr)
+ && prefix_list_apply(plist, dest_addr)
== PREFIX_DENY)
|| (alist_i
- && access_list_apply(alist_i,
- (struct prefix *)dest_addr)
+ && access_list_apply(alist_i, dest_addr)
== FILTER_DENY)
|| (plist_i
- && prefix_list_apply(plist_i,
- (struct prefix *)dest_addr)
+ && prefix_list_apply(plist_i, dest_addr)
== PREFIX_DENY)) {
/* do not send filtered route */
zlog_info("Filtered prefix %s won't be sent out.",
- inet_ntoa(dest_addr->prefix));
+ inet_ntoa(dest_addr->u.prefix4));
} else {
/* sending route which wasn't filtered */
length += eigrp_add_internalTLV_to_stream(ep->s, pe);
/* Check if any list fits */
if ((alist
- && access_list_apply(alist, (struct prefix *)dest_addr)
+ && access_list_apply(alist, dest_addr)
== FILTER_DENY)
|| (plist
- && prefix_list_apply(plist, (struct prefix *)dest_addr)
+ && prefix_list_apply(plist, dest_addr)
== PREFIX_DENY)
|| (alist_i
- && access_list_apply(alist_i,
- (struct prefix *)dest_addr)
+ && access_list_apply(alist_i, dest_addr)
== FILTER_DENY)
|| (plist_i
- && prefix_list_apply(plist_i,
- (struct prefix *)dest_addr)
+ && prefix_list_apply(plist_i, dest_addr)
== PREFIX_DENY)) {
/* do not send filtered route */
zlog_info("Filtered prefix %s will be removed.",
- inet_ntoa(dest_addr->prefix));
+ inet_ntoa(dest_addr->u.prefix4));
/* prepare message for FSM */
struct eigrp_fsm_action_message fsm_msg;