本文整理汇总了C++中IN_CLASSC函数的典型用法代码示例。如果您正苦于以下问题:C++ IN_CLASSC函数的具体用法?C++ IN_CLASSC怎么用?C++ IN_CLASSC使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IN_CLASSC函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: 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
示例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: apply_classful_mask_ipv4
/* Utility function to convert ipv4 prefixes to Classful prefixes */
void apply_classful_mask_ipv4 (struct prefix_ipv4 *p)
{
u_int32_t destination;
destination = ntohl (p->prefix.s_addr);
if (p->prefixlen == IPV4_MAX_PREFIXLEN);
/* do nothing for host routes */
else if (IN_CLASSC (destination))
{
p->prefixlen=24;
apply_mask_ipv4(p);
}
else if (IN_CLASSB(destination))
{
p->prefixlen=16;
apply_mask_ipv4(p);
}
else
{
p->prefixlen=8;
apply_mask_ipv4(p);
}
}
开发者ID:edderick,项目名称:quagga_zOSPF,代码行数:26,代码来源:prefix.c
示例4: 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
示例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: 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
示例7: 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
示例8: 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
示例9: 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
示例10: 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
示例11: 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
示例12: 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
示例13: 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
示例14: networkFromInaddr
static struct in_addr
networkFromInaddr(struct in_addr a)
{
struct in_addr b;
b.s_addr = ntohl(a.s_addr);
#if USE_CLASSFUL
if (IN_CLASSC(b.s_addr))
b.s_addr &= IN_CLASSC_NET;
else if (IN_CLASSB(b.s_addr))
b.s_addr &= IN_CLASSB_NET;
else if (IN_CLASSA(b.s_addr))
b.s_addr &= IN_CLASSA_NET;
#else
/* use /24 for everything */
b.s_addr &= IN_CLASSC_NET;
#endif
b.s_addr = htonl(b.s_addr);
return b;
}
开发者ID:linfengfeiye,项目名称:squid2,代码行数:19,代码来源:net_db.c
示例15: inet_abc_len
static __inline__ int inet_abc_len(u32 addr)
{
if (ZERONET(addr))
return 0;
addr = ntohl(addr);
if (IN_CLASSA(addr))
return 8;
if (IN_CLASSB(addr))
return 16;
if (IN_CLASSC(addr))
return 24;
/*
* Something else, probably a multicast.
*/
return -1;
}
开发者ID:muromec,项目名称:linux-ezxdev,代码行数:19,代码来源:devinet.c
示例16: getnetmask
static unsigned long getnetmask (unsigned long ip_in)
{
unsigned long t, p = ntohl (ip_in);
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:BackupTheBerlios,项目名称:dhcpcd-svn,代码行数:19,代码来源:dhcp.c
示例17: resume_networking
void resume_networking(int cancelled)
{
//struct netif *netif;
struct ip_addr ipaddr = { htonl(IF_IPADDR) };
struct ip_addr netmask = { htonl(IF_NETMASK) };
struct ip_addr gw = { htonl(0xc0a87a01) };
char *ip = NULL;
#ifdef CONFIG_PRINT
tprintk("Waiting for network.\n");
#endif
dev = init_netfront(NULL, NULL, rawmac, &ip);
if(!cancelled){
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));
netif = xmalloc(struct 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_SUSPEND
tprintk("TCP/IP bringup begins.\n");
#endif
}
开发者ID:farewellkou,项目名称:xen,代码行数:42,代码来源:lwip-net.c
示例18: netof
sockaddr_u *
netof(
sockaddr_u *hostaddr
)
{
static sockaddr_u netofbuf[8];
static int next_netofbuf;
u_int32 netnum;
sockaddr_u * netaddr;
netaddr = &netofbuf[next_netofbuf];
next_netofbuf = (next_netofbuf + 1) % COUNTOF(netofbuf);
memcpy(netaddr, hostaddr, sizeof(*netaddr));
if (IS_IPV4(netaddr)) {
netnum = SRCADR(netaddr);
/*
* We live in a modern CIDR world where the basement nets, which
* used to be class A, are now probably associated with each
* host address. So, for class-A nets, all bits are significant.
*/
if (IN_CLASSC(netnum))
netnum &= IN_CLASSC_NET;
else if (IN_CLASSB(netnum))
netnum &= IN_CLASSB_NET;
SET_ADDR4(netaddr, netnum);
} else if (IS_IPV6(netaddr))
/* assume the typical /64 subnet size */
zero_mem(&NSRCADR6(netaddr)[8], 8);
#ifdef DEBUG
else {
msyslog(LOG_ERR, "netof unknown AF %d", AF(netaddr));
exit(1);
}
#endif
return netaddr;
}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:42,代码来源:netof.c
示例19: netmask_isis_str2prefix_str
/* Utility function to convert ipv4 netmask to prefixes
ex.) "1.1.0.0" "255.255.0.0" => "1.1.0.0/16"
ex.) "1.0.0.0" NULL => "1.0.0.0/8" */
int
netmask_isis_str2prefix_str (const char *net_str, const char *mask_str,
char *prefix_str)
{
struct in_addr network;
struct in_addr mask;
u_char prefixlen;
u_int32_t destination;
int ret;
ret = inet_aton (net_str, &network);
if (! ret)
return 0;
if (mask_str)
{
ret = inet_aton (mask_str, &mask);
if (! ret)
return 0;
prefixlen = isis_ip_masklen (mask);
}
else
{
destination = ntohl (network.s_addr);
if (network.s_addr == 0)
prefixlen = 0;
else if (IN_CLASSC (destination))
prefixlen = 24;
else if (IN_CLASSB (destination))
prefixlen = 16;
else if (IN_CLASSA (destination))
prefixlen = 8;
else
return 0;
}
sprintf (prefix_str, "%s/%d", net_str, prefixlen);
return 1;
}
开发者ID:Benocs,项目名称:pmacct,代码行数:45,代码来源:prefix.c
示例20: guess_prefix_len
static unsigned int
guess_prefix_len(struct in_addr addr)
{
uint32_t prefix = ntohl(addr.s_addr);
unsigned int len;
/* At a minimum, use the prefix len for this IPv4 address class. */
if (IN_CLASSA(prefix))
len = 8;
else if (IN_CLASSB(prefix))
len = 16;
else if (IN_CLASSC(prefix))
len = 24;
else
len = 0;
/* If the address has bits beyond the default class,
* extend the prefix until we've covered all of them. */
return len + __count_net_bits(prefix << len);
}
开发者ID:mchf,项目名称:wicked,代码行数:20,代码来源:protocol.c
注:本文中的IN_CLASSC函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论