Changeset 988 for vendor/current/libcli/nbt
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- Location:
- vendor/current/libcli/nbt
- Files:
-
- 1 added
- 2 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/libcli/nbt/libnbt.h
r740 r988 25 25 #include "librpc/gen_ndr/nbt.h" 26 26 #include "librpc/ndr/libndr.h" 27 #include "system/network.h" 27 #include "lib/util/xfile.h" 28 28 29 /* 29 30 possible states for pending requests … … 335 336 336 337 337 NDR_SCALAR_PROTO(wrepl_nbt_name, const struct nbt_name *) 338 NDR_SCALAR_PROTO(nbt_string, const char *) 338 NDR_SCALAR_PTR_PROTO(wrepl_nbt_name, struct nbt_name) 339 339 NDR_BUFFER_PROTO(nbt_name, struct nbt_name) 340 340 NTSTATUS nbt_rcode_to_ntstatus(uint8_t rcode); … … 373 373 int *return_count); 374 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 381 375 #endif /* __LIBNBT_H__ */ -
vendor/current/libcli/nbt/namerefresh.c
r740 r988 332 332 333 333 if (!tevent_req_poll(subreq, ev)) { 334 status = map_nt_error_from_unix (errno);334 status = map_nt_error_from_unix_common(errno); 335 335 talloc_free(frame); 336 336 return status; -
vendor/current/libcli/nbt/nameregister.c
r740 r988 284 284 285 285 if (!tevent_req_poll(subreq, ev)) { 286 status = map_nt_error_from_unix (errno);286 status = map_nt_error_from_unix_common(errno); 287 287 talloc_free(frame); 288 288 return status; … … 499 499 500 500 if (!tevent_req_poll(subreq, ev)) { 501 status = map_nt_error_from_unix (errno);501 status = map_nt_error_from_unix_common(errno); 502 502 talloc_free(frame); 503 503 return status; -
vendor/current/libcli/nbt/nbtname.c
r740 r988 29 29 #include "system/locale.h" 30 30 #include "lib/util/util_net.h" 31 32 /* don't allow an unlimited number of name components */ 33 #define MAX_COMPONENTS 10 34 35 /** 36 print a nbt string 37 */ 38 _PUBLIC_ void ndr_print_nbt_string(struct ndr_print *ndr, const char *name, const char *s) 39 { 40 ndr_print_string(ndr, name, s); 41 } 42 43 /* 44 pull one component of a nbt_string 45 */ 46 static enum ndr_err_code ndr_pull_component(struct ndr_pull *ndr, 47 uint8_t **component, 48 uint32_t *offset, 49 uint32_t *max_offset) 50 { 51 uint8_t len; 52 unsigned int loops = 0; 53 while (loops < 5) { 54 if (*offset >= ndr->data_size) { 55 return ndr_pull_error(ndr, NDR_ERR_STRING, 56 "BAD NBT NAME component"); 57 } 58 len = ndr->data[*offset]; 59 if (len == 0) { 60 *offset += 1; 61 *max_offset = MAX(*max_offset, *offset); 62 *component = NULL; 63 return NDR_ERR_SUCCESS; 64 } 65 if ((len & 0xC0) == 0xC0) { 66 /* its a label pointer */ 67 if (1 + *offset >= ndr->data_size) { 68 return ndr_pull_error(ndr, NDR_ERR_STRING, 69 "BAD NBT NAME component"); 70 } 71 *max_offset = MAX(*max_offset, *offset + 2); 72 *offset = ((len&0x3F)<<8) | ndr->data[1 + *offset]; 73 *max_offset = MAX(*max_offset, *offset); 74 loops++; 75 continue; 76 } 77 if ((len & 0xC0) != 0) { 78 /* its a reserved length field */ 79 return ndr_pull_error(ndr, NDR_ERR_STRING, 80 "BAD NBT NAME component"); 81 } 82 if (*offset + len + 2 > ndr->data_size) { 83 return ndr_pull_error(ndr, NDR_ERR_STRING, 84 "BAD NBT NAME component"); 85 } 86 *component = (uint8_t*)talloc_strndup( 87 ndr->current_mem_ctx, 88 (const char *)&ndr->data[1 + *offset], len); 89 NDR_ERR_HAVE_NO_MEMORY(*component); 90 *offset += len + 1; 91 *max_offset = MAX(*max_offset, *offset); 92 return NDR_ERR_SUCCESS; 93 } 94 95 /* too many pointers */ 96 return ndr_pull_error(ndr, NDR_ERR_STRING, "BAD NBT NAME component"); 97 } 98 99 /** 100 pull a nbt_string from the wire 101 */ 102 _PUBLIC_ enum ndr_err_code ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_flags, const char **s) 103 { 104 uint32_t offset = ndr->offset; 105 uint32_t max_offset = offset; 106 unsigned num_components; 107 char *name; 108 109 if (!(ndr_flags & NDR_SCALARS)) { 110 return NDR_ERR_SUCCESS; 111 } 112 113 name = NULL; 114 115 /* break up name into a list of components */ 116 for (num_components=0;num_components<MAX_COMPONENTS;num_components++) { 117 uint8_t *component = NULL; 118 NDR_CHECK(ndr_pull_component(ndr, &component, &offset, &max_offset)); 119 if (component == NULL) break; 120 if (name) { 121 name = talloc_asprintf_append_buffer(name, ".%s", component); 122 NDR_ERR_HAVE_NO_MEMORY(name); 123 } else { 124 name = (char *)component; 125 } 126 } 127 if (num_components == MAX_COMPONENTS) { 128 return ndr_pull_error(ndr, NDR_ERR_STRING, 129 "BAD NBT NAME too many components"); 130 } 131 if (num_components == 0) { 132 name = talloc_strdup(ndr->current_mem_ctx, ""); 133 NDR_ERR_HAVE_NO_MEMORY(name); 134 } 135 136 (*s) = name; 137 ndr->offset = max_offset; 138 139 return NDR_ERR_SUCCESS; 140 } 141 142 /** 143 push a nbt string to the wire 144 */ 145 _PUBLIC_ enum ndr_err_code ndr_push_nbt_string(struct ndr_push *ndr, int ndr_flags, const char *s) 146 { 147 if (!(ndr_flags & NDR_SCALARS)) { 148 return NDR_ERR_SUCCESS; 149 } 150 151 while (s && *s) { 152 enum ndr_err_code ndr_err; 153 char *compname; 154 size_t complen; 155 uint32_t offset; 156 157 /* see if we have pushed the remaing string allready, 158 * if so we use a label pointer to this string 159 */ 160 ndr_err = ndr_token_retrieve_cmp_fn(&ndr->nbt_string_list, s, &offset, (comparison_fn_t)strcmp, false); 161 if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { 162 uint8_t b[2]; 163 164 if (offset > 0x3FFF) { 165 return ndr_push_error(ndr, NDR_ERR_STRING, 166 "offset for nbt string label pointer %u[%08X] > 0x00003FFF", 167 offset, offset); 168 } 169 170 b[0] = 0xC0 | (offset>>8); 171 b[1] = (offset & 0xFF); 172 173 return ndr_push_bytes(ndr, b, 2); 174 } 175 176 complen = strcspn(s, "."); 177 178 /* we need to make sure the length fits into 6 bytes */ 179 if (complen > 0x3F) { 180 return ndr_push_error(ndr, NDR_ERR_STRING, 181 "component length %u[%08X] > 0x0000003F", 182 (unsigned)complen, (unsigned)complen); 183 } 184 185 compname = talloc_asprintf(ndr, "%c%*.*s", 186 (unsigned char)complen, 187 (unsigned char)complen, 188 (unsigned char)complen, s); 189 NDR_ERR_HAVE_NO_MEMORY(compname); 190 191 /* remember the current componemt + the rest of the string 192 * so it can be reused later 193 */ 194 NDR_CHECK(ndr_token_store(ndr, &ndr->nbt_string_list, s, ndr->offset)); 195 196 /* push just this component into the blob */ 197 NDR_CHECK(ndr_push_bytes(ndr, (const uint8_t *)compname, complen+1)); 198 talloc_free(compname); 199 200 s += complen; 201 if (*s == '.') s++; 202 } 203 204 /* if we reach the end of the string and have pushed the last component 205 * without using a label pointer, we need to terminate the string 206 */ 207 return ndr_push_bytes(ndr, (const uint8_t *)"", 1); 208 } 209 31 #include "libcli/nbt/libnbt.h" 210 32 211 33 /* … … 503 325 pull a nbt name, WINS Replication uses another on wire format for nbt name 504 326 */ 505 _PUBLIC_ enum ndr_err_code ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, conststruct nbt_name **_r)327 _PUBLIC_ enum ndr_err_code ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt_name **_r) 506 328 { 507 329 struct nbt_name *r; -
vendor/current/libcli/nbt/nbtsocket.c
r740 r988 51 51 } 52 52 if (req->nbtsock->send_queue == NULL) { 53 EVENT_FD_NOT_WRITEABLE(req->nbtsock->fde);53 TEVENT_FD_NOT_WRITEABLE(req->nbtsock->fde); 54 54 } 55 55 if (req->nbtsock->num_pending == 0 && 56 56 req->nbtsock->incoming.handler == NULL) { 57 EVENT_FD_NOT_READABLE(req->nbtsock->fde);57 TEVENT_FD_NOT_READABLE(req->nbtsock->fde); 58 58 } 59 59 return 0; … … 88 88 talloc_free(req); 89 89 } else { 90 EVENT_FD_READABLE(nbtsock->fde);90 TEVENT_FD_READABLE(nbtsock->fde); 91 91 nbtsock->num_pending++; 92 92 } 93 93 } 94 94 95 EVENT_FD_NOT_WRITEABLE(nbtsock->fde);95 TEVENT_FD_NOT_WRITEABLE(nbtsock->fde); 96 96 talloc_free(tmp_ctx); 97 97 return; … … 123 123 if (req->num_retries != 0) { 124 124 req->num_retries--; 125 req->te = event_add_timed(req->nbtsock->event_ctx, req,126 timeval_add(&t, req->timeout, 0),127 nbt_name_socket_timeout, req);125 req->te = tevent_add_timer(req->nbtsock->event_ctx, req, 126 timeval_add(&t, req->timeout, 0), 127 nbt_name_socket_timeout, req); 128 128 if (req->state != NBT_REQUEST_SEND) { 129 129 req->state = NBT_REQUEST_SEND; 130 DLIST_ADD_END(req->nbtsock->send_queue, req, 131 struct nbt_name_request *); 132 } 133 EVENT_FD_WRITEABLE(req->nbtsock->fde); 130 DLIST_ADD_END(req->nbtsock->send_queue, req); 131 } 132 TEVENT_FD_WRITEABLE(req->nbtsock->fde); 134 133 return; 135 134 } … … 274 273 } 275 274 req->timeout = ttl; 276 req->te = event_add_timed(req->nbtsock->event_ctx, req,277 timeval_current_ofs(req->timeout, 0),278 nbt_name_socket_timeout, req);275 req->te = tevent_add_timer(req->nbtsock->event_ctx, req, 276 timeval_current_ofs(req->timeout, 0), 277 nbt_name_socket_timeout, req); 279 278 return; 280 279 } … … 319 318 struct nbt_name_socket *nbtsock = talloc_get_type(private_data, 320 319 struct nbt_name_socket); 321 if (flags & EVENT_FD_WRITE) {320 if (flags & TEVENT_FD_WRITE) { 322 321 nbt_name_socket_send(nbtsock); 323 322 } 324 if (flags & EVENT_FD_READ) {323 if (flags & TEVENT_FD_READ) { 325 324 nbt_name_socket_recv(nbtsock); 326 325 } … … 359 358 nbtsock->unexpected.handler = NULL; 360 359 361 nbtsock->fde = event_add_fd(nbtsock->event_ctx, nbtsock,362 socket_get_fd(nbtsock->sock), 0,363 nbt_name_socket_handler, nbtsock);360 nbtsock->fde = tevent_add_fd(nbtsock->event_ctx, nbtsock, 361 socket_get_fd(nbtsock->sock), 0, 362 nbt_name_socket_handler, nbtsock); 364 363 365 364 return nbtsock; … … 408 407 req->name_trn_id = id; 409 408 410 req->te = event_add_timed(nbtsock->event_ctx, req,411 timeval_current_ofs(req->timeout, 0),412 nbt_name_socket_timeout, req);409 req->te = tevent_add_timer(nbtsock->event_ctx, req, 410 timeval_current_ofs(req->timeout, 0), 411 nbt_name_socket_timeout, req); 413 412 414 413 talloc_set_destructor(req, nbt_name_request_destructor); … … 419 418 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) goto failed; 420 419 421 DLIST_ADD_END(nbtsock->send_queue, req , struct nbt_name_request *);420 DLIST_ADD_END(nbtsock->send_queue, req); 422 421 423 422 if (DEBUGLVL(10)) { … … 427 426 } 428 427 429 EVENT_FD_WRITEABLE(nbtsock->fde);428 TEVENT_FD_WRITEABLE(nbtsock->fde); 430 429 431 430 return req; … … 470 469 } 471 470 472 DLIST_ADD_END(nbtsock->send_queue, req , struct nbt_name_request *);473 474 EVENT_FD_WRITEABLE(nbtsock->fde);471 DLIST_ADD_END(nbtsock->send_queue, req); 472 473 TEVENT_FD_WRITEABLE(nbtsock->fde); 475 474 476 475 return NT_STATUS_OK; … … 489 488 490 489 while (req->state < NBT_REQUEST_DONE) { 491 if ( event_loop_once(req->nbtsock->event_ctx) != 0) {490 if (tevent_loop_once(req->nbtsock->event_ctx) != 0) { 492 491 req->state = NBT_REQUEST_ERROR; 493 492 req->status = NT_STATUS_UNEXPECTED_NETWORK_ERROR; … … 509 508 nbtsock->incoming.handler = handler; 510 509 nbtsock->incoming.private_data = private_data; 511 EVENT_FD_READABLE(nbtsock->fde);510 TEVENT_FD_READABLE(nbtsock->fde); 512 511 return NT_STATUS_OK; 513 512 } … … 523 522 nbtsock->unexpected.handler = handler; 524 523 nbtsock->unexpected.private_data = private_data; 525 EVENT_FD_READABLE(nbtsock->fde);524 TEVENT_FD_READABLE(nbtsock->fde); 526 525 return NT_STATUS_OK; 527 526 } -
vendor/current/libcli/nbt/pynbt.c
r740 r988 21 21 #include "includes.h" 22 22 #include "libcli/util/pyerrors.h" 23 #include " scripting/python/modules.h"23 #include "python/modules.h" 24 24 #include "../libcli/nbt/libnbt.h" 25 25 #include "lib/events/events.h" 26 26 27 27 void initnetbios(void); 28 29 #ifndef Py_RETURN_NONE30 #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None31 #endif32 28 33 29 extern PyTypeObject nbt_node_Type; -
vendor/current/libcli/nbt/tools/nmblookup.c
r740 r988 33 33 #include "param/param.h" 34 34 35 #include <string.h> 36 37 #define MAX_NETBIOSNAME_LEN 16 38 35 39 /* command line options */ 36 40 static struct { … … 191 195 struct nbt_name_socket *nbtsock; 192 196 NTSTATUS status = NT_STATUS_OK; 197 size_t nbt_len; 193 198 bool ret = true; 194 199 … … 211 216 } else { 212 217 node_name = talloc_strdup(tmp_ctx, name); 218 } 219 220 nbt_len = strlen(node_name); 221 if (nbt_len > MAX_NETBIOSNAME_LEN - 1) { 222 printf("The specified netbios name [%s] is too long.\n", 223 node_name); 224 talloc_free(tmp_ctx); 225 return false; 213 226 } 214 227 … … 247 260 int i, num_interfaces; 248 261 249 num_interfaces = iface_ count(ifaces);262 num_interfaces = iface_list_count(ifaces); 250 263 for (i=0;i<num_interfaces;i++) { 251 const char *bcast = iface_ n_bcast(ifaces, i);264 const char *bcast = iface_list_n_bcast(ifaces, i); 252 265 if (bcast == NULL) continue; 253 266 status = do_node_query(nbtsock, bcast, nbt_port, … … 358 371 } 359 372 360 load_interface s(NULL, lpcfg_interfaces(cmdline_lp_ctx), &ifaces);373 load_interface_list(NULL, cmdline_lp_ctx, &ifaces); 361 374 362 375 ev = s4_event_context_init(talloc_autofree_context()); -
vendor/current/libcli/nbt/wscript_build
r740 r988 12 12 ) 13 13 14 if bld.env._SAMBA_BUILD_ == 4: 15 bld.SAMBA_LIBRARY('cli-nbt', 16 source='nbtsocket.c namequery.c nameregister.c namerefresh.c namerelease.c dns_hosts_file.c', 17 public_deps='ndr NDR_NBT tevent UTIL_TEVENT NDR_SECURITY samba_socket samba-util lmhosts', 18 private_library=True 19 ) 14 bld.SAMBA_LIBRARY('cli-nbt', 15 source='nbtsocket.c namequery.c nameregister.c namerefresh.c namerelease.c', 16 public_deps='ndr ndr_nbt tevent tevent-util NDR_SECURITY samba_socket samba-util lmhosts', 17 private_library=True 18 ) 20 19 21 bld.SAMBA_BINARY('nmblookup', 22 source='tools/nmblookup.c', 23 manpages='man/nmblookup.1', 24 deps='samba-hostconfig samba-util cli-nbt popt POPT_SAMBA netif LIBCLI_RESOLVE' 25 ) 20 bld.SAMBA_BINARY('nmblookup' + bld.env.suffix4, 21 source='tools/nmblookup.c', 22 manpages='man/nmblookup4.1', 23 deps='samba-hostconfig samba-util cli-nbt popt POPT_SAMBA netif LIBCLI_RESOLVE', 24 install=False 25 ) 26 26 27 28 29 30 31 27 bld.SAMBA_PYTHON('python_netbios', 28 source='pynbt.c', 29 public_deps='cli-nbt DYNCONFIG samba-hostconfig', 30 realname='samba/netbios.so' 31 ) 32 32
Note:
See TracChangeset
for help on using the changeset viewer.