]> git.proxmox.com Git - mirror_frr.git/blob - lib/ptm_lib.h
Merge pull request #12805 from karlquan/kquan_self_orig
[mirror_frr.git] / lib / ptm_lib.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* PTM Library
3 * Copyright (C) 2015 Cumulus Networks, Inc.
4 */
5 #ifndef __PTM_LIB_H__
6 #define __PTM_LIB_H__
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #define PTMLIB_MSG_SZ 1024
13 #define PTMLIB_MSG_HDR_LEN 37
14 #define PTMLIB_MSG_VERSION 2
15 #define PTMLIB_MAXNAMELEN 32
16
17 #define PTMLIB_CMD_GET_STATUS "get-status"
18 #define PTMLIB_CMD_GET_BFD_CLIENT "get-bfd-client"
19 #define PTMLIB_CMD_START_BFD_SESS "start-bfd-sess"
20 #define PTMLIB_CMD_STOP_BFD_SESS "stop-bfd-sess"
21
22 typedef enum {
23 PTMLIB_MSG_TYPE_NOTIFICATION = 1,
24 PTMLIB_MSG_TYPE_CMD,
25 PTMLIB_MSG_TYPE_RESPONSE,
26 } ptmlib_msg_type;
27
28 typedef enum {
29 MODULE_BFD = 0,
30 MODULE_LLDP,
31 MODULE_MAX,
32 } ptmlib_mod_type;
33
34 typedef int (*ptm_cmd_cb)(void *data, void *arg);
35 typedef int (*ptm_notify_cb)(void *data, void *arg);
36 typedef int (*ptm_response_cb)(void *data, void *arg);
37 typedef int (*ptm_log_cb)(void *data, void *arg, ...);
38
39 typedef struct ptm_lib_handle_s {
40 char client_name[PTMLIB_MAXNAMELEN];
41 ptm_cmd_cb cmd_cb;
42 ptm_notify_cb notify_cb;
43 ptm_response_cb response_cb;
44 } ptm_lib_handle_t;
45
46 /* Prototypes */
47 int ptm_lib_process_msg(ptm_lib_handle_t *, int, char *, int, void *);
48 ptm_lib_handle_t *ptm_lib_register(char *, ptm_cmd_cb, ptm_notify_cb,
49 ptm_response_cb);
50 void ptm_lib_deregister(ptm_lib_handle_t *);
51 int ptm_lib_find_key_in_msg(void *, const char *, char *);
52 int ptm_lib_init_msg(ptm_lib_handle_t *, int, int, void *, void **);
53 int ptm_lib_append_msg(ptm_lib_handle_t *, void *, const char *, const char *);
54 int ptm_lib_complete_msg(ptm_lib_handle_t *, void *, char *, int *);
55 int ptm_lib_cleanup_msg(ptm_lib_handle_t *, void *);
56
57 #ifdef __cplusplus
58 }
59 #endif
60
61 #endif