ldp.h revision 1.18
1/* $OpenBSD: ldp.h,v 1.18 2015/07/19 20:54:17 renato Exp $ */ 2 3/* 4 * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> 5 * Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org> 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20/* LDP protocol definitions */ 21 22#ifndef _LDP_H_ 23#define _LDP_H_ 24 25#include <netinet/in.h> 26 27/* misc */ 28#define LDP_VERSION 1 29#define LDP_PORT 646 30#define AllRouters "224.0.0.2" 31 32#define LDP_MAX_LEN 4096 33 34#define LINK_DFLT_HOLDTIME 15 35#define TARGETED_DFLT_HOLDTIME 45 36#define MIN_HOLDTIME 1 37#define MAX_HOLDTIME 0xffff 38#define INFINITE_HOLDTIME 0xffff 39 40#define DEFAULT_KEEPALIVE 180 41#define MIN_KEEPALIVE 1 42#define MAX_KEEPALIVE 0xffff 43#define KEEPALIVE_PER_PERIOD 3 44 45#define DEFAULT_HELLO_INTERVAL 5 46#define MIN_HELLO_INTERVAL 1 47#define MAX_HELLO_INTERVAL 0xffff 48 49#define INIT_DELAY_TMR 15 50#define MAX_DELAY_TMR 120 51 52/* LDP message types */ 53#define MSG_TYPE_NOTIFICATION 0x0001 54#define MSG_TYPE_HELLO 0x0100 55#define MSG_TYPE_INIT 0x0200 56#define MSG_TYPE_KEEPALIVE 0x0201 57#define MSG_TYPE_ADDR 0x0300 58#define MSG_TYPE_ADDRWITHDRAW 0x0301 59#define MSG_TYPE_LABELMAPPING 0x0400 60#define MSG_TYPE_LABELREQUEST 0x0401 61#define MSG_TYPE_LABELWITHDRAW 0x0402 62#define MSG_TYPE_LABELRELEASE 0x0403 63#define MSG_TYPE_LABELABORTREQ 0x0404 64 65/* LDP TLV types */ 66#define TLV_TYPE_FEC 0x0100 67#define TLV_TYPE_ADDRLIST 0x0101 68#define TLV_TYPE_HOPCOUNT 0x0103 69#define TLV_TYPE_PATHVECTOR 0x0104 70#define TLV_TYPE_GENERICLABEL 0x0200 71#define TLV_TYPE_ATMLABEL 0x0201 72#define TLV_TYPE_FRLABEL 0x0202 73#define TLV_TYPE_STATUS 0x0300 74#define TLV_TYPE_EXTSTATUS 0x0301 75#define TLV_TYPE_RETURNEDPDU 0x0302 76#define TLV_TYPE_RETURNEDMSG 0x0303 77#define TLV_TYPE_COMMONHELLO 0x0400 78#define TLV_TYPE_IPV4TRANSADDR 0x0401 79#define TLV_TYPE_CONFIG 0x0402 80#define TLV_TYPE_IPV6TRANSADDR 0x0403 81#define TLV_TYPE_COMMONSESSION 0x0500 82#define TLV_TYPE_ATMSESSIONPAR 0x0501 83#define TLV_TYPE_FRSESSION 0x0502 84#define TLV_TYPE_LABELREQUEST 0x0600 85 86/* LDP header */ 87struct ldp_hdr { 88 u_int16_t version; 89 u_int16_t length; 90 u_int32_t lsr_id; 91 u_int16_t lspace_id; 92} __packed; 93 94#define LDP_HDR_SIZE 10 95#define LDP_HDR_PDU_LEN 6 96 97/* TLV record */ 98struct tlv { 99 u_int16_t type; 100 u_int16_t length; 101}; 102#define TLV_HDR_LEN 4 103 104struct ldp_msg { 105 u_int16_t type; 106 u_int16_t length; 107 u_int32_t msgid; 108 /* Mandatory Parameters */ 109 /* Optional Parameters */ 110} __packed; 111 112#define LDP_MSG_LEN 8 113 114#define UNKNOWN_FLAG 0x8000 115#define FORWARD_FLAG 0xc000 116 117#define TARGETED_HELLO 0x8000 118#define REQUEST_TARG_HELLO 0x4000 119 120struct hello_prms_tlv { 121 u_int16_t type; 122 u_int16_t length; 123 u_int16_t holdtime; 124 u_int16_t flags; 125}; 126 127struct hello_prms_opt4_tlv { 128 u_int16_t type; 129 u_int16_t length; 130 u_int32_t value; 131}; 132 133#define HELLO_PRMS_SIZE 8 134 135#define S_SUCCESS 0x00000000 136#define S_BAD_LDP_ID 0x80000001 137#define S_BAD_PROTO_VER 0x80000002 138#define S_BAD_PDU_LEN 0x80000003 139#define S_UNKNOWN_MSG 0x00000004 140#define S_BAD_MSG_LEN 0x80000005 141#define S_UNKNOWN_TLV 0x00000006 142#define S_BAD_TLV_LEN 0x80000007 143#define S_BAD_TLV_VAL 0x80000008 144#define S_HOLDTIME_EXP 0x80000009 145#define S_SHUTDOWN 0x8000000A 146#define S_LOOP_DETECTED 0x0000000B 147#define S_UNKNOWN_FEC 0x0000000C 148#define S_NO_ROUTE 0x0000000D 149#define S_NO_LABEL_RES 0x0000000E 150#define S_AVAILABLE 0x0000000F 151#define S_NO_HELLO 0x80000010 152#define S_PARM_ADV_MODE 0x80000011 153#define S_MAX_PDU_LEN 0x80000012 154#define S_PARM_L_RANGE 0x80000013 155#define S_KEEPALIVE_TMR 0x80000014 156#define S_LAB_REQ_ABRT 0x00000015 157#define S_MISS_MSG 0x00000016 158#define S_UNSUP_ADDR 0x00000017 159#define S_KEEPALIVE_BAD 0x80000018 160#define S_INTERN_ERR 0x80000019 161 162struct sess_prms_tlv { 163 u_int16_t type; 164 u_int16_t length; 165 u_int16_t proto_version; 166 u_int16_t keepalive_time; 167 u_int8_t reserved; 168 u_int8_t pvlim; 169 u_int16_t max_pdu_len; 170 u_int32_t lsr_id; 171 u_int16_t lspace_id; 172} __packed; 173 174#define SESS_PRMS_SIZE 18 175 176struct status_tlv { 177 u_int16_t type; 178 u_int16_t length; 179 u_int32_t status_code; 180 u_int32_t msg_id; 181 u_int16_t msg_type; 182} __packed; 183 184#define STATUS_SIZE 14 185#define STATUS_TLV_LEN 10 186#define STATUS_FATAL 0x80000000 187 188struct address_list_tlv { 189 u_int16_t type; 190 u_int16_t length; 191 u_int16_t family; 192 /* address entries */ 193} __packed; 194 195#define ADDR_IPV4 0x1 196#define ADDR_IPV6 0x2 197 198#define FEC_ELM_WCARD_LEN 1 199#define FEC_ELM_PREFIX_MIN_LEN 4 200#define FEC_WILDCARD 0x01 201#define FEC_PREFIX 0x02 202#define FEC_IPV4 0x0001 203 204struct label_tlv { 205 u_int16_t type; 206 u_int16_t length; 207 u_int32_t label; 208}; 209 210#define LABEL_TLV_LEN 8 211 212struct reqid_tlv { 213 u_int16_t type; 214 u_int16_t length; 215 u_int32_t reqid; 216}; 217 218#define REQID_TLV_LEN 8 219 220#define NO_LABEL UINT_MAX 221 222#endif /* !_LDP_H_ */ 223