python: merge branch 'python-capi'
Disable debug macro in swig API to reduce the noise and expose a couple of functions. https://github.com/thom311/libnl/pull/77
This commit is contained in:
commit
eae6a6875c
2 changed files with 27 additions and 1 deletions
|
@ -9,13 +9,15 @@
|
|||
#include <netlink/attr.h>
|
||||
#include <net/if.h>
|
||||
|
||||
#define DEBUG
|
||||
/* enable define below to get swig api debug messages */
|
||||
/*#define DEBUG*/
|
||||
#include "utils.h"
|
||||
%}
|
||||
|
||||
%include <stdint.i>
|
||||
%include <cstring.i>
|
||||
%include <cpointer.i>
|
||||
%include <exception.i>
|
||||
|
||||
%inline %{
|
||||
struct nl_dump_params *alloc_dump_params(void)
|
||||
|
@ -186,6 +188,9 @@ extern void nl_socket_set_peer_groups(struct nl_sock *sk, uint32_t groups);
|
|||
extern int nl_socket_set_buffer_size(struct nl_sock *, int, int);
|
||||
extern void nl_socket_set_cb(struct nl_sock *, struct nl_cb *);
|
||||
|
||||
extern int nl_socket_add_membership(struct nl_sock *, int);
|
||||
extern int nl_socket_drop_membership(struct nl_sock *, int);
|
||||
|
||||
extern int nl_send_auto_complete(struct nl_sock *, struct nl_msg *);
|
||||
extern int nl_recvmsgs(struct nl_sock *, struct nl_cb *);
|
||||
|
||||
|
@ -808,6 +813,19 @@ extern void *nla_data(struct nlattr *);
|
|||
%typemap(out) void *;
|
||||
extern int nla_type(const struct nlattr *);
|
||||
|
||||
%typemap(in) (int, const void *) {
|
||||
$1 = Py_SIZE($input);
|
||||
if (PyByteArray_Check($input)) {
|
||||
$2 = ($2_ltype)PyByteArray_AsString($input);
|
||||
} else if (PyString_Check($input)) {
|
||||
$2 = ($2_ltype)PyString_AsString($input);
|
||||
} else
|
||||
SWIG_exception(SWIG_TypeError,
|
||||
"pointer must be bytearray or string.");
|
||||
}
|
||||
extern int nla_put(struct nl_msg *, int, int, const void *);
|
||||
%typemap(in) const void *;
|
||||
|
||||
/* Integer attribute */
|
||||
extern uint8_t nla_get_u8(struct nlattr *);
|
||||
extern int nla_put_u8(struct nl_msg *, int, uint8_t);
|
||||
|
|
|
@ -36,8 +36,16 @@ extern void genl_family_set_maxattr(struct genl_family *, uint32_t);
|
|||
extern int genl_family_add_op(struct genl_family *, int, int);
|
||||
extern int genl_family_add_grp(struct genl_family *, uint32_t , const char *);
|
||||
|
||||
/* #include <linux/genetlink.h> */
|
||||
struct genlmsghdr {
|
||||
uint8_t cmd;
|
||||
uint8_t version;
|
||||
uint16_t reserved;
|
||||
};
|
||||
|
||||
/* #include <netlink/genl/genl.h> */
|
||||
extern int genl_connect(struct nl_sock *);
|
||||
extern struct genlmsghdr *genlmsg_hdr(struct nlmsghdr *);
|
||||
|
||||
extern void *genlmsg_put(struct nl_msg *, uint32_t, uint32_t,
|
||||
int, int, int, uint8_t, uint8_t);
|
||||
|
|
Loading…
Add table
Reference in a new issue