summaryrefslogtreecommitdiff
path: root/source4/libcli/swig/libcli_nbt.i
blob: 6bcbd7a65be37fd090fcb0e9f0c7f883442ea5d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* 
   Unix SMB/CIFS implementation.

   Swig interface to libcli_nbt library.

   Copyright (C) 2006 Tim Potter <tpot@samba.org>

     ** NOTE! The following LGPL license applies to the tdb
     ** library. This does NOT imply that all of Samba is released
     ** under the LGPL
   
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 3 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/

%module libcli_nbt

%{

#include "includes.h"
#include "lib/talloc/talloc.h"
#include "lib/events/events.h"
#include "libcli/nbt/libnbt.h"
#include "param/param.h"

/* Undo strcpy safety macro as it's used by swig )-: */

#undef strcpy

/* Loadparm parameters */

static struct loadparm_context lp_ctx;

%}

%apply bool { BOOL };
%apply int { uint8_t };
%apply int { int8_t };
%apply unsigned int { uint16_t };
%apply int { int16_t };

%typemap(in) uint32_t {
	if (PyLong_Check($input))
		$1 = PyLong_AsUnsignedLong($input);
	else if (PyInt_Check($input))
		$1 = PyInt_AsLong($input);
	else {
		PyErr_SetString(PyExc_TypeError,"Expected a long or an int");
		return NULL;
	}
}

%typemap(out) uint32_t {
	$result = PyLong_FromUnsignedLong($1);
}

%apply unsigned long long { uint64_t };
%apply long long { int64_t };

%typemap(in) NTSTATUS {
        if (PyLong_Check($input))
                $1 = NT_STATUS(PyLong_AsUnsignedLong($input));
        else if (PyInt_Check($input))
                $1 = NT_STATUS(PyInt_AsLong($input));
        else {
                PyErr_SetString(PyExc_TypeError, "Expected a long or an int");
                return NULL;
        }
}

%typemap(out) NTSTATUS {
        $result = PyLong_FromUnsignedLong(NT_STATUS_V($1));
}

TALLOC_CTX *talloc_init(char *name);
int talloc_free(TALLOC_CTX *ptr);

/* Function prototypes */

struct event_context *event_context_init(TALLOC_CTX *mem_ctx);

struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx, 
					     struct event_context *event_ctx);

enum nbt_name_type {
	NBT_NAME_CLIENT=0x00,
	NBT_NAME_MS=0x01,
	NBT_NAME_USER=0x03,
	NBT_NAME_SERVER=0x20,
	NBT_NAME_PDC=0x1B,
	NBT_NAME_LOGON=0x1C,
	NBT_NAME_MASTER=0x1D,
	NBT_NAME_BROWSER=0x1E
};

struct nbt_name {
	const char *name;
	const char *scope;
	enum nbt_name_type type;
};

%rename(data_in) in;
%rename(data_out) out;

struct nbt_name_query {
	struct {
		struct nbt_name name;
		const char *dest_addr;
		BOOL broadcast;
		BOOL wins_lookup;
		int timeout; /* in seconds */
		int retries;
	} in;
	struct {
		const char *reply_from;
		struct nbt_name name;
		int16_t num_addrs;
		const char **reply_addrs;
	} out;
};

%include "carrays.i"
%array_functions(char *, char_ptr_array);

%rename(do_nbt_name_query) nbt_name_query;

NTSTATUS nbt_name_query(struct nbt_name_socket *nbtsock, 
			TALLOC_CTX *mem_ctx, struct nbt_name_query *io);

%init %{
      loadparm_init(&lp_ctx);
%}