1 // SPDX-License-Identifier: LGPL-2.1-or-later
3 * This file is part of the PCEPlib, a PCEP protocol library.
5 * Copyright (C) 2020 Volta Networks https://voltanet.io/
7 * Author : Brady Johnson <brady@voltanet.io>
12 * This is a High Level PCEP message API.
15 #ifndef PCEP_MESSAGES_H
16 #define PCEP_MESSAGES_H
19 #include <netinet/in.h> /* struct in_addr */
21 #include "pcep_utils_double_linked_list.h"
22 #include "pcep_msg_objects.h"
28 enum pcep_message_types
{
30 PCEP_TYPE_KEEPALIVE
= 2,
36 PCEP_TYPE_REPORT
= 10,
37 PCEP_TYPE_UPDATE
= 11,
38 PCEP_TYPE_INITIATE
= 12,
39 PCEP_TYPE_START_TLS
= 13,
43 #define PCEP_MESSAGE_HEADER_VERSION 1
45 struct pcep_message_header
{
46 uint8_t pcep_version
; /* Current version is 1. */
47 enum pcep_message_types
48 type
; /* Defines message type:
49 OPEN/KEEPALIVE/PCREQ/PCREP/PCNOTF/ERROR/CLOSE */
52 /* The obj_list is a double_linked_list of struct pcep_object_header pointers.
55 struct pcep_message_header
*msg_header
;
56 double_linked_list
*obj_list
;
57 uint8_t *encoded_message
;
58 uint16_t encoded_message_length
;
63 * Regarding memory usage:
64 * When creating messages, any objects and tlvs passed into these APIs will be
65 * free'd when the pcep_message is free'd. That includes the
66 * double_linked_list's. So, just create the objects and TLVs, put them in their
67 * double_linked_list's, and everything will be managed internally. The message
68 * will be deleted by pcep_msg_free_message() or pcep_msg_free_message_list()
69 * which, in turn will call one of: pcep_obj_free_object() and
70 * pcep_obj_free_tlv(). For received messages, call pcep_msg_free_message() to
74 struct pcep_message
*pcep_msg_create_open(uint8_t keepalive
, uint8_t deadtimer
,
77 pcep_msg_create_open_with_tlvs(uint8_t keepalive
, uint8_t deadtimer
,
78 uint8_t sid
, double_linked_list
*tlv_list
);
80 pcep_msg_create_request(struct pcep_object_rp
*rp
,
81 struct pcep_object_endpoints_ipv4
*endpoints
,
82 double_linked_list
*object_list
);
84 pcep_msg_create_request_ipv6(struct pcep_object_rp
*rp
,
85 struct pcep_object_endpoints_ipv6
*endpoints
,
86 double_linked_list
*object_list
);
87 struct pcep_message
*pcep_msg_create_reply(struct pcep_object_rp
*rp
,
88 double_linked_list
*object_list
);
89 struct pcep_message
*pcep_msg_create_close(uint8_t reason
);
90 struct pcep_message
*pcep_msg_create_error(uint8_t error_type
,
92 struct pcep_message
*pcep_msg_create_error_with_objects(
93 uint8_t error_type
, uint8_t error_value
,
94 double_linked_list
*object_list
); /* include the offending objects */
95 struct pcep_message
*pcep_msg_create_keepalive(void);
96 struct pcep_message
*pcep_msg_create_notify(struct pcep_object_notify
*notify
,
97 double_linked_list
*object_list
);
99 /* Message defined in RFC 8231 section 6.1. Expecting double_linked_list of
100 * struct pcep_object_header* objects of type SRP, LSP, or path (ERO, Bandwidth,
101 * metrics, and RRO objects). */
102 struct pcep_message
*
103 pcep_msg_create_report(double_linked_list
*state_report_object_list
);
104 /* Message defined in RFC 8231. Expecting double_linked_list of at least 3
105 * struct pcep_object_header* objects of type SRP, LSP, and path (ERO and
106 * intended-attribute-list). The ERO must be present, but may be empty if
107 * the PCE cannot find a valid path for a delegated LSP. */
108 struct pcep_message
*
109 pcep_msg_create_update(double_linked_list
*update_request_object_list
);
110 /* Message defined in RFC 8281. Expecting double_linked_list of at least 2
111 * struct pcep_object_header* objects of type SRP and LSP for LSP deletion, and
112 * may also contain Endpoints, ERO and an attribute list for LSP creation. */
113 struct pcep_message
*
114 pcep_msg_create_initiate(double_linked_list
*lsp_object_list
);