*/
#include "includes.h"
+#include "nmbd/nmbd.h"
/****************************************************************************
Send a name release response.
struct in_addr owner_ip;
struct nmb_name *question = &nmb->question.question_name;
unstring qname;
- BOOL bcast = nmb->header.nm_flags.bcast;
+ bool bcast = nmb->header.nm_flags.bcast;
uint16 nb_flags = get_nb_flags(nmb->additional->rdata);
- BOOL group = (nb_flags & NB_GROUP) ? True : False;
+ bool group = (nb_flags & NB_GROUP) ? True : False;
struct name_record *namerec;
int rcode = 0;
subrec->subnet_name, inet_ntoa(owner_ip)));
/* If someone is releasing a broadcast group name, just ignore it. */
- if( group && !ismyip(owner_ip) )
+ if( group && !ismyip_v4(owner_ip) )
return;
/*
*/
pull_ascii_nstring(qname, sizeof(qname), question->name);
- if( !group && !ismyip(owner_ip) && strequal(qname, lp_workgroup()) &&
+ if( !group && !ismyip_v4(owner_ip) && strequal(qname, lp_workgroup()) &&
((question->name_type == 0x0) || (question->name_type == 0x1e))) {
DEBUG(6,("process_name_release_request: FTP OnNet bug workaround. Ignoring \
group release name %s from IP %s on subnet %s with no group bit set.\n",
{
struct nmb_packet *nmb = &p->packet.nmb;
struct nmb_name *question = &nmb->question.question_name;
- BOOL bcast = nmb->header.nm_flags.bcast;
+ bool bcast = nmb->header.nm_flags.bcast;
struct in_addr from_ip;
putip((char *)&from_ip,&nmb->additional->rdata[2]);
{
struct nmb_packet *nmb = &p->packet.nmb;
struct nmb_name *question = &nmb->question.question_name;
- BOOL bcast = nmb->header.nm_flags.bcast;
+ bool bcast = nmb->header.nm_flags.bcast;
uint16 nb_flags = get_nb_flags(nmb->additional->rdata);
- BOOL group = (nb_flags & NB_GROUP) ? True : False;
+ bool group = (nb_flags & NB_GROUP) ? True : False;
struct name_record *namerec = NULL;
int ttl = nmb->additional->ttl;
struct in_addr from_ip;
;
for (l2=0;l2<15 && n2[l2] && n2[l2] != ' ';l2++)
;
- l3 = strlen(global_myname());
+ l3 = strlen(lp_netbios_name());
- if ((l1==l3) && strncmp(n1,global_myname(),l3) == 0 &&
- (l2!=l3 || strncmp(n2,global_myname(),l3) != 0))
+ if ((l1==l3) && strncmp(n1,lp_netbios_name(),l3) == 0 &&
+ (l2!=l3 || strncmp(n2,lp_netbios_name(),l3) != 0))
return -1;
- if ((l2==l3) && strncmp(n2,global_myname(),l3) == 0 &&
- (l1!=l3 || strncmp(n1,global_myname(),l3) != 0))
+ if ((l2==l3) && strncmp(n2,lp_netbios_name(),l3) == 0 &&
+ (l1!=l3 || strncmp(n1,lp_netbios_name(),l3) != 0))
return 1;
return memcmp(n1,n2,sizeof(name1));
char rdata[MAX_DGRAM_SIZE];
char *countptr, *buf, *bufend, *buf0;
int names_added,i;
- struct name_record *namerec;
+ struct name_record *namerec = NULL;
pull_ascii_nstring(qname, sizeof(qname), nmb->question.question_name.name);
DEBUG(3,("process_node_status_request: status request for name %s from IP %s on \
subnet %s.\n", nmb_namestr(&nmb->question.question_name), inet_ntoa(p->ip), subrec->subnet_name));
- if((namerec = find_name_on_subnet(subrec, &nmb->question.question_name, FIND_SELF_NAME)) == 0) {
+ if(find_name_on_subnet(subrec, &nmb->question.question_name, FIND_SELF_NAME) == 0) {
DEBUG(1,("process_node_status_request: status request for name %s from IP %s on \
subnet %s - name not found.\n", nmb_namestr(&nmb->question.question_name),
inet_ntoa(p->ip), subrec->subnet_name));
/* this is not an exact calculation. the 46 is for the stats buffer
and the 60 is to leave room for the header etc */
- bufend = &rdata[MAX_DGRAM_SIZE] - (18 + 46 + 60);
+ bufend = &rdata[MAX_DGRAM_SIZE-1] - (18 + 46 + 60);
countptr = buf = rdata;
buf += 1;
buf0 = buf;
unstring name;
pull_ascii_nstring(name, sizeof(name), namerec->name.name);
- strupper_m(name);
+ if (!strupper_m(name)) {
+ DEBUG(2,("strupper_m %s failed\n", name));
+ return;
+ }
if (!strequal(name,"*") &&
!strequal(name,"__SAMBA__") &&
(name_type < 0x1b || name_type >= 0x20 ||
/* Remove duplicate names. */
if (names_added > 1) {
+ /* TODO: should use a real type and
+ TYPESAFE_QSORT() */
qsort( buf0, names_added, 18, QSORT_CAST status_compare );
}
struct nmb_packet *nmb = &p->packet.nmb;
struct nmb_name *question = &nmb->question.question_name;
int name_type = question->name_type;
- BOOL bcast = nmb->header.nm_flags.bcast;
+ bool bcast = nmb->header.nm_flags.bcast;
int ttl=0;
int rcode = 0;
char *prdata = NULL;
char rdata[6];
- BOOL success = False;
+ bool success = False;
struct name_record *namerec = NULL;
int reply_data_len = 0;
int i;
if (namerec->data.source == WINS_PROXY_NAME) {
for( i = 0; i < namerec->data.num_ips; i++) {
- if (same_net(namerec->data.ip[i], subrec->myip, subrec->mask_ip)) {
+ if (same_net_v4(namerec->data.ip[i], subrec->myip, subrec->mask_ip)) {
DEBUG(5,("process_name_query_request: name %s is a WINS proxy name and is also on the same subnet (%s) as the requestor. Not replying.\n",
nmb_namestr(&namerec->name), subrec->subnet_name ));
return;