summaryrefslogtreecommitdiff
path: root/source3/nmbd/nmbd_packets.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/nmbd/nmbd_packets.c')
-rw-r--r--source3/nmbd/nmbd_packets.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c
index 36dacfb6f3..a89f49c8fc 100644
--- a/source3/nmbd/nmbd_packets.c
+++ b/source3/nmbd/nmbd_packets.c
@@ -23,6 +23,7 @@
#include "nmbd/nmbd.h"
#include "../lib/util/select.h"
#include "system/select.h"
+#include "libsmb/libsmb.h"
extern int ClientNMB;
extern int ClientDGRAM;
@@ -108,7 +109,7 @@ void set_nb_flags(char *buf, uint16 nb_flags)
Dumps out the browse packet data.
**************************************************************************/
-static void debug_browse_data(char *outbuf, int len)
+static void debug_browse_data(const char *outbuf, int len)
{
int i,j;
@@ -1062,7 +1063,7 @@ static struct subnet_record *find_subnet_for_dgram_browse_packet(struct packet_s
Dispatch a browse frame from port 138 to the correct processing function.
****************************************************************************/
-static void process_browse_packet(struct packet_struct *p, char *buf,int len)
+static void process_browse_packet(struct packet_struct *p, const char *buf,int len)
{
struct dgram_packet *dgram = &p->packet.dgram;
int command = CVAL(buf,0);
@@ -1072,9 +1073,9 @@ static void process_browse_packet(struct packet_struct *p, char *buf,int len)
/* Drop the packet if it's a different NetBIOS scope, or the source is from one of our names. */
pull_ascii(scope, dgram->dest_name.scope, 64, 64, STR_TERMINATE);
- if (!strequal(scope, global_scope())) {
+ if (!strequal(scope, lp_netbios_scope())) {
DEBUG(7,("process_browse_packet: Discarding datagram from IP %s. Scope (%s) \
-mismatch with our scope (%s).\n", inet_ntoa(p->ip), scope, global_scope()));
+mismatch with our scope (%s).\n", inet_ntoa(p->ip), scope, lp_netbios_scope()));
return;
}
@@ -1149,7 +1150,7 @@ command code %d from %s IP %s to %s\n", subrec->subnet_name, command, nmb_namest
Dispatch a LanMan browse frame from port 138 to the correct processing function.
****************************************************************************/
-static void process_lanman_packet(struct packet_struct *p, char *buf,int len)
+static void process_lanman_packet(struct packet_struct *p, const char *buf,int len)
{
struct dgram_packet *dgram = &p->packet.dgram;
int command = SVAL(buf,0);
@@ -1160,9 +1161,9 @@ static void process_lanman_packet(struct packet_struct *p, char *buf,int len)
/* Drop the packet if it's a different NetBIOS scope, or the source is from one of our names. */
pull_ascii(scope, dgram->dest_name.scope, 64, 64, STR_TERMINATE);
- if (!strequal(scope, global_scope())) {
+ if (!strequal(scope, lp_netbios_scope())) {
DEBUG(7,("process_lanman_packet: Discarding datagram from IP %s. Scope (%s) \
-mismatch with our scope (%s).\n", inet_ntoa(p->ip), scope, global_scope()));
+mismatch with our scope (%s).\n", inet_ntoa(p->ip), scope, lp_netbios_scope()));
return;
}
@@ -1216,8 +1217,8 @@ static bool listening(struct packet_struct *p,struct nmb_name *nbname)
static void process_dgram(struct packet_struct *p)
{
- char *buf;
- char *buf2;
+ const char *buf;
+ const char *buf2;
int len;
struct dgram_packet *dgram = &p->packet.dgram;
@@ -1290,28 +1291,28 @@ packet sent to name %s from IP %s\n",
DEBUG(4,("process_dgram: datagram from %s to %s IP %s for %s of type %d len=%d\n",
nmb_namestr(&dgram->source_name),nmb_namestr(&dgram->dest_name),
- inet_ntoa(p->ip), smb_buf(buf),CVAL(buf2,0),len));
+ inet_ntoa(p->ip), smb_buf_const(buf),CVAL(buf2,0),len));
/* Datagram packet received for the browser mailslot */
- if (strequal(smb_buf(buf),BROWSE_MAILSLOT)) {
+ if (strequal(smb_buf_const(buf),BROWSE_MAILSLOT)) {
process_browse_packet(p,buf2,len);
return;
}
/* Datagram packet received for the LAN Manager mailslot */
- if (strequal(smb_buf(buf),LANMAN_MAILSLOT)) {
+ if (strequal(smb_buf_const(buf),LANMAN_MAILSLOT)) {
process_lanman_packet(p,buf2,len);
return;
}
/* Datagram packet received for the domain logon mailslot */
- if (strequal(smb_buf(buf),NET_LOGON_MAILSLOT)) {
+ if (strequal(smb_buf_const(buf),NET_LOGON_MAILSLOT)) {
process_logon_packet(p,buf2,len,NET_LOGON_MAILSLOT);
return;
}
/* Datagram packet received for the NT domain logon mailslot */
- if (strequal(smb_buf(buf),NT_LOGON_MAILSLOT)) {
+ if (strequal(smb_buf_const(buf),NT_LOGON_MAILSLOT)) {
process_logon_packet(p,buf2,len,NT_LOGON_MAILSLOT);
return;
}
@@ -1706,14 +1707,14 @@ static bool create_listen_pollfds(struct pollfd **pfds,
}
}
- fds = TALLOC_ZERO_ARRAY(NULL, struct pollfd, count);
+ fds = talloc_zero_array(NULL, struct pollfd, count);
if (fds == NULL) {
DEBUG(1, ("create_listen_pollfds: malloc fail for fds. "
"size %d\n", count));
return true;
}
- attrs = TALLOC_ARRAY(NULL, struct socket_attributes, count);
+ attrs = talloc_array(NULL, struct socket_attributes, count);
if (fds == NULL) {
DEBUG(1, ("create_listen_pollfds: malloc fail for attrs. "
"size %d\n", count));
@@ -1884,7 +1885,7 @@ bool listen_for_packets(bool run_election)
* create_listen_pollfds.
*/
- fds = TALLOC_REALLOC_ARRAY(NULL, fds, struct pollfd, listen_number);
+ fds = talloc_realloc(NULL, fds, struct pollfd, listen_number);
if (fds == NULL) {
return true;
}
@@ -1893,7 +1894,7 @@ bool listen_for_packets(bool run_election)
#ifndef SYNC_DNS
dns_fd = asyncdns_fd();
if (dns_fd != -1) {
- fds = TALLOC_REALLOC_ARRAY(NULL, fds, struct pollfd, num_sockets+1);
+ fds = talloc_realloc(NULL, fds, struct pollfd, num_sockets+1);
if (fds == NULL) {
return true;
}
@@ -2087,7 +2088,7 @@ bool send_mailslot(bool unique, const char *mailslot,char *buf, size_t len,
SSVAL(ptr,smb_vwv15,1);
SSVAL(ptr,smb_vwv16,2);
p2 = smb_buf(ptr);
- safe_strcpy_base(p2, mailslot, dgram->data, sizeof(dgram->data));
+ strlcpy_base(p2, mailslot, dgram->data, sizeof(dgram->data));
p2 = skip_string(ptr,MAX_DGRAM_SIZE,p2);
if (((p2+len) > dgram->data+sizeof(dgram->data)) || ((p2+len) < p2)) {