本文整理汇总了C++中IN_CLASSA函数的典型用法代码示例。如果您正苦于以下问题:C++ IN_CLASSA函数的具体用法?C++ IN_CLASSA怎么用?C++ IN_CLASSA使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IN_CLASSA函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: get_netmask4
/*
* Given a host-order address, calculate client's default net mask.
* Consult netmasks database to see if net is further subnetted.
* We'll only snag the first netmask that matches our criteria.
* We return the resultant netmask in host order.
*/
void
get_netmask4(const struct in_addr *n_addrp, struct in_addr *s_addrp)
{
struct in_addr hp, tp;
/*
* First check if VLSM is in use.
*/
hp.s_addr = htonl(n_addrp->s_addr);
if (getnetmaskbyaddr(hp, &tp) == 0) {
s_addrp->s_addr = ntohl(tp.s_addr);
return;
}
/*
* Fall back on standard classed networks.
*/
if (IN_CLASSA(n_addrp->s_addr))
s_addrp->s_addr = IN_CLASSA_NET;
else if (IN_CLASSB(n_addrp->s_addr))
s_addrp->s_addr = IN_CLASSB_NET;
else if (IN_CLASSC(n_addrp->s_addr))
s_addrp->s_addr = IN_CLASSC_NET;
else
s_addrp->s_addr = IN_CLASSE_NET;
}
开发者ID:apprisi,项目名称:illumos-gate,代码行数:32,代码来源:inetutil.c
示例2: route_netmask
/* This calculates the netmask that we should use for static routes.
* This IS different from the calculation used to calculate the netmask
* for an interface address. */
static uint32_t
route_netmask(uint32_t ip_in)
{
/* used to be unsigned long - check if error */
uint32_t p = ntohl(ip_in);
uint32_t t;
if (IN_CLASSA(p))
t = ~IN_CLASSA_NET;
else {
if (IN_CLASSB(p))
t = ~IN_CLASSB_NET;
else {
if (IN_CLASSC(p))
t = ~IN_CLASSC_NET;
else
t = 0;
}
}
while (t & p)
t >>= 1;
return (htonl(~t));
}
开发者ID:Andproject,项目名称:platform_external_dhcpcd,代码行数:28,代码来源:dhcp.c
示例3: in_netof
unsigned long in_netof(struct in_addr in)
{
unsigned long i, net;
struct in_ifaddr *ia;
/* Setup locals */
i = ntohl(in.s_addr);
/* Get network number */
if ( IN_CLASSA(i) )
net = i & IN_CLASSA_NET;
else if ( IN_CLASSB(i) )
net = i & IN_CLASSB_NET;
else if ( IN_CLASSC(i) )
net = i & IN_CLASSC_NET;
else if ( IN_CLASSD(i) )
net = i & IN_CLASSD_NET;
else
return 0;
/* Check if subnet */
for (ia = in_ifaddr; ia != NULL; ia = ia->ia_next)
if (net == ia->ia_net)
return (i & ia->ia_subnetmask);
return net;
}
开发者ID:phoboz,项目名称:vmx,代码行数:31,代码来源:inLib.c
示例4: GetMask
/*
* Return user specified netmask, modified by any mask we might determine
* for address `addr' (in network byte order).
* Here we scan through the system's list of interfaces, looking for
* any non-point-to-point interfaces which might appear to be on the same
* network as `addr'. If we find any, we OR in their netmask to the
* user-specified netmask.
*/
uint32_t
GetMask(
uint32_t addr)
{
uint32_t mask, nmask, ina;
struct ifreq *ifr, *ifend, ifreq;
struct ifconf ifc;
struct ifreq ifs[MAX_IFS];
addr = ntohl(addr);
if (IN_CLASSA(addr)) /* determine network mask for address class */
nmask = IN_CLASSA_NET;
else if (IN_CLASSB(addr))
nmask = IN_CLASSB_NET;
else
nmask = IN_CLASSC_NET;
/* class D nets are disallowed by bad_ip_adrs */
mask = netmask | htonl(nmask);
/*
* Scan through the system's network interfaces.
*/
ifc.ifc_len = sizeof(ifs);
ifc.ifc_req = ifs;
if (ioctl(sockfd, SIOCGIFCONF, &ifc) < 0) {
warn("ioctl(SIOCGIFCONF): %m");
return mask;
}
ifend = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
for (ifr = ifc.ifc_req; ifr < ifend; ifr = (struct ifreq *)
((char *)&ifr->ifr_addr + ifr->ifr_addr.sa_len)) {
/*
* Check the interface's internet address.
*/
if (ifr->ifr_addr.sa_family != AF_INET)
continue;
ina = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr;
if ((ntohl(ina) & nmask) != (addr & nmask))
continue;
/*
* Check that the interface is up, and not point-to-point or loopback.
*/
strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
if (ioctl(sockfd, SIOCGIFFLAGS, &ifreq) < 0)
continue;
if ((ifreq.ifr_flags & (IFF_UP|IFF_POINTOPOINT|IFF_LOOPBACK))
!= IFF_UP)
continue;
/*
* Get its netmask and OR it into our mask.
*/
if (ioctl(sockfd, SIOCGIFNETMASK, &ifreq) < 0)
continue;
mask |= ((struct sockaddr_in *)&ifreq.ifr_addr)->sin_addr.s_addr;
}
return mask;
}
开发者ID:deval-maker,项目名称:rtems-libbsd,代码行数:66,代码来源:sys-rtems.c
示例5: GetClass
/// This function uses Windows Sockets macros to get standard class information. It
/// does not know about subnetting or any classes beyond class C.
TINetSocketAddress::TINetClass TINetSocketAddress::GetClass() const
{
if (IN_CLASSA(GetNetworkAddress()))
return ClassA;
if (IN_CLASSB(GetNetworkAddress()))
return ClassB;
if (IN_CLASSC(GetNetworkAddress()))
return ClassC;
return ClassUnknown;
}
开发者ID:GarMeridian3,项目名称:Meridian59,代码行数:12,代码来源:wskaddr.cpp
示例6: net_mask
/* XXX - should really support CIDR which means explicit masks always. */
static u_int32_t
net_mask(struct in_addr in) /*!< XXX - should really use system's version of this */
{
u_int32_t i = ntohl(in.s_addr);
if (IN_CLASSA(i))
return (htonl(IN_CLASSA_NET));
else if (IN_CLASSB(i))
return (htonl(IN_CLASSB_NET));
return (htonl(IN_CLASSC_NET));
}
开发者ID:cemeyer,项目名称:freebsd-base-graphics,代码行数:12,代码来源:res_init.c
示例7: inet_lnaof
/*
* Return the local network address portion of an
* internet address; handles class a/b/c network
* number formats.
*/
in_addr_t inet_lnaof(struct in_addr in)
{
in_addr_t i = ntohl(in.s_addr);
if (IN_CLASSA(i))
return (i & IN_CLASSA_HOST);
else if (IN_CLASSB(i))
return (i & IN_CLASSB_HOST);
else
return (i & IN_CLASSC_HOST);
}
开发者ID:jameshilliard,项目名称:WECB-BH-GPL,代码行数:16,代码来源:addr.c
示例8: config_ip_prefix
static int config_ip_prefix(struct in_addr *addr)
{
if (IN_CLASSA(addr->s_addr))
return 32 - IN_CLASSA_NSHIFT;
if (IN_CLASSB(addr->s_addr))
return 32 - IN_CLASSB_NSHIFT;
if (IN_CLASSC(addr->s_addr))
return 32 - IN_CLASSC_NSHIFT;
return 0;
}
开发者ID:coconutpilot,项目名称:lxc-gentoo-new,代码行数:11,代码来源:confile.c
示例9: inet_class_netmask
static uint32_t inet_class_netmask(uint32_t ip)
{
ip = ntohl(ip);
if (IN_CLASSA(ip))
return htonl(IN_CLASSA_NET);
if (IN_CLASSB(ip))
return htonl(IN_CLASSB_NET);
if (IN_CLASSC(ip))
return htonl(IN_CLASSC_NET);
return INADDR_ANY;
}
开发者ID:Agochka,项目名称:klibc,代码行数:11,代码来源:main.c
示例10: printk
//---------------------------------------------------------------------------
// Search the entity with the IPv4 address 'addr'
struct cx_entity *nasmt_CLASS_cx4(struct sk_buff *skb, unsigned char dscp, int *paddr_type, unsigned char *cx_index) {
//---------------------------------------------------------------------------
unsigned char cxi;
uint32_t daddr;
struct cx_entity *cx=NULL;
struct classifier_entity *pclassifier=NULL;
struct in_addr masked_addr;
#ifdef NAS_DEBUG_CLASS
printk("nasmt_CLASS_cx4: begin\n");
#endif
if (skb!=NULL) {
daddr = ((struct iphdr*)(skb_network_header(skb)))->daddr;
if (daddr != INADDR_ANY) {
#ifdef NAS_DEBUG_CLASS
printk("nasmt_CLASS_cx4: SOURCE ADDR %d.%d.%d.%d",NIPADDR(ip_hdr(skb)->saddr));
printk(" DEST ADDR %d.%d.%d.%d\n",NIPADDR(ip_hdr(skb)->daddr));
#endif
if (ipv4_is_multicast(ip_hdr(skb)->daddr)) {
// TO BE CHECKED
*paddr_type = NAS_IPV4_ADDR_MC_SIGNALLING;
} else {
if (ipv4_is_lbcast(ip_hdr(skb)->daddr)) {
// TO BE CHECKED
*paddr_type = NAS_IPV4_ADDR_BROADCAST;
} else {
if (IN_CLASSA(ip_hdr(skb)->daddr) || IN_CLASSB(ip_hdr(skb)->daddr) || IN_CLASSC(ip_hdr(skb)->daddr)) {
*paddr_type = NAS_IPV4_ADDR_UNICAST;
cxi = 0;
(*cx_index)++;
pclassifier = gpriv->cx[cxi].sclassifier[dscp];
while (pclassifier!=NULL) {
// verify that this is an IPv4 classifier
if ((pclassifier->version == NAS_VERSION_4) || (pclassifier->version == NAS_VERSION_DEFAULT)) {
nasmt_create_mask_ipv4_addr(&masked_addr, pclassifier->dplen);
if (IN_ARE_ADDR_MASKED_EQUAL(&ip_hdr(skb)->daddr, &(pclassifier->daddr.ipv4), &masked_addr)) {
#ifdef NAS_DEBUG_CLASS
printk("nasmt_CLASS_cx4: IP MASK MATCHED: found cx %d: %d.%d.%d.%d/%d\n",cxi, NIPADDR(pclassifier->daddr.ipv4), pclassifier->dplen);
#endif
return &gpriv->cx[cxi];
}
}
// goto to next classification rule for the connection
pclassifier = pclassifier->next;
}
} else {
*paddr_type = NAS_IPV4_ADDR_UNKNOWN;
}
}
}
}
}
return cx;
}
开发者ID:mspublic,项目名称:openair4G-mirror,代码行数:56,代码来源:nasmt_classifier.c
示例11: inet_lnaof
/*
* Return the local network address portion of an
* internet address; handles class a/b/c network
* number formats.
*/
int
inet_lnaof(struct in_addr in)
{
u_long i = ntohl(in.s_addr);
if (IN_CLASSA(i))
return ((i)&IN_CLASSA_HOST);
else if (IN_CLASSB(i))
return ((i)&IN_CLASSB_HOST);
else
return ((i)&IN_CLASSC_HOST);
}
开发者ID:NanXiao,项目名称:illumos-joyent,代码行数:17,代码来源:inet_lnaof.c
示例12: ipaddrtonetmask
/*
* Get the netmask of an IP address. This routine is used if
* SIOCGIFNETMASK doesn't work.
*/
u_int32_t
ipaddrtonetmask(u_int32_t addr)
{
if (IN_CLASSA(addr))
return IN_CLASSA_NET;
if (IN_CLASSB(addr))
return IN_CLASSB_NET;
if (IN_CLASSC(addr))
return IN_CLASSC_NET;
error(FATAL, "unknown IP address class: %08X", addr);
/* NOTREACHED */
}
开发者ID:mosconi,项目名称:openbsd,代码行数:16,代码来源:rarpd.c
示例13: forgemask
static uint32_t
forgemask(uint32_t a)
{
uint32_t m;
if (IN_CLASSA(a))
m = IN_CLASSA_NET;
else if (IN_CLASSB(a))
m = IN_CLASSB_NET;
else
m = IN_CLASSC_NET;
return (m);
}
开发者ID:joegen,项目名称:oss_core,代码行数:13,代码来源:rtnl_get_route.cpp
示例14: forgemask
static u_long
forgemask(u_long a)
{
u_long m;
if (IN_CLASSA(a))
m = IN_CLASSA_NET;
else if (IN_CLASSB(a))
m = IN_CLASSB_NET;
else
m = IN_CLASSC_NET;
return (m);
}
开发者ID:MarginC,项目名称:kame,代码行数:13,代码来源:route.c
示例15: inet_lnaof
unsigned long
inet_lnaof(struct in_addr in)
{
unsigned long addr = ntohl(in.s_addr);
if (IN_CLASSA(addr))
addr &= IN_CLASSA_HOST;
else if (IN_CLASSB(addr))
addr &= IN_CLASSB_HOST;
else
addr &= IN_CLASSC_HOST;
return(htonl(addr));
}
开发者ID:barmi,项目名称:tcpip,代码行数:13,代码来源:IN_LNAOF.C
示例16: nl_set_ifaddr
int nl_set_ifaddr(struct in_addr ifaddr, struct in_addr bcaddr, int ifindex)
{
struct {
struct ifaddrmsg ifa;
struct {
struct rtattr rta;
struct in_addr addr;
} data[3];
} m;
memset(&m, 0, sizeof(m));
m.ifa.ifa_family = AF_INET;
if (IN_CLASSA(ifaddr.s_addr))
m.ifa.ifa_prefixlen = IN_CLASSA_NSHIFT;
else if (IN_CLASSB(ifaddr.s_addr))
m.ifa.ifa_prefixlen = IN_CLASSB_NSHIFT;
else if (IN_CLASSC(ifaddr.s_addr))
m.ifa.ifa_prefixlen = IN_CLASSC_NSHIFT;
else if (IN_CLASSD(ifaddr.s_addr))
m.ifa.ifa_prefixlen = 0;
m.ifa.ifa_prefixlen = 24;
m.ifa.ifa_flags = 0; //IFA_F_PERMANENT;
m.ifa.ifa_scope = RT_SCOPE_UNIVERSE;
m.ifa.ifa_index = ifindex;
m.data[0].rta.rta_len = RTA_LENGTH(sizeof(ifaddr));
m.data[0].rta.rta_type = IFA_LOCAL;
m.data[0].addr.s_addr = ifaddr.s_addr;
m.data[1].rta.rta_len = RTA_LENGTH(sizeof(ifaddr));
m.data[1].rta.rta_type = IFA_ADDRESS;
m.data[1].addr.s_addr = ifaddr.s_addr;
m.data[2].rta.rta_len = RTA_LENGTH(sizeof(ifaddr));
m.data[2].rta.rta_type = IFA_BROADCAST;
m.data[2].addr.s_addr = bcaddr.s_addr;
DEBUG(LOG_DEBUG, 0, "Sending new ifaddr %s %s netlink message index=%d",
ip_to_str(ifaddr),
ip_to_str(bcaddr),
ifindex);
return nl_create_and_send_msg(rtnlsock, RTM_NEWADDR, &m, sizeof(m));
}
开发者ID:joninvski,项目名称:aodvuu-ts7500,代码行数:48,代码来源:nl.c
示例17: get_netmask
unsigned long get_netmask (unsigned long addr)
{
unsigned long dst;
if (addr == 0)
return (0);
dst = htonl (addr);
if (IN_CLASSA (dst))
return (ntohl (IN_CLASSA_NET));
if (IN_CLASSB (dst))
return (ntohl (IN_CLASSB_NET));
if (IN_CLASSC (dst))
return (ntohl (IN_CLASSC_NET));
return (0);
}
开发者ID:BackupTheBerlios,项目名称:dhcpcd-svn,代码行数:17,代码来源:interface.c
示例18: buid_ip_set
//------------------------------------------------------------------------------
// FUNCTION
// void buid_ip_set(struct ip_set *setp,
// const char *if_name,
// unsigned int addrs_ip,
// unsigned int addrs_netmask,
// unsigned int addrs_broadcast,
// unsigned int addrs_gateway,
// unsigned int addrs_server,
// unsigned char mode,
// unsigned char *data )
//
// DESCRIPTION
//
//
// PARAMETERS
//
//
// RETURN
//
//
//------------------------------------------------------------------------------
void buid_ip_set(struct ip_set *setp,
const char *if_name,
unsigned int addrs_ip,
unsigned int addrs_netmask,
unsigned int addrs_broadcast,
unsigned int addrs_gateway,
unsigned int addrs_server,
unsigned int mtu,
unsigned char mode,
const char *domain,
unsigned char *data )
{
if(if_name == NULL)
return;
memset(setp, 0, sizeof(struct ip_set)); // clear
strcpy(setp->ifname, if_name);
setp->ip = addrs_ip;
if(addrs_netmask || (setp->ip == 0))
setp->netmask = addrs_netmask;
else
{
// if no netmask, set class netmask
if (IN_CLASSA(setp->ip))
setp->netmask = IN_CLASSA_HOST;
else if (IN_CLASSB(setp->ip))
setp->netmask = IN_CLASSB_HOST;
else
setp->netmask = IN_CLASSC_HOST;
}
setp->server_ip = addrs_server;
setp->gw_ip = addrs_gateway;
if(addrs_broadcast)
setp->broad_ip = addrs_broadcast;
else
setp->broad_ip=((setp->ip)&(setp->netmask))|~(setp->netmask);
setp->mtu = mtu;
setp->mode = mode;
if(domain)
strcpy(setp->domain, domain);
setp->data = data;
}
开发者ID:houzhenggang,项目名称:mt7688_mips_ecos,代码行数:67,代码来源:net_cfg.c
示例19: start_networking
void start_networking(void)
{
struct ip_addr ipaddr = { htonl(IF_IPADDR) };
struct ip_addr netmask = { htonl(IF_NETMASK) };
struct ip_addr gw = { 0 };
char *ip = NULL;
#ifdef CONFIG_PRINT
tprintk("Waiting for network.\n");
#endif
dev = init_netfront(NULL, NULL, rawmac, &ip);
if (ip) {
ipaddr.addr = inet_addr(ip);
if (IN_CLASSA(ntohl(ipaddr.addr)))
netmask.addr = htonl(IN_CLASSA_NET);
else if (IN_CLASSB(ntohl(ipaddr.addr)))
netmask.addr = htonl(IN_CLASSB_NET);
else if (IN_CLASSC(ntohl(ipaddr.addr)))
netmask.addr = htonl(IN_CLASSC_NET);
else
tprintk("Strange IP %s, leaving netmask to 0.\n", ip);
}
tprintk("IP %x netmask %x gateway %x.\n",
ntohl(ipaddr.addr), ntohl(netmask.addr), ntohl(gw.addr));
#ifdef CONFIG_PRINT
tprintk("TCP/IP bringup begins.\n");
#endif
netif = xmalloc(struct netif);
tcpip_init(tcpip_bringup_finished, netif);
netif_add(netif, &ipaddr, &netmask, &gw, rawmac,
netif_netfront_init, ip_input);
netif_set_default(netif);
netif_set_up(netif);
down(&tcpip_is_up);
#ifdef CONFIG_FRONT
tprintk("Network is ready.\n");
#endif
}
开发者ID:farewellkou,项目名称:xen,代码行数:45,代码来源:lwip-net.c
示例20: get_netmask
uint32_t
get_netmask(uint32_t addr)
{
uint32_t dst;
if (addr == 0)
return 0;
dst = htonl(addr);
if (IN_CLASSA(dst))
return ntohl(IN_CLASSA_NET);
if (IN_CLASSB(dst))
return ntohl(IN_CLASSB_NET);
if (IN_CLASSC(dst))
return ntohl(IN_CLASSC_NET);
return 0;
}
开发者ID:Andproject,项目名称:platform_external_dhcpcd,代码行数:18,代码来源:net.c
注:本文中的IN_CLASSA函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论