1 /*********************************************************************
2 * Copyright 2015 Cumulus Networks, LLC. All rights reserved.
4 * library file used by clients for sending commands and parsing response
8 #define PTMLIB_MSG_SZ 1024
9 #define PTMLIB_MSG_HDR_LEN 37
10 #define PTMLIB_MSG_VERSION 2
11 #define PTMLIB_MAXNAMELEN 32
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"
19 PTMLIB_MSG_TYPE_NOTIFICATION
= 1,
21 PTMLIB_MSG_TYPE_RESPONSE
,
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
,...);
35 typedef struct ptm_lib_handle_s
{
36 char client_name
[PTMLIB_MAXNAMELEN
];
38 ptm_notify_cb notify_cb
;
39 ptm_response_cb response_cb
;
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 **);
48 int ptm_lib_append_msg(ptm_lib_handle_t
*, void *, const char *, char *);
49 int ptm_lib_complete_msg(ptm_lib_handle_t
*, void *, char *, int *);