2 * This file is part of the PCEPlib, a PCEP protocol library.
4 * Copyright (C) 2020 Volta Networks https://voltanet.io/
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * Author : Brady Johnson <brady@voltanet.io>
24 * This is a High Level PCEP message API.
27 #ifndef PCEP_MESSAGES_H
28 #define PCEP_MESSAGES_H
31 #include <netinet/in.h> /* struct in_addr */
33 #include "pcep_utils_double_linked_list.h"
34 #include "pcep_msg_objects.h"
40 enum pcep_message_types
{
42 PCEP_TYPE_KEEPALIVE
= 2,
48 PCEP_TYPE_REPORT
= 10,
49 PCEP_TYPE_UPDATE
= 11,
50 PCEP_TYPE_INITIATE
= 12,
51 PCEP_TYPE_START_TLS
= 13,
55 #define PCEP_MESSAGE_HEADER_VERSION 1
57 struct pcep_message_header
{
58 uint8_t pcep_version
; /* Current version is 1. */
59 enum pcep_message_types
60 type
; /* Defines message type:
61 OPEN/KEEPALIVE/PCREQ/PCREP/PCNOTF/ERROR/CLOSE */
64 /* The obj_list is a double_linked_list of struct pcep_object_header pointers.
67 struct pcep_message_header
*msg_header
;
68 double_linked_list
*obj_list
;
69 uint8_t *encoded_message
;
70 uint16_t encoded_message_length
;
75 * Regarding memory usage:
76 * When creating messages, any objects and tlvs passed into these APIs will be
77 * free'd when the pcep_message is free'd. That includes the
78 * double_linked_list's. So, just create the objects and TLVs, put them in their
79 * double_linked_list's, and everything will be managed internally. The message
80 * will be deleted by pcep_msg_free_message() or pcep_msg_free_message_list()
81 * which, in turn will call one of: pcep_obj_free_object() and
82 * pcep_obj_free_tlv(). For received messages, call pcep_msg_free_message() to
86 struct pcep_message
*pcep_msg_create_open(uint8_t keepalive
, uint8_t deadtimer
,
89 pcep_msg_create_open_with_tlvs(uint8_t keepalive
, uint8_t deadtimer
,
90 uint8_t sid
, double_linked_list
*tlv_list
);
92 pcep_msg_create_request(struct pcep_object_rp
*rp
,
93 struct pcep_object_endpoints_ipv4
*endpoints
,
94 double_linked_list
*object_list
);
96 pcep_msg_create_request_ipv6(struct pcep_object_rp
*rp
,
97 struct pcep_object_endpoints_ipv6
*endpoints
,
98 double_linked_list
*object_list
);
99 struct pcep_message
*pcep_msg_create_reply(struct pcep_object_rp
*rp
,
100 double_linked_list
*object_list
);
101 struct pcep_message
*pcep_msg_create_close(uint8_t reason
);
102 struct pcep_message
*pcep_msg_create_error(uint8_t error_type
,
103 uint8_t error_value
);
104 struct pcep_message
*pcep_msg_create_error_with_objects(
105 uint8_t error_type
, uint8_t error_value
,
106 double_linked_list
*object_list
); /* include the offending objects */
107 struct pcep_message
*pcep_msg_create_keepalive(void);
108 struct pcep_message
*pcep_msg_create_notify(struct pcep_object_notify
*notify
,
109 double_linked_list
*object_list
);
111 /* Message defined in RFC 8231 section 6.1. Expecting double_linked_list of
112 * struct pcep_object_header* objects of type SRP, LSP, or path (ERO, Bandwidth,
113 * metrics, and RRO objects). */
114 struct pcep_message
*
115 pcep_msg_create_report(double_linked_list
*state_report_object_list
);
116 /* Message defined in RFC 8231. Expecting double_linked_list of at least 3
117 * struct pcep_object_header* objects of type SRP, LSP, and path (ERO and
118 * intended-attribute-list). The ERO must be present, but may be empty if
119 * the PCE cannot find a valid path for a delegated LSP. */
120 struct pcep_message
*
121 pcep_msg_create_update(double_linked_list
*update_request_object_list
);
122 /* Message defined in RFC 8281. Expecting double_linked_list of at least 2
123 * struct pcep_object_header* objects of type SRP and LSP for LSP deletion, and
124 * may also contain Endpoints, ERO and an attribute list for LSP creation. */
125 struct pcep_message
*
126 pcep_msg_create_initiate(double_linked_list
*lsp_object_list
);