Example #1
0
/*
  push a string into the data portion of the request packet, growing it if necessary
  this gets quite tricky - please be very careful to cover all cases when modifying this

  if dest is NULL, then put the string at the end of the data portion of the packet

  if dest_len is -1 then no limit applies
*/
size_t smbcli_req_append_ascii4(struct smbcli_request *req, const char *str, unsigned int flags)
{
	size_t size;
	smbcli_req_append_bytes(req, (const uint8_t *)"\4", 1);
	size = smbcli_req_append_string(req, str, flags);
	return size + 1;
}
Example #2
0
/*
  Send a negprot command.
*/
struct smbcli_request *smb_raw_negotiate_send(struct smbcli_transport *transport, 
					      bool unicode,
					      int maxprotocol)
{
	struct smbcli_request *req;
	int i;
	uint16_t flags2 = 0;

	req = smbcli_request_setup_transport(transport, SMBnegprot, 0, 0);
	if (!req) {
		return NULL;
	}

	flags2 |= FLAGS2_32_BIT_ERROR_CODES;
	if (unicode) {
		flags2 |= FLAGS2_UNICODE_STRINGS;
	}
	flags2 |= FLAGS2_EXTENDED_ATTRIBUTES;
	flags2 |= FLAGS2_LONG_PATH_COMPONENTS;
	flags2 |= FLAGS2_IS_LONG_NAME;

	if (transport->options.use_spnego) {
		flags2 |= FLAGS2_EXTENDED_SECURITY;
	}

	SSVAL(req->out.hdr,HDR_FLG2, flags2);

	/* setup the protocol strings */
	for (i=0; i < ARRAY_SIZE(prots) && prots[i].prot <= maxprotocol; i++) {
		smbcli_req_append_bytes(req, (const uint8_t *)"\2", 1);
		smbcli_req_append_string(req, prots[i].name, STR_TERMINATE | STR_ASCII);
	}

	if (!smbcli_request_send(req)) {
		smbcli_request_destroy(req);
		return NULL;
	}

	return req;
}