2013-07-20 09:16:08 +04:00
|
|
|
/* $NetBSD: ldp_peer.h,v 1.7 2013/07/20 05:16:08 kefren Exp $ */
|
2010-12-08 10:20:14 +03:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 2010 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Mihai Chelaru <kefren@NetBSD.org>
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LDP_PEER_H_
|
|
|
|
#define _LDP_PEER_H_
|
|
|
|
|
|
|
|
#include "sys/types.h"
|
|
|
|
#include "sys/queue.h"
|
|
|
|
#include "netinet/in.h"
|
|
|
|
|
2013-01-26 21:29:55 +04:00
|
|
|
#include "mpls_routes.h"
|
2010-12-08 10:20:14 +03:00
|
|
|
#include "tlv.h"
|
|
|
|
|
|
|
|
struct ldp_peer_address {
|
2013-01-26 21:29:55 +04:00
|
|
|
union sockunion address;
|
2010-12-08 10:20:14 +03:00
|
|
|
SLIST_ENTRY(ldp_peer_address) addresses;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct label_mapping {
|
2013-01-26 21:29:55 +04:00
|
|
|
union sockunion address;
|
|
|
|
uint prefix;
|
|
|
|
uint label;
|
2010-12-08 10:20:14 +03:00
|
|
|
SLIST_ENTRY(label_mapping) mappings;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ldp_peer {
|
|
|
|
/*
|
|
|
|
* I add routes to address.
|
|
|
|
* I maintain LDP TCP connection on transport_address.
|
|
|
|
* I use ldp_id as peer identificator.
|
|
|
|
*/
|
2013-01-26 21:29:55 +04:00
|
|
|
struct sockaddr *address, *transport_address;
|
|
|
|
/* According to draft-ietf-mpls-ldp-ipv6-07 ID is IPv4 only for now */
|
|
|
|
struct in_addr ldp_id;
|
2010-12-08 10:20:14 +03:00
|
|
|
/* TCP socket */
|
|
|
|
int socket;
|
2013-01-26 21:29:55 +04:00
|
|
|
/* Rest of the peer parameters */
|
2010-12-08 10:20:14 +03:00
|
|
|
uint16_t holdtime, timeout;
|
|
|
|
int master; /* 0 if we're passive */
|
|
|
|
int state; /* see below for possible states */
|
2013-01-26 21:29:55 +04:00
|
|
|
time_t established_t; /* time when it did connect */
|
2010-12-08 10:20:14 +03:00
|
|
|
/* Here I maintain all the addresses announced by a peer */
|
|
|
|
SLIST_HEAD(,ldp_peer_address) ldp_peer_address_head;
|
|
|
|
SLIST_HEAD(,label_mapping) label_mapping_head;
|
|
|
|
|
|
|
|
SLIST_ENTRY(ldp_peer) peers;
|
|
|
|
};
|
|
|
|
SLIST_HEAD(,ldp_peer) ldp_peer_head;
|
|
|
|
|
|
|
|
struct peer_map {
|
|
|
|
struct ldp_peer *peer;
|
|
|
|
struct label_mapping *lm;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* LDP Peers States */
|
|
|
|
#define LDP_PEER_CONNECTING 0
|
|
|
|
#define LDP_PEER_CONNECTED 1
|
|
|
|
#define LDP_PEER_ESTABLISHED 2
|
|
|
|
#define LDP_PEER_HOLDDOWN 3
|
|
|
|
|
2013-02-04 21:14:31 +04:00
|
|
|
int sockaddr_cmp(const struct sockaddr *, const struct sockaddr *);
|
2010-12-08 10:20:14 +03:00
|
|
|
void ldp_peer_init(void);
|
2013-07-11 09:45:23 +04:00
|
|
|
struct ldp_peer * ldp_peer_new(const struct in_addr *, const struct sockaddr *,
|
|
|
|
const struct sockaddr *, uint16_t, int);
|
2010-12-08 10:20:14 +03:00
|
|
|
void ldp_peer_holddown(struct ldp_peer *);
|
|
|
|
void ldp_peer_delete(struct ldp_peer *);
|
2013-01-26 21:29:55 +04:00
|
|
|
struct ldp_peer * get_ldp_peer(const struct sockaddr *);
|
|
|
|
struct ldp_peer * get_ldp_peer_by_id(const struct in_addr *);
|
|
|
|
struct ldp_peer * get_ldp_peer_by_socket(int);
|
2013-07-11 09:45:23 +04:00
|
|
|
int add_ifaddresses(struct ldp_peer *, const struct al_tlv *);
|
|
|
|
int add_ifaddr(struct ldp_peer *, const struct sockaddr *);
|
|
|
|
int del_ifaddr(struct ldp_peer *, const struct sockaddr *);
|
|
|
|
struct ldp_peer_address * check_ifaddr(const struct ldp_peer *,
|
2013-01-26 21:29:55 +04:00
|
|
|
const struct sockaddr *);
|
2013-07-11 09:45:23 +04:00
|
|
|
void print_bounded_addresses(const struct ldp_peer *);
|
2013-01-26 21:29:55 +04:00
|
|
|
void del_all_ifaddr(struct ldp_peer *);
|
2013-07-11 09:45:23 +04:00
|
|
|
int del_ifaddresses(struct ldp_peer *, const struct al_tlv *);
|
2013-01-26 21:29:55 +04:00
|
|
|
|
2013-07-11 09:45:23 +04:00
|
|
|
int ldp_peer_add_mapping(struct ldp_peer *, const struct sockaddr *, int, int);
|
|
|
|
int ldp_peer_delete_mapping(struct ldp_peer *, const struct sockaddr *, int);
|
|
|
|
struct label_mapping * ldp_peer_get_lm(const struct ldp_peer *,
|
|
|
|
const struct sockaddr *, uint);
|
2013-07-20 09:16:08 +04:00
|
|
|
void ldp_peer_delete_all_mappings(struct ldp_peer *);
|
2013-01-26 21:29:55 +04:00
|
|
|
void ldp_peer_holddown_all(void);
|
|
|
|
|
2013-07-11 09:45:23 +04:00
|
|
|
struct peer_map * ldp_test_mapping(const struct sockaddr *, int,
|
|
|
|
const struct sockaddr *);
|
2010-12-08 10:20:14 +03:00
|
|
|
|
2013-07-11 09:45:23 +04:00
|
|
|
const char * ldp_state_to_name(int);
|
2010-12-08 10:20:14 +03:00
|
|
|
|
|
|
|
#endif /* !_LDP_PEER_H_ */
|