]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: LGPL-2.1-or-later |
74971473 JG |
2 | /* |
3 | * This file is part of the PCEPlib, a PCEP protocol library. | |
4 | * | |
5 | * Copyright (C) 2020 Volta Networks https://voltanet.io/ | |
6 | * | |
74971473 JG |
7 | * Author : Brady Johnson <brady@voltanet.io> |
8 | */ | |
9 | ||
10 | ||
11 | /* | |
12 | * This is a High Level PCEP message API. | |
13 | */ | |
14 | ||
15 | #ifndef PCEP_MESSAGES_H | |
16 | #define PCEP_MESSAGES_H | |
17 | ||
18 | #include <stdint.h> | |
19 | #include <netinet/in.h> /* struct in_addr */ | |
20 | ||
21 | #include "pcep_utils_double_linked_list.h" | |
22 | #include "pcep_msg_objects.h" | |
23 | ||
24 | #ifdef __cplusplus | |
25 | extern "C" { | |
26 | #endif | |
27 | ||
28 | enum pcep_message_types { | |
29 | PCEP_TYPE_OPEN = 1, | |
30 | PCEP_TYPE_KEEPALIVE = 2, | |
31 | PCEP_TYPE_PCREQ = 3, | |
32 | PCEP_TYPE_PCREP = 4, | |
33 | PCEP_TYPE_PCNOTF = 5, | |
34 | PCEP_TYPE_ERROR = 6, | |
35 | PCEP_TYPE_CLOSE = 7, | |
36 | PCEP_TYPE_REPORT = 10, | |
37 | PCEP_TYPE_UPDATE = 11, | |
38 | PCEP_TYPE_INITIATE = 12, | |
39 | PCEP_TYPE_START_TLS = 13, | |
40 | PCEP_TYPE_MAX, | |
41 | }; | |
42 | ||
43 | #define PCEP_MESSAGE_HEADER_VERSION 1 | |
44 | ||
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 */ | |
50 | }; | |
51 | ||
52 | /* The obj_list is a double_linked_list of struct pcep_object_header pointers. | |
53 | */ | |
54 | struct pcep_message { | |
55 | struct pcep_message_header *msg_header; | |
56 | double_linked_list *obj_list; | |
57 | uint8_t *encoded_message; | |
58 | uint16_t encoded_message_length; | |
59 | }; | |
60 | ||
61 | ||
62 | /* | |
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 | |
71 | * free them. | |
72 | */ | |
73 | ||
74 | struct pcep_message *pcep_msg_create_open(uint8_t keepalive, uint8_t deadtimer, | |
75 | uint8_t sid); | |
76 | struct pcep_message * | |
77 | pcep_msg_create_open_with_tlvs(uint8_t keepalive, uint8_t deadtimer, | |
78 | uint8_t sid, double_linked_list *tlv_list); | |
79 | struct pcep_message * | |
80 | pcep_msg_create_request(struct pcep_object_rp *rp, | |
81 | struct pcep_object_endpoints_ipv4 *endpoints, | |
82 | double_linked_list *object_list); | |
83 | struct pcep_message * | |
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, | |
91 | uint8_t error_value); | |
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); | |
98 | ||
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); | |
115 | ||
116 | #ifdef __cplusplus | |
117 | } | |
118 | #endif | |
119 | ||
120 | #endif |