]>
Commit | Line | Data |
---|---|---|
c43ed2e4 DS |
1 | /********************************************************************* |
2 | * Copyright 2015 Cumulus Networks, LLC. All rights reserved. | |
3 | * | |
4 | * library file used by clients for sending commands and parsing response | |
5 | * | |
6 | */ | |
7 | ||
8 | #define PTMLIB_MSG_SZ 1024 | |
9 | #define PTMLIB_MSG_HDR_LEN 37 | |
10 | #define PTMLIB_MSG_VERSION 2 | |
11 | #define PTMLIB_MAXNAMELEN 32 | |
12 | ||
13 | #define PTMLIB_CMD_GET_STATUS "get-status" | |
14 | #define PTMLIB_CMD_GET_BFD_CLIENT "get-bfd-client" | |
15 | #define PTMLIB_CMD_START_BFD_SESS "start-bfd-sess" | |
16 | #define PTMLIB_CMD_STOP_BFD_SESS "stop-bfd-sess" | |
17 | ||
18 | typedef enum { | |
19 | PTMLIB_MSG_TYPE_NOTIFICATION = 1, | |
20 | PTMLIB_MSG_TYPE_CMD, | |
21 | PTMLIB_MSG_TYPE_RESPONSE, | |
22 | } ptmlib_msg_type; | |
23 | ||
24 | typedef enum { | |
25 | MODULE_BFD = 0, | |
26 | MODULE_LLDP, | |
27 | MODULE_MAX, | |
28 | } ptmlib_mod_type; | |
29 | ||
30 | typedef int (*ptm_cmd_cb) (void *data, void *arg); | |
31 | typedef int (*ptm_notify_cb) (void *data, void *arg); | |
32 | typedef int (*ptm_response_cb) (void *data, void *arg); | |
33 | typedef int (*ptm_log_cb) (void *data, void *arg,...); | |
34 | ||
35 | typedef struct ptm_lib_handle_s { | |
36 | char client_name[PTMLIB_MAXNAMELEN]; | |
37 | ptm_cmd_cb cmd_cb; | |
38 | ptm_notify_cb notify_cb; | |
39 | ptm_response_cb response_cb; | |
40 | } ptm_lib_handle_t; | |
41 | ||
42 | /* Prototypes */ | |
43 | int ptm_lib_process_msg(ptm_lib_handle_t *, int, char *, int, void *); | |
44 | ptm_lib_handle_t *ptm_lib_register(char *, ptm_cmd_cb, ptm_notify_cb, ptm_response_cb); | |
45 | void ptm_lib_deregister(ptm_lib_handle_t *); | |
46 | int ptm_lib_find_key_in_msg(void *, const char *, char *); | |
47 | int ptm_lib_init_msg(ptm_lib_handle_t *, int, int, void *, void **); | |
88177fe3 | 48 | int ptm_lib_append_msg(ptm_lib_handle_t *, void *, const char *, const char *); |
c43ed2e4 | 49 | int ptm_lib_complete_msg(ptm_lib_handle_t *, void *, char *, int *); |