1*38e65088Srenato /* $OpenBSD: ldp.h,v 1.42 2017/03/04 00:21:48 renato Exp $ */ 2ab0c2486Smichele 3ab0c2486Smichele /* 45dc9330aSrenato * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> 5ab0c2486Smichele * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> 6ab0c2486Smichele * Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org> 7ab0c2486Smichele * 8ab0c2486Smichele * Permission to use, copy, modify, and distribute this software for any 9ab0c2486Smichele * purpose with or without fee is hereby granted, provided that the above 10ab0c2486Smichele * copyright notice and this permission notice appear in all copies. 11ab0c2486Smichele * 12ab0c2486Smichele * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13ab0c2486Smichele * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14ab0c2486Smichele * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15ab0c2486Smichele * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16ab0c2486Smichele * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17ab0c2486Smichele * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18ab0c2486Smichele * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19ab0c2486Smichele */ 20ab0c2486Smichele 21ab0c2486Smichele /* LDP protocol definitions */ 22ab0c2486Smichele 23ab0c2486Smichele #ifndef _LDP_H_ 24ab0c2486Smichele #define _LDP_H_ 25ab0c2486Smichele 265411bbb6Srenato #include <sys/types.h> 27ab0c2486Smichele 28ab0c2486Smichele /* misc */ 29ab0c2486Smichele #define LDP_VERSION 1 30ab0c2486Smichele #define LDP_PORT 646 31ab0c2486Smichele #define LDP_MAX_LEN 4096 32ab0c2486Smichele 33a8c39dc0Srenato /* All Routers on this Subnet group multicast addresses */ 34a8c39dc0Srenato #define AllRouters_v4 "224.0.0.2" 35a8c39dc0Srenato #define AllRouters_v6 "ff02::2" 36a8c39dc0Srenato 37ab0c2486Smichele #define LINK_DFLT_HOLDTIME 15 38ab0c2486Smichele #define TARGETED_DFLT_HOLDTIME 45 3969eaa65aSrenato #define MIN_HOLDTIME 3 40ab0c2486Smichele #define MAX_HOLDTIME 0xffff 4144df7203Sclaudio #define INFINITE_HOLDTIME 0xffff 42ab0c2486Smichele 43ab0c2486Smichele #define DEFAULT_KEEPALIVE 180 4469eaa65aSrenato #define MIN_KEEPALIVE 3 45ab0c2486Smichele #define MAX_KEEPALIVE 0xffff 46ab0c2486Smichele #define KEEPALIVE_PER_PERIOD 3 4780237bd1Srenato #define INIT_FSM_TIMEOUT 15 48ab0c2486Smichele 49ab0c2486Smichele #define DEFAULT_HELLO_INTERVAL 5 50ab0c2486Smichele #define MIN_HELLO_INTERVAL 1 5183dcf737Sclaudio #define MAX_HELLO_INTERVAL 0xffff 52ab0c2486Smichele 53ab0c2486Smichele #define INIT_DELAY_TMR 15 543e1c7e0bSclaudio #define MAX_DELAY_TMR 120 55ab0c2486Smichele 566399cec1Srenato #define MIN_PWID_ID 1 576399cec1Srenato #define MAX_PWID_ID 0xffffffff 586399cec1Srenato 596399cec1Srenato #define DEFAULT_L2VPN_MTU 1500 606399cec1Srenato #define MIN_L2VPN_MTU 512 616399cec1Srenato #define MAX_L2VPN_MTU 0xffff 626399cec1Srenato 63ab0c2486Smichele /* LDP message types */ 64ab0c2486Smichele #define MSG_TYPE_NOTIFICATION 0x0001 65ab0c2486Smichele #define MSG_TYPE_HELLO 0x0100 66ab0c2486Smichele #define MSG_TYPE_INIT 0x0200 67ab0c2486Smichele #define MSG_TYPE_KEEPALIVE 0x0201 683b4c1866Srenato #define MSG_TYPE_CAPABILITY 0x0202 /* RFC 5561 */ 69ab0c2486Smichele #define MSG_TYPE_ADDR 0x0300 70ab0c2486Smichele #define MSG_TYPE_ADDRWITHDRAW 0x0301 71ab0c2486Smichele #define MSG_TYPE_LABELMAPPING 0x0400 72ab0c2486Smichele #define MSG_TYPE_LABELREQUEST 0x0401 73ab0c2486Smichele #define MSG_TYPE_LABELWITHDRAW 0x0402 74ab0c2486Smichele #define MSG_TYPE_LABELRELEASE 0x0403 75ab0c2486Smichele #define MSG_TYPE_LABELABORTREQ 0x0404 76ab0c2486Smichele 77ab0c2486Smichele /* LDP TLV types */ 78ab0c2486Smichele #define TLV_TYPE_FEC 0x0100 79ab0c2486Smichele #define TLV_TYPE_ADDRLIST 0x0101 80ab0c2486Smichele #define TLV_TYPE_HOPCOUNT 0x0103 81ab0c2486Smichele #define TLV_TYPE_PATHVECTOR 0x0104 82ab0c2486Smichele #define TLV_TYPE_GENERICLABEL 0x0200 83ab0c2486Smichele #define TLV_TYPE_ATMLABEL 0x0201 84ab0c2486Smichele #define TLV_TYPE_FRLABEL 0x0202 85ab0c2486Smichele #define TLV_TYPE_STATUS 0x0300 86ab0c2486Smichele #define TLV_TYPE_EXTSTATUS 0x0301 87ab0c2486Smichele #define TLV_TYPE_RETURNEDPDU 0x0302 88ab0c2486Smichele #define TLV_TYPE_RETURNEDMSG 0x0303 89ab0c2486Smichele #define TLV_TYPE_COMMONHELLO 0x0400 90ab0c2486Smichele #define TLV_TYPE_IPV4TRANSADDR 0x0401 91ab0c2486Smichele #define TLV_TYPE_CONFIG 0x0402 92ab0c2486Smichele #define TLV_TYPE_IPV6TRANSADDR 0x0403 93ab0c2486Smichele #define TLV_TYPE_COMMONSESSION 0x0500 94ab0c2486Smichele #define TLV_TYPE_ATMSESSIONPAR 0x0501 95ab0c2486Smichele #define TLV_TYPE_FRSESSION 0x0502 96ab0c2486Smichele #define TLV_TYPE_LABELREQUEST 0x0600 976399cec1Srenato /* RFC 4447 */ 98*38e65088Srenato #define TLV_TYPE_MAC_LIST 0x8404 99bd4a767aSrenato #define TLV_TYPE_PW_STATUS 0x896A 1006399cec1Srenato #define TLV_TYPE_PW_IF_PARAM 0x096B 1016399cec1Srenato #define TLV_TYPE_PW_GROUP_ID 0x096C 1023b4c1866Srenato /* RFC 5561 */ 1033b4c1866Srenato #define TLV_TYPE_RETURNED_TLVS 0x8304 1043b4c1866Srenato #define TLV_TYPE_DYNAMIC_CAP 0x8506 105c7c5a728Srenato /* RFC 5918 */ 106c7c5a728Srenato #define TLV_TYPE_TWCARD_CAP 0x850B 1079246985aSrenato /* RFC 5919 */ 1089246985aSrenato #define TLV_TYPE_UNOTIF_CAP 0x8603 109a8c39dc0Srenato /* RFC 7552 */ 110a8c39dc0Srenato #define TLV_TYPE_DUALSTACK 0x8701 111ab0c2486Smichele 112ab0c2486Smichele /* LDP header */ 113ab0c2486Smichele struct ldp_hdr { 1143de94509Srenato uint16_t version; 1153de94509Srenato uint16_t length; 1163de94509Srenato uint32_t lsr_id; 1173de94509Srenato uint16_t lspace_id; 11865125de0Sclaudio } __packed; 119ab0c2486Smichele 1209277622bSrenato #define LDP_HDR_SIZE 10 /* actual size of the LDP header */ 1219277622bSrenato #define LDP_HDR_PDU_LEN 6 /* minimum "PDU Length" */ 1229277622bSrenato #define LDP_HDR_DEAD_LEN 4 123ab0c2486Smichele 124ab0c2486Smichele /* TLV record */ 12528970269Sclaudio struct tlv { 1263de94509Srenato uint16_t type; 1273de94509Srenato uint16_t length; 12828970269Sclaudio }; 12960e1e0e7Srenato #define TLV_HDR_SIZE 4 13028970269Sclaudio 131ab0c2486Smichele struct ldp_msg { 1323de94509Srenato uint16_t type; 1333de94509Srenato uint16_t length; 13460e1e0e7Srenato uint32_t id; 135ab0c2486Smichele /* Mandatory Parameters */ 136ab0c2486Smichele /* Optional Parameters */ 13789f23408Sclaudio } __packed; 138ab0c2486Smichele 1399277622bSrenato #define LDP_MSG_SIZE 8 /* minimum size of LDP message */ 1409277622bSrenato #define LDP_MSG_LEN 4 /* minimum "Message Length" */ 1419277622bSrenato #define LDP_MSG_DEAD_LEN 4 142ab0c2486Smichele 143ab0c2486Smichele #define UNKNOWN_FLAG 0x8000 144ab0c2486Smichele #define FORWARD_FLAG 0xc000 145ab0c2486Smichele 146ab0c2486Smichele struct hello_prms_tlv { 1473de94509Srenato uint16_t type; 1483de94509Srenato uint16_t length; 1493de94509Srenato uint16_t holdtime; 1503de94509Srenato uint16_t flags; 151ab0c2486Smichele }; 152d7525efdSrenato #define F_HELLO_TARGETED 0x8000 153d7525efdSrenato #define F_HELLO_REQ_TARG 0x4000 154d7525efdSrenato #define F_HELLO_GTSM 0x2000 15533f6ccfeSrenato 156f9479091Sclaudio struct hello_prms_opt4_tlv { 1573de94509Srenato uint16_t type; 1583de94509Srenato uint16_t length; 1593de94509Srenato uint32_t value; 160f9479091Sclaudio }; 161f9479091Sclaudio 162a8c39dc0Srenato struct hello_prms_opt16_tlv { 163a8c39dc0Srenato uint16_t type; 164a8c39dc0Srenato uint16_t length; 165a8c39dc0Srenato uint8_t value[16]; 166a8c39dc0Srenato }; 167a8c39dc0Srenato 168a8c39dc0Srenato #define DUAL_STACK_LDPOV4 4 169a8c39dc0Srenato #define DUAL_STACK_LDPOV6 6 170a8c39dc0Srenato 171a8c39dc0Srenato #define F_HELLO_TLV_RCVD_ADDR 0x01 172a8c39dc0Srenato #define F_HELLO_TLV_RCVD_CONF 0x02 173a8c39dc0Srenato #define F_HELLO_TLV_RCVD_DS 0x04 17489f23408Sclaudio 175ab0c2486Smichele #define S_SUCCESS 0x00000000 176ab0c2486Smichele #define S_BAD_LDP_ID 0x80000001 177ab0c2486Smichele #define S_BAD_PROTO_VER 0x80000002 178ab0c2486Smichele #define S_BAD_PDU_LEN 0x80000003 179ab0c2486Smichele #define S_UNKNOWN_MSG 0x00000004 180ab0c2486Smichele #define S_BAD_MSG_LEN 0x80000005 181ab0c2486Smichele #define S_UNKNOWN_TLV 0x00000006 182ab0c2486Smichele #define S_BAD_TLV_LEN 0x80000007 183ab0c2486Smichele #define S_BAD_TLV_VAL 0x80000008 184ab0c2486Smichele #define S_HOLDTIME_EXP 0x80000009 185ab0c2486Smichele #define S_SHUTDOWN 0x8000000A 186ab0c2486Smichele #define S_LOOP_DETECTED 0x0000000B 187ab0c2486Smichele #define S_UNKNOWN_FEC 0x0000000C 188ab0c2486Smichele #define S_NO_ROUTE 0x0000000D 189ab0c2486Smichele #define S_NO_LABEL_RES 0x0000000E 190ab0c2486Smichele #define S_AVAILABLE 0x0000000F 191ab0c2486Smichele #define S_NO_HELLO 0x80000010 192ab0c2486Smichele #define S_PARM_ADV_MODE 0x80000011 193ab0c2486Smichele #define S_MAX_PDU_LEN 0x80000012 194ab0c2486Smichele #define S_PARM_L_RANGE 0x80000013 195ab0c2486Smichele #define S_KEEPALIVE_TMR 0x80000014 196ab0c2486Smichele #define S_LAB_REQ_ABRT 0x00000015 197ab0c2486Smichele #define S_MISS_MSG 0x00000016 198ab0c2486Smichele #define S_UNSUP_ADDR 0x00000017 19965125de0Sclaudio #define S_KEEPALIVE_BAD 0x80000018 20065125de0Sclaudio #define S_INTERN_ERR 0x80000019 2016399cec1Srenato /* RFC 4447 */ 2026399cec1Srenato #define S_ILLEGAL_CBIT 0x00000024 2036399cec1Srenato #define S_WRONG_CBIT 0x00000025 2046399cec1Srenato #define S_INCPT_BITRATE 0x00000026 2056399cec1Srenato #define S_CEP_MISCONF 0x00000027 2066399cec1Srenato #define S_PW_STATUS 0x00000028 2076399cec1Srenato #define S_UNASSIGN_TAI 0x00000029 2086399cec1Srenato #define S_MISCONF_ERR 0x0000002A 2096399cec1Srenato #define S_WITHDRAW_MTHD 0x0000002B 2103b4c1866Srenato /* RFC 5561 */ 2113b4c1866Srenato #define S_UNSSUPORTDCAP 0x0000002E 2129246985aSrenato /* RFC 5919 */ 2139246985aSrenato #define S_ENDOFLIB 0x0000002F 214a8c39dc0Srenato /* RFC 7552 */ 215a8c39dc0Srenato #define S_TRANS_MISMTCH 0x80000032 216a8c39dc0Srenato #define S_DS_NONCMPLNCE 0x80000033 217ab0c2486Smichele 218ab0c2486Smichele struct sess_prms_tlv { 2193de94509Srenato uint16_t type; 2203de94509Srenato uint16_t length; 2213de94509Srenato uint16_t proto_version; 2223de94509Srenato uint16_t keepalive_time; 2233de94509Srenato uint8_t reserved; 2243de94509Srenato uint8_t pvlim; 2253de94509Srenato uint16_t max_pdu_len; 2263de94509Srenato uint32_t lsr_id; 2273de94509Srenato uint16_t lspace_id; 22889f23408Sclaudio } __packed; 229ab0c2486Smichele 230ab0c2486Smichele #define SESS_PRMS_SIZE 18 23160e1e0e7Srenato #define SESS_PRMS_LEN 14 232ab0c2486Smichele 233ab0c2486Smichele struct status_tlv { 2343de94509Srenato uint16_t type; 2353de94509Srenato uint16_t length; 2363de94509Srenato uint32_t status_code; 2373de94509Srenato uint32_t msg_id; 2383de94509Srenato uint16_t msg_type; 23989f23408Sclaudio } __packed; 240ab0c2486Smichele 241ab0c2486Smichele #define STATUS_SIZE 14 242ab0c2486Smichele #define STATUS_TLV_LEN 10 243ab0c2486Smichele #define STATUS_FATAL 0x80000000 244ab0c2486Smichele 2453b4c1866Srenato struct capability_tlv { 2463b4c1866Srenato uint16_t type; 2473b4c1866Srenato uint16_t length; 2483b4c1866Srenato uint8_t reserved; 2493b4c1866Srenato }; 2503b4c1866Srenato #define STATE_BIT 0x80 2513b4c1866Srenato 2523b4c1866Srenato #define F_CAP_TLV_RCVD_DYNAMIC 0x01 253c7c5a728Srenato #define F_CAP_TLV_RCVD_TWCARD 0x02 2549246985aSrenato #define F_CAP_TLV_RCVD_UNOTIF 0x04 2553b4c1866Srenato 2563b4c1866Srenato #define CAP_TLV_DYNAMIC_SIZE 5 2573b4c1866Srenato #define CAP_TLV_DYNAMIC_LEN 1 2583b4c1866Srenato 259c7c5a728Srenato #define CAP_TLV_TWCARD_SIZE 5 260c7c5a728Srenato #define CAP_TLV_TWCARD_LEN 1 261c7c5a728Srenato 2629246985aSrenato #define CAP_TLV_UNOTIF_SIZE 5 2639246985aSrenato #define CAP_TLV_UNOTIF_LEN 1 2649246985aSrenato 2656399cec1Srenato #define AF_IPV4 0x1 2666399cec1Srenato #define AF_IPV6 0x2 2676399cec1Srenato 268ab0c2486Smichele struct address_list_tlv { 2693de94509Srenato uint16_t type; 2703de94509Srenato uint16_t length; 2713de94509Srenato uint16_t family; 272ab0c2486Smichele /* address entries */ 27389f23408Sclaudio } __packed; 274ab0c2486Smichele 275397583bcSrenato #define ADDR_LIST_SIZE 6 276397583bcSrenato 277cf483f25Srenato #define FEC_ELM_WCARD_LEN 1 278cf483f25Srenato #define FEC_ELM_PREFIX_MIN_LEN 4 2796399cec1Srenato #define FEC_PWID_ELM_MIN_LEN 8 28002a212eeSrenato #define FEC_PWID_SIZE 4 281c7c5a728Srenato #define FEC_ELM_TWCARD_MIN_LEN 3 282cf09440fSrenato 283cf09440fSrenato #define MAP_TYPE_WILDCARD 0x01 284cf09440fSrenato #define MAP_TYPE_PREFIX 0x02 285c7c5a728Srenato #define MAP_TYPE_TYPED_WCARD 0x05 286cf09440fSrenato #define MAP_TYPE_PWID 0x80 287cf09440fSrenato #define MAP_TYPE_GENPWID 0x81 2886399cec1Srenato 2896399cec1Srenato #define CONTROL_WORD_FLAG 0x8000 2906399cec1Srenato #define PW_TYPE_ETHERNET_TAGGED 0x0004 2916399cec1Srenato #define PW_TYPE_ETHERNET 0x0005 2926702dd25Srenato #define PW_TYPE_WILDCARD 0x7FFF 2931d5e7f63Srenato #define DEFAULT_PW_TYPE PW_TYPE_ETHERNET 2946399cec1Srenato 2956702dd25Srenato #define PW_TWCARD_RESERVED_BIT 0x8000 2966702dd25Srenato 2976399cec1Srenato /* RFC 4447 Sub-TLV record */ 2986399cec1Srenato struct subtlv { 2993de94509Srenato uint8_t type; 3003de94509Srenato uint8_t length; 3016399cec1Srenato }; 30260e1e0e7Srenato #define SUBTLV_HDR_SIZE 2 3036399cec1Srenato 3046399cec1Srenato #define SUBTLV_IFMTU 0x01 3056399cec1Srenato #define SUBTLV_VLANID 0x06 3066399cec1Srenato 30760e1e0e7Srenato #define FEC_SUBTLV_IFMTU_SIZE 4 30860e1e0e7Srenato #define FEC_SUBTLV_VLANID_SIZE 4 309ab0c2486Smichele 310ab0c2486Smichele struct label_tlv { 3113de94509Srenato uint16_t type; 3123de94509Srenato uint16_t length; 3133de94509Srenato uint32_t label; 314ab0c2486Smichele }; 31560e1e0e7Srenato #define LABEL_TLV_SIZE 8 31660e1e0e7Srenato #define LABEL_TLV_LEN 4 3170493f73aSmichele 3183220fd77Sclaudio struct reqid_tlv { 3193de94509Srenato uint16_t type; 3203de94509Srenato uint16_t length; 3213de94509Srenato uint32_t reqid; 3223220fd77Sclaudio }; 32360e1e0e7Srenato #define REQID_TLV_SIZE 8 32460e1e0e7Srenato #define REQID_TLV_LEN 4 3253220fd77Sclaudio 3266399cec1Srenato struct pw_status_tlv { 3273de94509Srenato uint16_t type; 3283de94509Srenato uint16_t length; 3293de94509Srenato uint32_t value; 3306399cec1Srenato }; 33160e1e0e7Srenato #define PW_STATUS_TLV_SIZE 8 33260e1e0e7Srenato #define PW_STATUS_TLV_LEN 4 3336399cec1Srenato 3346399cec1Srenato #define PW_FORWARDING 0 3356399cec1Srenato #define PW_NOT_FORWARDING (1 << 0) 3366399cec1Srenato #define PW_LOCAL_RX_FAULT (1 << 1) 3376399cec1Srenato #define PW_LOCAL_TX_FAULT (1 << 2) 3386399cec1Srenato #define PW_PSN_RX_FAULT (1 << 3) 3396399cec1Srenato #define PW_PSN_TX_FAULT (1 << 4) 3406399cec1Srenato 3414dcd314eSrenato #define NO_LABEL UINT32_MAX 342ab0c2486Smichele 343ab0c2486Smichele #endif /* !_LDP_H_ */ 344