xref: /netbsd/usr.sbin/ldpd/mpls_routes.h (revision 6550d01e)
1 /* $NetBSD: mpls_routes.h,v 1.1 2010/12/08 07:20:15 kefren Exp $ */
2 
3 /*-
4  * Copyright (c) 2010 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Mihai Chelaru <kefren@NetBSD.org>
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef _MPLS_ROUTES_H_
33 #define _MPLS_ROUTES_H_
34 
35 #include <sys/types.h>
36 #include <sys/socket.h>
37 #include <net/if.h>
38 #include <net/route.h>
39 #include <netinet/in.h>
40 #include <netmpls/mpls.h>
41 
42 #include <arpa/inet.h>
43 
44 #define	NO_FREESO 0
45 #define	FREESO 1
46 
47 #define	RTM_READD -1
48 
49 union sockunion {
50 	struct sockaddr sa;
51 	struct sockaddr_in sin;
52 	struct sockaddr_mpls smpls;
53 	struct sockaddr_dl sdl;
54 };
55 
56 struct rt_msg {
57 	struct rt_msghdr m_rtm;
58 	char            m_space[512];
59 }               __packed;
60 
61 union sockunion *	make_inet_union(char *);
62 union sockunion *	make_mpls_union(uint32_t);
63 union sockunion	*	make_mplsinet_union(uint16_t peer, uint32_t label,
64 						struct in_addr *addr);
65 uint8_t	from_mask_to_cidr(char *);
66 void	from_cidr_to_mask(uint8_t, char *);
67 int	add_route(union sockunion *, union sockunion *, union sockunion *,
68 			union sockunion *, union sockunion *, int, int);
69 int	delete_route(union sockunion *, union sockunion *, int);
70 int	get_route(struct rt_msg *, union sockunion *, union sockunion *, int);
71 int	bind_current_routes(void);
72 int	flush_mpls_routes(void);
73 int	check_route(struct rt_msg *, uint);
74 char*	union_ntoa(union sockunion *);
75 uint8_t	from_union_to_cidr(union sockunion *);
76 union sockunion *	from_cidr_to_union(uint8_t);
77 
78 #endif	/* !_MPLS_ROUTES_H_ */
79