Changeset 745 for trunk/server/libcli/nbt
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 1 deleted
- 11 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/libcli/nbt/libnbt.h
r414 r745 96 96 struct socket_context *sock; 97 97 struct tevent_context *event_ctx; 98 struct smb_iconv_convenience *iconv_convenience;99 98 100 99 /* a queue of requests pending to be sent */ … … 276 275 277 276 struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx, 278 struct tevent_context *event_ctx, 279 struct smb_iconv_convenience *iconv_convenience); 277 struct tevent_context *event_ctx); 280 278 void nbt_name_socket_handle_response_packet(struct nbt_name_request *req, 281 279 struct nbt_name_packet *packet, … … 295 293 296 294 NTSTATUS nbt_name_dup(TALLOC_CTX *mem_ctx, struct nbt_name *name, struct nbt_name *newname); 297 NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience,DATA_BLOB *blob, struct nbt_name *name);295 NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct nbt_name *name); 298 296 NTSTATUS nbt_name_from_blob(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, struct nbt_name *name); 299 297 void nbt_choose_called_name(TALLOC_CTX *mem_ctx, struct nbt_name *n, const char *name, int type); … … 342 340 NTSTATUS nbt_rcode_to_ntstatus(uint8_t rcode); 343 341 344 struct composite_context; 345 struct composite_context *nbt_name_register_bcast_send(struct nbt_name_socket *nbtsock, 346 struct nbt_name_register_bcast *io); 347 NTSTATUS nbt_name_register_bcast_recv(struct composite_context *c); 348 struct composite_context *nbt_name_register_wins_send(struct nbt_name_socket *nbtsock, 349 struct nbt_name_register_wins *io); 350 NTSTATUS nbt_name_refresh_wins_recv(struct composite_context *c, TALLOC_CTX *mem_ctx, 351 struct nbt_name_refresh_wins *io); 352 struct composite_context *nbt_name_refresh_wins_send(struct nbt_name_socket *nbtsock, 353 struct nbt_name_refresh_wins *io); 354 NTSTATUS nbt_name_register_wins_recv(struct composite_context *c, TALLOC_CTX *mem_ctx, 342 struct tevent_context; 343 struct tevent_req; 344 struct tevent_req *nbt_name_register_bcast_send(TALLOC_CTX *mem_ctx, 345 struct tevent_context *ev, 346 struct nbt_name_socket *nbtsock, 347 struct nbt_name_register_bcast *io); 348 NTSTATUS nbt_name_register_bcast_recv(struct tevent_req *req); 349 struct tevent_req *nbt_name_register_wins_send(TALLOC_CTX *mem_ctx, 350 struct tevent_context *ev, 351 struct nbt_name_socket *nbtsock, 352 struct nbt_name_register_wins *io); 353 NTSTATUS nbt_name_register_wins_recv(struct tevent_req *req, 354 TALLOC_CTX *mem_ctx, 355 355 struct nbt_name_register_wins *io); 356 356 struct tevent_req *nbt_name_refresh_wins_send(TALLOC_CTX *mem_ctx, 357 struct tevent_context *ev, 358 struct nbt_name_socket *nbtsock, 359 struct nbt_name_refresh_wins *io); 360 NTSTATUS nbt_name_refresh_wins_recv(struct tevent_req *req, 361 TALLOC_CTX *mem_ctx, 362 struct nbt_name_refresh_wins *io); 357 363 358 364 XFILE *startlmhosts(const char *fname); … … 361 367 void endlmhosts(XFILE *fp); 362 368 369 NTSTATUS resolve_lmhosts_file_as_sockaddr(const char *lmhosts_file, 370 const char *name, int name_type, 371 TALLOC_CTX *mem_ctx, 372 struct sockaddr_storage **return_iplist, 373 int *return_count); 374 375 NTSTATUS resolve_dns_hosts_file_as_sockaddr(const char *dns_hosts_file, 376 const char *name, bool srv_lookup, 377 TALLOC_CTX *mem_ctx, 378 struct sockaddr_storage **return_iplist, 379 int *return_count); 380 363 381 #endif /* __LIBNBT_H__ */ -
trunk/server/libcli/nbt/lmhosts.c
r414 r745 27 27 #include "system/filesys.h" 28 28 #include "system/network.h" 29 #include "../libcli/nbt/libnbt.h" 29 30 30 31 /******************************************************** … … 156 157 } 157 158 159 /******************************************************** 160 Resolve via "lmhosts" method. 161 *********************************************************/ 162 163 NTSTATUS resolve_lmhosts_file_as_sockaddr(const char *lmhosts_file, 164 const char *name, int name_type, 165 TALLOC_CTX *mem_ctx, 166 struct sockaddr_storage **return_iplist, 167 int *return_count) 168 { 169 /* 170 * "lmhosts" means parse the local lmhosts file. 171 */ 172 173 XFILE *fp; 174 char *lmhost_name = NULL; 175 int name_type2; 176 struct sockaddr_storage return_ss; 177 NTSTATUS status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND; 178 TALLOC_CTX *ctx = NULL; 179 180 *return_iplist = NULL; 181 *return_count = 0; 182 183 DEBUG(3,("resolve_lmhosts: " 184 "Attempting lmhosts lookup for name %s<0x%x>\n", 185 name, name_type)); 186 187 fp = startlmhosts(lmhosts_file); 188 189 if ( fp == NULL ) 190 return NT_STATUS_NO_SUCH_FILE; 191 192 ctx = talloc_new(mem_ctx); 193 if (!ctx) { 194 endlmhosts(fp); 195 return NT_STATUS_NO_MEMORY; 196 } 197 198 while (getlmhostsent(ctx, fp, &lmhost_name, &name_type2, &return_ss)) { 199 200 if (!strequal(name, lmhost_name)) { 201 TALLOC_FREE(lmhost_name); 202 continue; 203 } 204 205 if ((name_type2 != -1) && (name_type != name_type2)) { 206 TALLOC_FREE(lmhost_name); 207 continue; 208 } 209 210 *return_iplist = talloc_realloc(ctx, (*return_iplist), 211 struct sockaddr_storage, 212 (*return_count)+1); 213 214 if ((*return_iplist) == NULL) { 215 TALLOC_FREE(ctx); 216 endlmhosts(fp); 217 DEBUG(3,("resolve_lmhosts: talloc_realloc fail !\n")); 218 return NT_STATUS_NO_MEMORY; 219 } 220 221 (*return_iplist)[*return_count] = return_ss; 222 *return_count += 1; 223 224 /* we found something */ 225 status = NT_STATUS_OK; 226 227 /* Multiple names only for DC lookup */ 228 if (name_type != 0x1c) 229 break; 230 } 231 232 talloc_steal(mem_ctx, *return_iplist); 233 TALLOC_FREE(ctx); 234 endlmhosts(fp); 235 return status; 236 } 237 -
trunk/server/libcli/nbt/man/nmblookup.1.xml
r414 r745 1 1 <?xml version="1.0" encoding="iso-8859-1"?> 2 <!DOCTYPE refentry PUBLIC "-// Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> 3 3 <refentry id="nmblookup"> 4 4 … … 107 107 </varlistentry> 108 108 109 110 111 &popt.common.connection;112 &stdarg.help;113 114 109 <varlistentry> 115 110 <term>-B <broadcast address></term> … … 124 119 </varlistentry> 125 120 126 127 128 121 <varlistentry> 129 122 <term>-U <unicast address></term> … … 133 126 query a WINS server.</para></listitem> 134 127 </varlistentry> 135 136 &stdarg.server.debug;137 &popt.common.samba;138 128 139 129 <varlistentry> -
trunk/server/libcli/nbt/namerefresh.c
r414 r745 21 21 22 22 #include "includes.h" 23 #include <tevent.h> 23 24 #include "../libcli/nbt/libnbt.h" 24 25 #include "../libcli/nbt/nbt_proto.h" 25 #include "libcli/composite/composite.h"26 26 #include "lib/socket/socket.h" 27 #include "lib/util/tevent_ntstatus.h" 27 28 28 29 /* … … 143 144 reply for each address 144 145 */ 145 struct refresh_wins_state {146 struct nbt_name_refresh_wins_state { 146 147 struct nbt_name_socket *nbtsock; 147 148 struct nbt_name_refresh *io; 148 c onst char **wins_servers;149 char **wins_servers; 149 150 uint16_t wins_port; 150 c onst char **addresses;151 char **addresses; 151 152 int address_idx; 152 struct nbt_name_request *req;153 153 }; 154 154 155 156 /** 157 state handler for WINS multi-homed multi-server name refresh 158 */ 159 static void name_refresh_wins_handler(struct nbt_name_request *req) 160 { 161 struct composite_context *c = talloc_get_type(req->async.private_data, 162 struct composite_context); 163 struct refresh_wins_state *state = talloc_get_type(c->private_data, 164 struct refresh_wins_state); 165 NTSTATUS status; 166 167 status = nbt_name_refresh_recv(state->req, state, state->io); 168 if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { 169 /* the refresh timed out - try the next WINS server */ 170 state->wins_servers++; 171 state->address_idx = 0; 172 if (state->wins_servers[0] == NULL) { 173 c->state = COMPOSITE_STATE_ERROR; 174 c->status = status; 175 goto done; 176 } 177 state->io->in.dest_addr = state->wins_servers[0]; 178 state->io->in.dest_port = state->wins_port; 179 state->io->in.address = state->addresses[0]; 180 state->req = nbt_name_refresh_send(state->nbtsock, state->io); 181 if (state->req == NULL) { 182 c->state = COMPOSITE_STATE_ERROR; 183 c->status = NT_STATUS_NO_MEMORY; 184 } else { 185 state->req->async.fn = name_refresh_wins_handler; 186 state->req->async.private_data = c; 187 } 188 } else if (!NT_STATUS_IS_OK(status)) { 189 c->state = COMPOSITE_STATE_ERROR; 190 c->status = status; 191 } else { 192 if (state->io->out.rcode == 0 && 193 state->addresses[state->address_idx+1] != NULL) { 194 /* refresh our next address */ 195 state->io->in.address = state->addresses[++(state->address_idx)]; 196 state->req = nbt_name_refresh_send(state->nbtsock, state->io); 197 if (state->req == NULL) { 198 c->state = COMPOSITE_STATE_ERROR; 199 c->status = NT_STATUS_NO_MEMORY; 200 } else { 201 state->req->async.fn = name_refresh_wins_handler; 202 state->req->async.private_data = c; 203 } 204 } else { 205 c->state = COMPOSITE_STATE_DONE; 206 c->status = NT_STATUS_OK; 207 } 208 } 209 210 done: 211 if (c->state >= COMPOSITE_STATE_DONE && 212 c->async.fn) { 213 c->async.fn(c); 214 } 215 } 155 static void nbt_name_refresh_wins_handler(struct nbt_name_request *subreq); 216 156 217 157 /** 218 158 the async send call for a multi-server WINS refresh 219 159 */ 220 _PUBLIC_ struct composite_context *nbt_name_refresh_wins_send(struct nbt_name_socket *nbtsock, 221 struct nbt_name_refresh_wins *io) 222 { 223 struct composite_context *c; 224 struct refresh_wins_state *state; 225 226 c = talloc_zero(nbtsock, struct composite_context); 227 if (c == NULL) goto failed; 228 229 state = talloc(c, struct refresh_wins_state); 230 if (state == NULL) goto failed; 160 _PUBLIC_ struct tevent_req *nbt_name_refresh_wins_send(TALLOC_CTX *mem_ctx, 161 struct tevent_context *ev, 162 struct nbt_name_socket *nbtsock, 163 struct nbt_name_refresh_wins *io) 164 { 165 struct tevent_req *req; 166 struct nbt_name_refresh_wins_state *state; 167 struct nbt_name_request *subreq; 168 169 req = tevent_req_create(mem_ctx, &state, 170 struct nbt_name_refresh_wins_state); 171 if (req == NULL) { 172 return NULL; 173 } 231 174 232 175 state->io = talloc(state, struct nbt_name_refresh); 233 if (state->io == NULL) goto failed; 176 if (tevent_req_nomem(state->io, req)) { 177 return tevent_req_post(req, ev); 178 } 179 180 if (io->in.wins_servers == NULL) { 181 tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER); 182 return tevent_req_post(req, ev); 183 } 184 185 if (io->in.wins_servers[0] == NULL) { 186 tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER); 187 return tevent_req_post(req, ev); 188 } 189 190 if (io->in.addresses == NULL) { 191 tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER); 192 return tevent_req_post(req, ev); 193 } 194 195 if (io->in.addresses[0] == NULL) { 196 tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER); 197 return tevent_req_post(req, ev); 198 } 234 199 235 200 state->wins_port = io->in.wins_port; 236 state->wins_servers = (const char **)str_list_copy(state, io->in.wins_servers); 237 if (state->wins_servers == NULL || 238 state->wins_servers[0] == NULL) goto failed; 239 240 state->addresses = (const char **)str_list_copy(state, io->in.addresses); 241 if (state->addresses == NULL || 242 state->addresses[0] == NULL) goto failed; 201 state->wins_servers = str_list_copy(state, io->in.wins_servers); 202 if (tevent_req_nomem(state->wins_servers, req)) { 203 return tevent_req_post(req, ev); 204 } 205 206 state->addresses = str_list_copy(state, io->in.addresses); 207 if (tevent_req_nomem(state->addresses, req)) { 208 return tevent_req_post(req, ev); 209 } 243 210 244 211 state->io->in.name = io->in.name; … … 255 222 state->address_idx = 0; 256 223 257 state->req = nbt_name_refresh_send(nbtsock, state->io); 258 if (state->req == NULL) goto failed; 259 260 state->req->async.fn = name_refresh_wins_handler; 261 state->req->async.private_data = c; 262 263 c->private_data = state; 264 c->state = COMPOSITE_STATE_IN_PROGRESS; 265 c->event_ctx = nbtsock->event_ctx; 266 267 return c; 268 269 failed: 270 talloc_free(c); 271 return NULL; 224 subreq = nbt_name_refresh_send(nbtsock, state->io); 225 if (tevent_req_nomem(subreq, req)) { 226 return tevent_req_post(req, ev); 227 } 228 229 subreq->async.fn = nbt_name_refresh_wins_handler; 230 subreq->async.private_data = req; 231 232 return req; 233 } 234 235 static void nbt_name_refresh_wins_handler(struct nbt_name_request *subreq) 236 { 237 struct tevent_req *req = 238 talloc_get_type_abort(subreq->async.private_data, 239 struct tevent_req); 240 struct nbt_name_refresh_wins_state *state = 241 tevent_req_data(req, 242 struct nbt_name_refresh_wins_state); 243 NTSTATUS status; 244 245 status = nbt_name_refresh_recv(subreq, state, state->io); 246 if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { 247 /* the refresh timed out - try the next WINS server */ 248 state->wins_servers++; 249 if (state->wins_servers[0] == NULL) { 250 tevent_req_nterror(req, status); 251 return; 252 } 253 254 state->address_idx = 0; 255 state->io->in.dest_addr = state->wins_servers[0]; 256 state->io->in.dest_port = state->wins_port; 257 state->io->in.address = state->addresses[0]; 258 259 subreq = nbt_name_refresh_send(state->nbtsock, state->io); 260 if (tevent_req_nomem(subreq, req)) { 261 return; 262 } 263 subreq->async.fn = nbt_name_refresh_wins_handler; 264 subreq->async.private_data = req; 265 } else if (!NT_STATUS_IS_OK(status)) { 266 tevent_req_nterror(req, status); 267 return; 268 } 269 270 if (state->io->out.rcode == 0 && 271 state->addresses[state->address_idx+1] != NULL) { 272 /* refresh our next address */ 273 state->io->in.address = state->addresses[++(state->address_idx)]; 274 subreq = nbt_name_refresh_send(state->nbtsock, state->io); 275 if (tevent_req_nomem(subreq, req)) { 276 return; 277 } 278 subreq->async.fn = nbt_name_refresh_wins_handler; 279 subreq->async.private_data = req; 280 return; 281 } 282 283 tevent_req_done(req); 272 284 } 273 285 … … 275 287 multi-homed WINS name refresh - recv side 276 288 */ 277 _PUBLIC_ NTSTATUS nbt_name_refresh_wins_recv(struct composite_context *c, TALLOC_CTX *mem_ctx, 278 struct nbt_name_refresh_wins *io) 279 { 289 _PUBLIC_ NTSTATUS nbt_name_refresh_wins_recv(struct tevent_req *req, 290 TALLOC_CTX *mem_ctx, 291 struct nbt_name_refresh_wins *io) 292 { 293 struct nbt_name_refresh_wins_state *state = 294 tevent_req_data(req, 295 struct nbt_name_refresh_wins_state); 280 296 NTSTATUS status; 281 status = composite_wait(c); 282 if (NT_STATUS_IS_OK(status)) { 283 struct refresh_wins_state *state = 284 talloc_get_type(c->private_data, struct refresh_wins_state); 285 io->out.wins_server = talloc_steal(mem_ctx, state->wins_servers[0]); 286 io->out.rcode = state->io->out.rcode; 287 } 288 talloc_free(c); 289 return status; 297 298 if (tevent_req_is_nterror(req, &status)) { 299 tevent_req_received(req); 300 return status; 301 } 302 303 io->out.wins_server = talloc_move(mem_ctx, &state->wins_servers[0]); 304 io->out.rcode = state->io->out.rcode; 305 306 tevent_req_received(req); 307 return NT_STATUS_OK; 290 308 } 291 309 … … 294 312 */ 295 313 _PUBLIC_ NTSTATUS nbt_name_refresh_wins(struct nbt_name_socket *nbtsock, 296 TALLOC_CTX *mem_ctx, 297 struct nbt_name_refresh_wins *io) 298 { 299 struct composite_context *c = nbt_name_refresh_wins_send(nbtsock, io); 300 return nbt_name_refresh_wins_recv(c, mem_ctx, io); 301 } 314 TALLOC_CTX *mem_ctx, 315 struct nbt_name_refresh_wins *io) 316 { 317 TALLOC_CTX *frame = talloc_stackframe(); 318 struct tevent_context *ev; 319 struct tevent_req *subreq; 320 NTSTATUS status; 321 322 /* 323 * TODO: create a temporary event context 324 */ 325 ev = nbtsock->event_ctx; 326 327 subreq = nbt_name_refresh_wins_send(frame, ev, nbtsock, io); 328 if (subreq == NULL) { 329 talloc_free(frame); 330 return NT_STATUS_NO_MEMORY; 331 } 332 333 if (!tevent_req_poll(subreq, ev)) { 334 status = map_nt_error_from_unix(errno); 335 talloc_free(frame); 336 return status; 337 } 338 339 status = nbt_name_refresh_wins_recv(subreq, mem_ctx, io); 340 if (!NT_STATUS_IS_OK(status)) { 341 talloc_free(frame); 342 return status; 343 } 344 345 TALLOC_FREE(frame); 346 return NT_STATUS_OK; 347 } -
trunk/server/libcli/nbt/nameregister.c
r414 r745 21 21 22 22 #include "includes.h" 23 #include <tevent.h> 23 24 #include "../libcli/nbt/libnbt.h" 24 25 #include "../libcli/nbt/nbt_proto.h" 25 #include "libcli/composite/composite.h"26 26 #include "lib/socket/socket.h" 27 27 #include "librpc/gen_ndr/ndr_nbt.h" 28 #include "../lib/util/tevent_ntstatus.h" 28 29 29 30 /* … … 149 150 a name registration demand 150 151 */ 151 struct register_bcast_state {152 struct nbt_name_register_bcast_state { 152 153 struct nbt_name_socket *nbtsock; 153 struct nbt_name_register *io; 154 struct nbt_name_request *req; 154 struct nbt_name_register io; 155 155 }; 156 156 157 158 /* 159 state handler for 4 stage name registration 160 */ 161 static void name_register_bcast_handler(struct nbt_name_request *req) 162 { 163 struct composite_context *c = talloc_get_type(req->async.private_data, struct composite_context); 164 struct register_bcast_state *state = talloc_get_type(c->private_data, struct register_bcast_state); 165 NTSTATUS status; 166 167 status = nbt_name_register_recv(state->req, state, state->io); 157 static void nbt_name_register_bcast_handler(struct nbt_name_request *subreq); 158 159 /* 160 the async send call for a 4 stage name registration 161 */ 162 _PUBLIC_ struct tevent_req *nbt_name_register_bcast_send(TALLOC_CTX *mem_ctx, 163 struct tevent_context *ev, 164 struct nbt_name_socket *nbtsock, 165 struct nbt_name_register_bcast *io) 166 { 167 struct tevent_req *req; 168 struct nbt_name_register_bcast_state *state; 169 struct nbt_name_request *subreq; 170 171 req = tevent_req_create(mem_ctx, &state, 172 struct nbt_name_register_bcast_state); 173 if (req == NULL) { 174 return NULL; 175 } 176 177 state->io.in.name = io->in.name; 178 state->io.in.dest_addr = io->in.dest_addr; 179 state->io.in.dest_port = io->in.dest_port; 180 state->io.in.address = io->in.address; 181 state->io.in.nb_flags = io->in.nb_flags; 182 state->io.in.register_demand = false; 183 state->io.in.broadcast = true; 184 state->io.in.multi_homed = false; 185 state->io.in.ttl = io->in.ttl; 186 state->io.in.timeout = 1; 187 state->io.in.retries = 2; 188 189 state->nbtsock = nbtsock; 190 191 subreq = nbt_name_register_send(nbtsock, &state->io); 192 if (tevent_req_nomem(subreq, req)) { 193 return tevent_req_post(req, ev); 194 } 195 196 subreq->async.fn = nbt_name_register_bcast_handler; 197 subreq->async.private_data = req; 198 199 return req; 200 } 201 202 static void nbt_name_register_bcast_handler(struct nbt_name_request *subreq) 203 { 204 struct tevent_req *req = 205 talloc_get_type_abort(subreq->async.private_data, 206 struct tevent_req); 207 struct nbt_name_register_bcast_state *state = 208 tevent_req_data(req, 209 struct nbt_name_register_bcast_state); 210 NTSTATUS status; 211 212 status = nbt_name_register_recv(subreq, state, &state->io); 168 213 if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { 169 if (state->io->in.register_demand == true) { 170 /* all done */ 171 c->state = COMPOSITE_STATE_DONE; 172 c->status = NT_STATUS_OK; 173 goto done; 214 if (state->io.in.register_demand == true) { 215 tevent_req_done(req); 216 return; 174 217 } 175 218 176 219 /* the registration timed out - good, send the demand */ 177 state->io->in.register_demand = true; 178 state->io->in.retries = 0; 179 state->req = nbt_name_register_send(state->nbtsock, state->io); 180 if (state->req == NULL) { 181 c->state = COMPOSITE_STATE_ERROR; 182 c->status = NT_STATUS_NO_MEMORY; 183 } else { 184 state->req->async.fn = name_register_bcast_handler; 185 state->req->async.private_data = c; 220 state->io.in.register_demand = true; 221 state->io.in.retries = 0; 222 223 subreq = nbt_name_register_send(state->nbtsock, &state->io); 224 if (tevent_req_nomem(subreq, req)) { 225 return; 186 226 } 187 } else if (!NT_STATUS_IS_OK(status)) { 188 c->state = COMPOSITE_STATE_ERROR; 189 c->status = status; 190 } else { 191 c->state = COMPOSITE_STATE_ERROR; 192 c->status = NT_STATUS_CONFLICTING_ADDRESSES; 193 DEBUG(3,("Name registration conflict from %s for %s with ip %s - rcode %d\n", 194 state->io->out.reply_from, 195 nbt_name_string(state, &state->io->out.name), 196 state->io->out.reply_addr, 197 state->io->out.rcode)); 198 } 199 200 done: 201 if (c->state >= COMPOSITE_STATE_DONE && 202 c->async.fn) { 203 c->async.fn(c); 204 } 205 } 206 207 /* 208 the async send call for a 4 stage name registration 209 */ 210 _PUBLIC_ struct composite_context *nbt_name_register_bcast_send(struct nbt_name_socket *nbtsock, 211 struct nbt_name_register_bcast *io) 212 { 213 struct composite_context *c; 214 struct register_bcast_state *state; 215 216 c = talloc_zero(nbtsock, struct composite_context); 217 if (c == NULL) goto failed; 218 219 state = talloc(c, struct register_bcast_state); 220 if (state == NULL) goto failed; 221 222 state->io = talloc(state, struct nbt_name_register); 223 if (state->io == NULL) goto failed; 224 225 state->io->in.name = io->in.name; 226 state->io->in.dest_addr = io->in.dest_addr; 227 state->io->in.dest_port = io->in.dest_port; 228 state->io->in.address = io->in.address; 229 state->io->in.nb_flags = io->in.nb_flags; 230 state->io->in.register_demand = false; 231 state->io->in.broadcast = true; 232 state->io->in.multi_homed = false; 233 state->io->in.ttl = io->in.ttl; 234 state->io->in.timeout = 1; 235 state->io->in.retries = 2; 236 237 state->nbtsock = nbtsock; 238 239 state->req = nbt_name_register_send(nbtsock, state->io); 240 if (state->req == NULL) goto failed; 241 242 state->req->async.fn = name_register_bcast_handler; 243 state->req->async.private_data = c; 244 245 c->private_data = state; 246 c->state = COMPOSITE_STATE_IN_PROGRESS; 247 c->event_ctx = nbtsock->event_ctx; 248 249 return c; 250 251 failed: 252 talloc_free(c); 253 return NULL; 227 228 subreq->async.fn = nbt_name_register_bcast_handler; 229 subreq->async.private_data = req; 230 return; 231 } 232 233 if (!NT_STATUS_IS_OK(status)) { 234 tevent_req_nterror(req, status); 235 return; 236 } 237 238 DEBUG(3,("Name registration conflict from %s for %s with ip %s - rcode %d\n", 239 state->io.out.reply_from, 240 nbt_name_string(state, &state->io.out.name), 241 state->io.out.reply_addr, 242 state->io.out.rcode)); 243 244 tevent_req_nterror(req, NT_STATUS_CONFLICTING_ADDRESSES); 254 245 } 255 246 … … 257 248 broadcast 4 part name register - recv 258 249 */ 259 _PUBLIC_ NTSTATUS nbt_name_register_bcast_recv(struct composite_context *c) 260 { 261 NTSTATUS status; 262 status = composite_wait(c); 263 talloc_free(c); 264 return status; 250 _PUBLIC_ NTSTATUS nbt_name_register_bcast_recv(struct tevent_req *req) 251 { 252 NTSTATUS status; 253 254 if (tevent_req_is_nterror(req, &status)) { 255 tevent_req_received(req); 256 return status; 257 } 258 259 tevent_req_received(req); 260 return NT_STATUS_OK; 265 261 } 266 262 … … 271 267 struct nbt_name_register_bcast *io) 272 268 { 273 struct composite_context *c = nbt_name_register_bcast_send(nbtsock, io); 274 return nbt_name_register_bcast_recv(c); 269 TALLOC_CTX *frame = talloc_stackframe(); 270 struct tevent_context *ev; 271 struct tevent_req *subreq; 272 NTSTATUS status; 273 274 /* 275 * TODO: create a temporary event context 276 */ 277 ev = nbtsock->event_ctx; 278 279 subreq = nbt_name_register_bcast_send(frame, ev, nbtsock, io); 280 if (subreq == NULL) { 281 talloc_free(frame); 282 return NT_STATUS_NO_MEMORY; 283 } 284 285 if (!tevent_req_poll(subreq, ev)) { 286 status = map_nt_error_from_unix(errno); 287 talloc_free(frame); 288 return status; 289 } 290 291 status = nbt_name_register_bcast_recv(subreq); 292 if (!NT_STATUS_IS_OK(status)) { 293 talloc_free(frame); 294 return status; 295 } 296 297 TALLOC_FREE(frame); 298 return NT_STATUS_OK; 275 299 } 276 300 … … 281 305 reply for each address 282 306 */ 283 struct register_wins_state {307 struct nbt_name_register_wins_state { 284 308 struct nbt_name_socket *nbtsock; 285 struct nbt_name_register *io;286 c onst char **wins_servers;309 struct nbt_name_register io; 310 char **wins_servers; 287 311 uint16_t wins_port; 288 const char **addresses; 289 int address_idx; 290 struct nbt_name_request *req; 312 char **addresses; 313 uint32_t address_idx; 291 314 }; 292 315 316 static void nbt_name_register_wins_handler(struct nbt_name_request *subreq); 317 318 /* 319 the async send call for a multi-server WINS register 320 */ 321 _PUBLIC_ struct tevent_req *nbt_name_register_wins_send(TALLOC_CTX *mem_ctx, 322 struct tevent_context *ev, 323 struct nbt_name_socket *nbtsock, 324 struct nbt_name_register_wins *io) 325 { 326 struct tevent_req *req; 327 struct nbt_name_register_wins_state *state; 328 struct nbt_name_request *subreq; 329 330 req = tevent_req_create(mem_ctx, &state, 331 struct nbt_name_register_wins_state); 332 if (req == NULL) { 333 return NULL; 334 } 335 336 if (io->in.wins_servers == NULL) { 337 tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER); 338 return tevent_req_post(req, ev); 339 } 340 341 if (io->in.wins_servers[0] == NULL) { 342 tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER); 343 return tevent_req_post(req, ev); 344 } 345 346 if (io->in.addresses == NULL) { 347 tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER); 348 return tevent_req_post(req, ev); 349 } 350 351 if (io->in.addresses[0] == NULL) { 352 tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER); 353 return tevent_req_post(req, ev); 354 } 355 356 state->wins_port = io->in.wins_port; 357 state->wins_servers = str_list_copy(state, io->in.wins_servers); 358 if (tevent_req_nomem(state->wins_servers, req)) { 359 return tevent_req_post(req, ev); 360 } 361 362 state->addresses = str_list_copy(state, io->in.addresses); 363 if (tevent_req_nomem(state->addresses, req)) { 364 return tevent_req_post(req, ev); 365 } 366 367 state->io.in.name = io->in.name; 368 state->io.in.dest_addr = state->wins_servers[0]; 369 state->io.in.dest_port = state->wins_port; 370 state->io.in.address = io->in.addresses[0]; 371 state->io.in.nb_flags = io->in.nb_flags; 372 state->io.in.broadcast = false; 373 state->io.in.register_demand = false; 374 state->io.in.multi_homed = (io->in.nb_flags & NBT_NM_GROUP)?false:true; 375 state->io.in.ttl = io->in.ttl; 376 state->io.in.timeout = 3; 377 state->io.in.retries = 2; 378 379 state->nbtsock = nbtsock; 380 state->address_idx = 0; 381 382 subreq = nbt_name_register_send(nbtsock, &state->io); 383 if (tevent_req_nomem(subreq, req)) { 384 return tevent_req_post(req, ev); 385 } 386 387 subreq->async.fn = nbt_name_register_wins_handler; 388 subreq->async.private_data = req; 389 390 return req; 391 } 293 392 294 393 /* 295 394 state handler for WINS multi-homed multi-server name register 296 395 */ 297 static void name_register_wins_handler(struct nbt_name_request *req) 298 { 299 struct composite_context *c = talloc_get_type(req->async.private_data, 300 struct composite_context); 301 struct register_wins_state *state = talloc_get_type(c->private_data, 302 struct register_wins_state); 303 NTSTATUS status; 304 305 status = nbt_name_register_recv(state->req, state, state->io); 396 static void nbt_name_register_wins_handler(struct nbt_name_request *subreq) 397 { 398 struct tevent_req *req = 399 talloc_get_type_abort(subreq->async.private_data, 400 struct tevent_req); 401 struct nbt_name_register_wins_state *state = 402 tevent_req_data(req, 403 struct nbt_name_register_wins_state); 404 NTSTATUS status; 405 406 status = nbt_name_register_recv(subreq, state, &state->io); 306 407 if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { 307 408 /* the register timed out - try the next WINS server */ 308 409 state->wins_servers++; 410 if (state->wins_servers[0] == NULL) { 411 tevent_req_nterror(req, status); 412 return; 413 } 414 309 415 state->address_idx = 0; 310 if (state->wins_servers[0] == NULL) { 311 c->state = COMPOSITE_STATE_ERROR; 312 c->status = status; 313 goto done; 416 state->io.in.dest_addr = state->wins_servers[0]; 417 state->io.in.dest_port = state->wins_port; 418 state->io.in.address = state->addresses[0]; 419 420 subreq = nbt_name_register_send(state->nbtsock, &state->io); 421 if (tevent_req_nomem(subreq, req)) { 422 return; 314 423 } 315 state->io->in.dest_addr = state->wins_servers[0]; 316 state->io->in.dest_port = state->wins_port; 317 state->io->in.address = state->addresses[0]; 318 state->req = nbt_name_register_send(state->nbtsock, state->io); 319 if (state->req == NULL) { 320 c->state = COMPOSITE_STATE_ERROR; 321 c->status = NT_STATUS_NO_MEMORY; 322 } else { 323 state->req->async.fn = name_register_wins_handler; 324 state->req->async.private_data = c; 424 425 subreq->async.fn = nbt_name_register_wins_handler; 426 subreq->async.private_data = req; 427 return; 428 } 429 430 if (!NT_STATUS_IS_OK(status)) { 431 tevent_req_nterror(req, status); 432 return; 433 } 434 435 if (state->io.out.rcode == 0 && 436 state->addresses[state->address_idx+1] != NULL) { 437 /* register our next address */ 438 state->io.in.address = state->addresses[++(state->address_idx)]; 439 440 subreq = nbt_name_register_send(state->nbtsock, &state->io); 441 if (tevent_req_nomem(subreq, req)) { 442 return; 325 443 } 326 } else if (!NT_STATUS_IS_OK(status)) { 327 c->state = COMPOSITE_STATE_ERROR; 328 c->status = status; 329 } else { 330 if (state->io->out.rcode == 0 && 331 state->addresses[state->address_idx+1] != NULL) { 332 /* register our next address */ 333 state->io->in.address = state->addresses[++(state->address_idx)]; 334 state->req = nbt_name_register_send(state->nbtsock, state->io); 335 if (state->req == NULL) { 336 c->state = COMPOSITE_STATE_ERROR; 337 c->status = NT_STATUS_NO_MEMORY; 338 } else { 339 state->req->async.fn = name_register_wins_handler; 340 state->req->async.private_data = c; 341 } 342 } else { 343 c->state = COMPOSITE_STATE_DONE; 344 c->status = NT_STATUS_OK; 345 } 346 } 347 348 done: 349 if (c->state >= COMPOSITE_STATE_DONE && 350 c->async.fn) { 351 c->async.fn(c); 352 } 353 } 354 355 /* 356 the async send call for a multi-server WINS register 357 */ 358 _PUBLIC_ struct composite_context *nbt_name_register_wins_send(struct nbt_name_socket *nbtsock, 359 struct nbt_name_register_wins *io) 360 { 361 struct composite_context *c; 362 struct register_wins_state *state; 363 364 c = talloc_zero(nbtsock, struct composite_context); 365 if (c == NULL) goto failed; 366 367 state = talloc(c, struct register_wins_state); 368 if (state == NULL) goto failed; 369 370 state->io = talloc(state, struct nbt_name_register); 371 if (state->io == NULL) goto failed; 372 373 state->wins_port = io->in.wins_port; 374 state->wins_servers = (const char **)str_list_copy(state, io->in.wins_servers); 375 if (state->wins_servers == NULL || 376 state->wins_servers[0] == NULL) goto failed; 377 378 state->addresses = (const char **)str_list_copy(state, io->in.addresses); 379 if (state->addresses == NULL || 380 state->addresses[0] == NULL) goto failed; 381 382 state->io->in.name = io->in.name; 383 state->io->in.dest_addr = state->wins_servers[0]; 384 state->io->in.dest_port = state->wins_port; 385 state->io->in.address = io->in.addresses[0]; 386 state->io->in.nb_flags = io->in.nb_flags; 387 state->io->in.broadcast = false; 388 state->io->in.register_demand = false; 389 state->io->in.multi_homed = (io->in.nb_flags & NBT_NM_GROUP)?false:true; 390 state->io->in.ttl = io->in.ttl; 391 state->io->in.timeout = 3; 392 state->io->in.retries = 2; 393 394 state->nbtsock = nbtsock; 395 state->address_idx = 0; 396 397 state->req = nbt_name_register_send(nbtsock, state->io); 398 if (state->req == NULL) goto failed; 399 400 state->req->async.fn = name_register_wins_handler; 401 state->req->async.private_data = c; 402 403 c->private_data = state; 404 c->state = COMPOSITE_STATE_IN_PROGRESS; 405 c->event_ctx = nbtsock->event_ctx; 406 407 return c; 408 409 failed: 410 talloc_free(c); 411 return NULL; 444 445 subreq->async.fn = nbt_name_register_wins_handler; 446 subreq->async.private_data = req; 447 return; 448 } 449 450 tevent_req_done(req); 412 451 } 413 452 … … 415 454 multi-homed WINS name register - recv side 416 455 */ 417 _PUBLIC_ NTSTATUS nbt_name_register_wins_recv(struct composite_context *c, TALLOC_CTX *mem_ctx, 418 struct nbt_name_register_wins *io) 419 { 420 NTSTATUS status; 421 status = composite_wait(c); 422 if (NT_STATUS_IS_OK(status)) { 423 struct register_wins_state *state = 424 talloc_get_type(c->private_data, struct register_wins_state); 425 io->out.wins_server = talloc_steal(mem_ctx, state->wins_servers[0]); 426 io->out.rcode = state->io->out.rcode; 427 } 428 talloc_free(c); 429 return status; 456 _PUBLIC_ NTSTATUS nbt_name_register_wins_recv(struct tevent_req *req, 457 TALLOC_CTX *mem_ctx, 458 struct nbt_name_register_wins *io) 459 { 460 struct nbt_name_register_wins_state *state = 461 tevent_req_data(req, 462 struct nbt_name_register_wins_state); 463 NTSTATUS status; 464 465 if (tevent_req_is_nterror(req, &status)) { 466 tevent_req_received(req); 467 return status; 468 } 469 470 io->out.wins_server = talloc_move(mem_ctx, &state->wins_servers[0]); 471 io->out.rcode = state->io.out.rcode; 472 473 tevent_req_received(req); 474 return NT_STATUS_OK; 430 475 } 431 476 … … 437 482 struct nbt_name_register_wins *io) 438 483 { 439 struct composite_context *c = nbt_name_register_wins_send(nbtsock, io); 440 return nbt_name_register_wins_recv(c, mem_ctx, io); 441 } 484 TALLOC_CTX *frame = talloc_stackframe(); 485 struct tevent_context *ev; 486 struct tevent_req *subreq; 487 NTSTATUS status; 488 489 /* 490 * TODO: create a temporary event context 491 */ 492 ev = nbtsock->event_ctx; 493 494 subreq = nbt_name_register_wins_send(frame, ev, nbtsock, io); 495 if (subreq == NULL) { 496 talloc_free(frame); 497 return NT_STATUS_NO_MEMORY; 498 } 499 500 if (!tevent_req_poll(subreq, ev)) { 501 status = map_nt_error_from_unix(errno); 502 talloc_free(frame); 503 return status; 504 } 505 506 status = nbt_name_register_wins_recv(subreq, mem_ctx, io); 507 if (!NT_STATUS_IS_OK(status)) { 508 talloc_free(frame); 509 return status; 510 } 511 512 TALLOC_FREE(frame); 513 return NT_STATUS_OK; 514 } -
trunk/server/libcli/nbt/nbt_proto.h
r414 r745 1 /* 2 Unix SMB/CIFS implementation. 3 4 manipulate nbt name structures 5 6 Copyright (C) Andrew Tridgell 2005 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 3 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 1 22 #ifndef _____LIBCLI_NBT_NBT_PROTO_H__ 2 23 #define _____LIBCLI_NBT_NBT_PROTO_H__ -
trunk/server/libcli/nbt/nbtname.c
r596 r745 28 28 #include "librpc/gen_ndr/ndr_misc.h" 29 29 #include "system/locale.h" 30 #include "lib/util/util_net.h" 30 31 31 32 /* don't allow an unlimited number of name components */ … … 49 50 { 50 51 uint8_t len; 51 u int_t loops = 0;52 unsigned int loops = 0; 52 53 while (loops < 5) { 53 54 if (*offset >= ndr->data_size) { … … 176 177 177 178 /* we need to make sure the length fits into 6 bytes */ 178 if (complen > =0x3F) {179 if (complen > 0x3F) { 179 180 return ndr_push_error(ndr, NDR_ERR_STRING, 180 "component length %u[%08X] > 0x0000 3F",181 "component length %u[%08X] > 0x0000003F", 181 182 (unsigned)complen, (unsigned)complen); 182 183 } … … 383 384 push a nbt name into a blob 384 385 */ 385 _PUBLIC_ NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience,DATA_BLOB *blob, struct nbt_name *name)386 _PUBLIC_ NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct nbt_name *name) 386 387 { 387 388 enum ndr_err_code ndr_err; 388 389 389 ndr_err = ndr_push_struct_blob(blob, mem_ctx, iconv_convenience,name, (ndr_push_flags_fn_t)ndr_push_nbt_name);390 ndr_err = ndr_push_struct_blob(blob, mem_ctx, name, (ndr_push_flags_fn_t)ndr_push_nbt_name); 390 391 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { 391 392 return ndr_map_error2ntstatus(ndr_err); … … 402 403 enum ndr_err_code ndr_err; 403 404 404 ndr_err = ndr_pull_struct_blob(blob, mem_ctx, NULL,name,405 ndr_err = ndr_pull_struct_blob(blob, mem_ctx, name, 405 406 (ndr_pull_flags_fn_t)ndr_pull_nbt_name); 406 407 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 520 521 NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, namebuf, namebuf_len)); 521 522 523 if ((namebuf_len % 4) == 0) { 524 /* 525 * [MS-WINSRA] â v20091104 was wrong 526 * regarding section "2.2.10.1 Name Record" 527 * 528 * If the name buffer is already 4 byte aligned 529 * Windows (at least 2003 SP1 and 2008) add 4 extra 530 * bytes. This can happen when the name has a scope. 531 */ 532 uint32_t pad; 533 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &pad)); 534 } 535 522 536 NDR_PULL_ALLOC(ndr, r); 523 537 … … 548 562 if (!r->name) return ndr_pull_error(ndr, NDR_ERR_ALLOC, "out of memory"); 549 563 550 if (namebuf_len > 1 8) {551 r->scope = talloc_strndup(r, (char *)(namebuf+1 7), namebuf_len-17);564 if (namebuf_len > 17) { 565 r->scope = talloc_strndup(r, (char *)(namebuf+16), namebuf_len-17); 552 566 if (!r->scope) return ndr_pull_error(ndr, NDR_ERR_ALLOC, "out of memory"); 553 567 } else { … … 617 631 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, namebuf_len)); 618 632 NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, namebuf, namebuf_len)); 633 634 if ((namebuf_len % 4) == 0) { 635 /* 636 * [MS-WINSRA] â v20091104 was wrong 637 * regarding section "2.2.10.1 Name Record" 638 * 639 * If the name buffer is already 4 byte aligned 640 * Windows (at least 2003 SP1 and 2008) add 4 extra 641 * bytes. This can happen when the name has a scope. 642 */ 643 NDR_CHECK(ndr_push_zero(ndr, 4)); 644 } 619 645 620 646 talloc_free(namebuf); -
trunk/server/libcli/nbt/nbtsocket.c
r414 r745 192 192 193 193 /* parse the request */ 194 ndr_err = ndr_pull_struct_blob(&blob, packet, nbtsock->iconv_convenience,packet,194 ndr_err = ndr_pull_struct_blob(&blob, packet, packet, 195 195 (ndr_pull_flags_fn_t)ndr_pull_nbt_name_packet); 196 196 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 333 333 */ 334 334 _PUBLIC_ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx, 335 struct tevent_context *event_ctx, 336 struct smb_iconv_convenience *iconv_convenience) 335 struct tevent_context *event_ctx) 337 336 { 338 337 struct nbt_name_socket *nbtsock; … … 342 341 if (nbtsock == NULL) goto failed; 343 342 344 nbtsock->event_ctx = talloc_reference(nbtsock, event_ctx);343 nbtsock->event_ctx = event_ctx; 345 344 if (nbtsock->event_ctx == NULL) goto failed; 346 345 … … 359 358 nbtsock->incoming.handler = NULL; 360 359 nbtsock->unexpected.handler = NULL; 361 nbtsock->iconv_convenience = iconv_convenience;362 360 363 361 nbtsock->fde = event_add_fd(nbtsock->event_ctx, nbtsock, … … 417 415 418 416 ndr_err = ndr_push_struct_blob(&req->encoded, req, 419 req->nbtsock->iconv_convenience,420 417 request, 421 418 (ndr_push_flags_fn_t)ndr_push_nbt_name_packet); … … 466 463 467 464 ndr_err = ndr_push_struct_blob(&req->encoded, req, 468 req->nbtsock->iconv_convenience,469 465 request, 470 466 (ndr_push_flags_fn_t)ndr_push_nbt_name_packet); -
trunk/server/libcli/nbt/pynbt.c
r414 r745 18 18 */ 19 19 20 #include <Python.h> 20 21 #include "includes.h" 21 #include <Python.h>22 22 #include "libcli/util/pyerrors.h" 23 23 #include "scripting/python/modules.h" … … 25 25 #include "lib/events/events.h" 26 26 27 void initnetbios(void); 28 27 29 #ifndef Py_RETURN_NONE 28 30 #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None 29 31 #endif 30 32 31 PyAPI_DATA(PyTypeObject)nbt_node_Type;33 extern PyTypeObject nbt_node_Type; 32 34 33 35 typedef struct { … … 37 39 } nbt_node_Object; 38 40 39 static void py_nbt_node_dealloc( PyObject *obj)40 { 41 talloc_free( ((nbt_node_Object *)obj)->mem_ctx);42 PyObject_Del(obj);41 static void py_nbt_node_dealloc(nbt_node_Object *self) 42 { 43 talloc_free(self->mem_ctx); 44 self->ob_type->tp_free(self); 43 45 } 44 46 … … 53 55 54 56 ev = s4_event_context_init(ret->mem_ctx); 55 ret->socket = nbt_name_socket_init(ret->mem_ctx, ev , py_iconv_convenience(ret->mem_ctx));57 ret->socket = nbt_name_socket_init(ret->mem_ctx, ev); 56 58 return (PyObject *)ret; 57 59 } … … 125 127 } 126 128 127 static PyObject *PyObject_FromNBTName(struct nbt_name_socket *name_socket, struct smb_iconv_convenience *ic,129 static PyObject *PyObject_FromNBTName(struct nbt_name_socket *name_socket, 128 130 struct nbt_name *name) 129 131 { … … 176 178 PyTuple_SetItem(ret, 0, PyString_FromString(io.out.reply_from)); 177 179 178 py_name = PyObject_FromNBTName(node->socket, py_iconv_convenience(node->socket),&io.out.name);180 py_name = PyObject_FromNBTName(node->socket, &io.out.name); 179 181 if (py_name == NULL) 180 182 return NULL; … … 234 236 PyTuple_SetItem(ret, 0, PyString_FromString(io.out.reply_from)); 235 237 236 py_name = PyObject_FromNBTName(node->socket, py_iconv_convenience(NULL),&io.out.name);238 py_name = PyObject_FromNBTName(node->socket, &io.out.name); 237 239 if (py_name == NULL) 238 240 return NULL; … … 297 299 PyTuple_SetItem(ret, 0, PyString_FromString(io.out.reply_from)); 298 300 299 py_name = PyObject_FromNBTName(node->socket, py_iconv_convenience(NULL),&io.out.name);301 py_name = PyObject_FromNBTName(node->socket, &io.out.name); 300 302 if (py_name == NULL) 301 303 return NULL; … … 352 354 PyTuple_SetItem(ret, 0, PyString_FromString(io.out.reply_from)); 353 355 354 py_name = PyObject_FromNBTName(node->socket, py_iconv_convenience(NULL),&io.out.name);356 py_name = PyObject_FromNBTName(node->socket, &io.out.name); 355 357 if (py_name == NULL) 356 358 return NULL; … … 394 396 .tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, 395 397 .tp_new = py_nbt_node_init, 396 .tp_dealloc = py_nbt_node_dealloc,398 .tp_dealloc = (destructor)py_nbt_node_dealloc, 397 399 .tp_methods = py_nbt_methods, 398 400 .tp_doc = "Node()\n" -
trunk/server/libcli/nbt/tools/nmblookup.c
r414 r745 213 213 } 214 214 215 nbtsock = nbt_name_socket_init(tmp_ctx, ev , lp_iconv_convenience(lp_ctx));215 nbtsock = nbt_name_socket_init(tmp_ctx, ev); 216 216 217 217 if (options.root_port) { … … 358 358 } 359 359 360 load_interfaces(NULL, lp _interfaces(cmdline_lp_ctx), &ifaces);360 load_interfaces(NULL, lpcfg_interfaces(cmdline_lp_ctx), &ifaces); 361 361 362 362 ev = s4_event_context_init(talloc_autofree_context()); … … 365 365 const char *name = poptGetArg(pc); 366 366 367 ret &= process_one(cmdline_lp_ctx, ev, ifaces, name, lp _nbt_port(cmdline_lp_ctx));367 ret &= process_one(cmdline_lp_ctx, ev, ifaces, name, lpcfg_nbt_port(cmdline_lp_ctx)); 368 368 } 369 369
Note:
See TracChangeset
for help on using the changeset viewer.