]> git.proxmox.com Git - mirror_frr.git/blob - pceplib/pcep_session_logic_internals.h
Merge pull request #12762 from sri-mohan1/sri-bable
[mirror_frr.git] / pceplib / pcep_session_logic_internals.h
1 /*
2 * This file is part of the PCEPlib, a PCEP protocol library.
3 *
4 * Copyright (C) 2020 Volta Networks https://voltanet.io/
5 *
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.
10 *
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.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 *
19 * Author : Brady Johnson <brady@voltanet.io>
20 *
21 */
22
23
24 /*
25 * Internal Session Logic declarations, not intended to be in the public API.
26 */
27
28 #ifndef SRC_PCEPSESSIONLOGICINTERNALS_H_
29 #define SRC_PCEPSESSIONLOGICINTERNALS_H_
30
31
32 #include <pthread.h>
33 #include <stdbool.h>
34
35 #include "pcep_msg_tools.h"
36
37 #include "pcep_utils_double_linked_list.h"
38 #include "pcep_utils_ordered_list.h"
39 #include "pcep_utils_queue.h"
40
41
42 typedef struct pcep_session_logic_handle_ {
43 pthread_t session_logic_thread;
44 pthread_mutex_t session_logic_mutex;
45 pthread_cond_t session_logic_cond_var;
46 bool session_logic_condition;
47 bool active;
48
49 ordered_list_handle *session_list;
50 pthread_mutex_t session_list_mutex;
51 /* Internal timers and socket events */
52 queue_handle *session_event_queue;
53
54 } pcep_session_logic_handle;
55
56
57 /* Used internally for Session events: message received, timer expired,
58 * or socket closed */
59 typedef struct pcep_session_event_ {
60 pcep_session *session;
61 int expired_timer_id;
62 double_linked_list *received_msg_list;
63 bool socket_closed;
64
65 } pcep_session_event;
66
67 /* Event Counters counter-id definitions */
68 typedef enum pcep_session_counters_event_counter_ids {
69 PCEP_EVENT_COUNTER_ID_PCC_CONNECT = 0,
70 PCEP_EVENT_COUNTER_ID_PCE_CONNECT = 1,
71 PCEP_EVENT_COUNTER_ID_PCC_DISCONNECT = 2,
72 PCEP_EVENT_COUNTER_ID_PCE_DISCONNECT = 3,
73 PCEP_EVENT_COUNTER_ID_TIMER_KEEPALIVE = 4,
74 PCEP_EVENT_COUNTER_ID_TIMER_DEADTIMER = 5,
75 PCEP_EVENT_COUNTER_ID_TIMER_OPENKEEPWAIT = 6,
76 PCEP_EVENT_COUNTER_ID_TIMER_OPENKEEPALIVE = 7
77
78 } pcep_session_counters_event_counter_ids;
79
80 /* functions implemented in pcep_session_logic_loop.c */
81 void *session_logic_loop(void *data);
82 int session_logic_msg_ready_handler(void *data, int socket_fd);
83 void session_logic_message_sent_handler(void *data, int socket_fd);
84 void session_logic_conn_except_notifier(void *data, int socket_fd);
85 void session_logic_timer_expire_handler(void *data, int timer_id);
86
87 void handle_timer_event(pcep_session_event *event);
88 void handle_socket_comm_event(pcep_session_event *event);
89 void session_send_message(pcep_session *session, struct pcep_message *message);
90
91 /* defined in pcep_session_logic_states.c */
92 void send_pcep_error(pcep_session *session, enum pcep_error_type error_type,
93 enum pcep_error_value error_value);
94 void enqueue_event(pcep_session *session, pcep_event_type event_type,
95 struct pcep_message *message);
96 void increment_unknown_message(pcep_session *session);
97
98 /* defined in pcep_session_logic_counters.c */
99 void create_session_counters(pcep_session *session);
100 void increment_event_counters(
101 pcep_session *session,
102 pcep_session_counters_event_counter_ids counter_id);
103 void increment_message_rx_counters(pcep_session *session,
104 struct pcep_message *message);
105
106 /* defined in pcep_session_logic.c, also used in pcep_session_logic_states.c */
107 struct pcep_message *create_pcep_open(pcep_session *session);
108
109 #endif /* SRC_PCEPSESSIONLOGICINTERNALS_H_ */