1/* $NetBSD: mpls_routes.h,v 1.6 2013/07/18 11:45:36 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
49union sockunion {
50	struct sockaddr sa;
51	struct sockaddr_in sin;
52	struct sockaddr_in6 sin6;
53	struct sockaddr_mpls smpls;
54	struct sockaddr_dl sdl;
55};
56
57struct rt_msg {
58	struct rt_msghdr m_rtm;
59	char            m_space[512];
60};
61
62union sockunion *	make_inet_union(const char *);
63union sockunion *	make_mpls_union(uint32_t);
64union sockunion	*	make_mplsinet_union(uint16_t peer, uint32_t label,
65						struct in_addr *addr);
66uint8_t	from_mask_to_cidr(const char *);
67void	from_cidr_to_mask(uint8_t, char *);
68int	add_route(union sockunion *, union sockunion *, union sockunion *,
69		union sockunion *, union sockunion *, int, int);
70int	delete_route(union sockunion *, union sockunion *, int);
71#if 0
72int	get_route(struct rt_msg *, const union sockunion *,
73		const union sockunion *, int);
74#endif
75int	bind_current_routes(void);
76int	flush_mpls_routes(void);
77int	check_route(struct rt_msg *, uint);
78uint8_t	from_union_to_cidr(const union sockunion *);
79union sockunion *	from_cidr_to_union(uint8_t);
80
81#endif	/* !_MPLS_ROUTES_H_ */
82