]>
git.proxmox.com Git - mirror_frr.git/blob - bgpd/rfapi/rfapi_descriptor_rfp_utils.c
3 * Copyright 2009-2016, LabN Consulting, L.L.C.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "lib/zebra.h"
22 #include "lib/prefix.h"
23 #include "lib/table.h"
25 #include "lib/memory.h"
28 #include "bgpd/bgpd.h"
30 #include "bgpd/rfapi/rfapi.h"
31 #include "bgpd/rfapi/rfapi_private.h"
32 #include "bgpd/rfapi/rfapi_descriptor_rfp_utils.h"
33 #include "bgpd/rfapi/vnc_debug.h"
36 void *rfapi_create_generic(struct rfapi_ip_addr
*vn
, struct rfapi_ip_addr
*un
)
38 struct rfapi_descriptor
*rfd
;
39 rfd
= XCALLOC(MTYPE_RFAPI_DESC
, sizeof(struct rfapi_descriptor
));
40 vnc_zlog_debug_verbose("%s: rfd=%p", __func__
, rfd
);
46 /*------------------------------------------
49 * Compare two generic rfapi descriptors.
52 * grfd: rfapi descriptor returned by rfapi_open or rfapi_create_generic
58 *------------------------------------------*/
59 void rfapi_free_generic(void *grfd
)
61 struct rfapi_descriptor
*rfd
;
62 rfd
= (struct rfapi_descriptor
*)grfd
;
63 XFREE(MTYPE_RFAPI_DESC
, rfd
);
67 /*------------------------------------------
70 * Compare two generic rfapi descriptors.
73 * rfd1: rfapi descriptor returned by rfapi_open or rfapi_create_generic
74 * rfd2: rfapi descriptor returned by rfapi_open or rfapi_create_generic
81 *------------------------------------------*/
82 int rfapi_compare_rfds(void *rfd1
, void *rfd2
)
84 struct rfapi_descriptor
*rrfd1
, *rrfd2
;
87 rrfd1
= (struct rfapi_descriptor
*)rfd1
;
88 rrfd2
= (struct rfapi_descriptor
*)rfd2
;
90 if (rrfd1
->vn_addr
.addr_family
== rrfd2
->vn_addr
.addr_family
) {
91 if (rrfd1
->vn_addr
.addr_family
== AF_INET
)
92 match
= IPV4_ADDR_SAME(&(rrfd1
->vn_addr
.addr
.v4
),
93 &(rrfd2
->vn_addr
.addr
.v4
));
95 match
= IPV6_ADDR_SAME(&(rrfd1
->vn_addr
.addr
.v6
),
96 &(rrfd2
->vn_addr
.addr
.v6
));
100 * If the VN addresses don't match in all forms,
107 * do the process again for the UN addresses.
110 if (rrfd1
->un_addr
.addr_family
== rrfd2
->un_addr
.addr_family
) {
111 /* VN addresses match
112 * UN address families match
113 * now check the actual UN addresses
115 if (rrfd1
->un_addr
.addr_family
== AF_INET
)
116 match
= IPV4_ADDR_SAME(&(rrfd1
->un_addr
.addr
.v4
),
117 &(rrfd2
->un_addr
.addr
.v4
));
119 match
= IPV6_ADDR_SAME(&(rrfd1
->un_addr
.addr
.v6
),
120 &(rrfd2
->un_addr
.addr
.v6
));