int open_socket_out(int type, struct in_addr *addr, int port );
int interpret_protocol(char *str,int def);
int interpret_security(char *str,int def);
-unsigned long interpret_addr(char *str);
+uint32 interpret_addr(char *str);
struct in_addr *interpret_addr2(char *str);
BOOL zero_ip(struct in_addr ip);
void standard_sub_basic(char *s);
/* masked_match - match address against netnumber/netmask */
static int masked_match(char *tok, char *slash, char *s)
{
- unsigned long net;
- unsigned long mask;
- unsigned long addr;
-
- if ((addr = interpret_addr(s)) == INADDR_NONE)
- return (NO);
- *slash = 0;
- net = interpret_addr(tok);
- *slash = '/';
- if (net == INADDR_NONE || (mask = interpret_addr(slash + 1)) == INADDR_NONE) {
- DEBUG(0,("access: bad net/mask access control: %s", tok));
- return (NO);
- }
- return ((addr & mask) == net);
+ uint32 net;
+ uint32 mask;
+ uint32 addr;
+
+ if ((addr = interpret_addr(s)) == INADDR_NONE)
+ return (NO);
+ *slash = 0;
+ net = interpret_addr(tok);
+ *slash = '/';
+ if (net == INADDR_NONE || (mask = interpret_addr(slash + 1)) == INADDR_NONE) {
+ DEBUG(0,("access: bad net/mask access control: %s", tok));
+ return (NO);
+ }
+ return ((addr & mask) == net);
}
****************************************************************************/
static void default_netmask(struct in_addr *inm, struct in_addr *iad)
{
- unsigned long ad = ntohl(iad->s_addr);
- unsigned long nm;
+ uint32 ad = ntohl(iad->s_addr);
+ uint32 nm;
/*
** Guess a netmask based on the class of the IP address given.
*/
/* sanity check on the netmask */
{
- unsigned long nm = ntohl(if_nmask->s_addr);
+ uint32 nm = ntohl(if_nmask->s_addr);
if ((nm >> 24) != 0xFF) {
DEBUG(0,("Impossible netmask %s - using defaults\n",inet_ntoa(*if_nmask)));
default_netmask(if_nmask, if_ipaddr);
all MS operating systems do, we have to comply even if the unix
box is setup differently */
{
- unsigned long ad = ntohl(if_ipaddr->s_addr);
- unsigned long nm = ntohl(if_nmask->s_addr);
- unsigned long bc = (ad & nm) | (0xffffffff & ~nm);
+ uint32 ad = ntohl(if_ipaddr->s_addr);
+ uint32 nm = ntohl(if_nmask->s_addr);
+ uint32 bc = (ad & nm) | (0xffffffff & ~nm);
if_bcast->s_addr = htonl(bc);
}
****************************************************************************/
BOOL ip_equal(struct in_addr ip1,struct in_addr ip2)
{
- unsigned long a1,a2;
+ uint32 a1,a2;
a1 = ntohl(ip1.s_addr);
a2 = ntohl(ip2.s_addr);
return(a1 == a2);
/****************************************************************************
interpret an internet address or name into an IP address in 4 byte form
****************************************************************************/
-unsigned long interpret_addr(char *str)
+uint32 interpret_addr(char *str)
{
struct hostent *hp;
- unsigned long res;
+ uint32 res;
if (strcmp(str,"0.0.0.0") == 0) return(0);
if (strcmp(str,"255.255.255.255") == 0) return(0xFFFFFFFF);
putip((char *)&res,(char *)hp->h_addr);
}
- if (res == (unsigned long)-1) return(0);
+ if (res == (uint32)-1) return(0);
return(res);
}
struct in_addr *interpret_addr2(char *str)
{
static struct in_addr ret;
- unsigned long a = interpret_addr(str);
+ uint32 a = interpret_addr(str);
ret.s_addr = a;
return(&ret);
}
******************************************************************/
BOOL zero_ip(struct in_addr ip)
{
- unsigned long a;
+ uint32 a;
putip((char *)&a,(char *)&ip);
return(a == 0);
}
********************************************************************/
BOOL same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask)
{
- unsigned long net1,net2,nmask;
+ uint32 net1,net2,nmask;
nmask = ntohl(mask.s_addr);
net1 = ntohl(ip1.s_addr);
if ((offset & mask) != 0)
offset = (offset & ~mask) | ((offset & mask) >> 2);
#else
- unsigned long mask = ((unsigned)1<<31);
+ uint32 mask = ((unsigned)1<<31);
/* interpret negative counts as large numbers */
if (count < 0)
if (!n)
{
struct in_addr dns_ip;
- unsigned long a;
+ uint32 a;
/* only do DNS lookups if the query is for type 0x20 or type 0x0 */
if (!dns_type && name_type != 0x1b)
for (d = subnetlist; d; d = d->next)
{
- BOOL wins_iface = ip_equal(d->bcast_ip, ipgrp);
-
add_my_name_entry(d, myname,0x20,nb_type|NB_ACTIVE);
add_my_name_entry(d, myname,0x03,nb_type|NB_ACTIVE);
add_my_name_entry(d, myname,0x00,nb_type|NB_ACTIVE);