• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ NIPQUAD函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中NIPQUAD函数的典型用法代码示例。如果您正苦于以下问题:C++ NIPQUAD函数的具体用法?C++ NIPQUAD怎么用?C++ NIPQUAD使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NIPQUAD函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: route

/* Try to route the packet according to the routing keys specified in
 * route_info. Keys are :
 *  - ifindex : 
 *      0 if no oif preferred, 
 *      otherwise set to the index of the desired oif
 *  - route_info->gw :
 *      0 if no gateway specified,
 *      otherwise set to the next host to which the pkt must be routed
 * If success, skb->dev is the output device to which the packet must 
 * be sent and skb->dst is not NULL
 *
 * RETURN: -1 if an error occured
 *          1 if the packet was succesfully routed to the 
 *            destination desired
 *          0 if the kernel routing table could not route the packet
 *            according to the keys specified
 */
static int route(struct sk_buff *skb,
		 unsigned int ifindex,
		 const struct ipt_route_target_info *route_info)
{
	int err;
	struct rtable *rt;
	struct iphdr *iph =ip_hdr(skb);
	struct flowi fl = {
		.oif = ifindex,
		.nl_u = {
			.ip4_u = {
				.daddr = iph->daddr,
				.saddr = 0,
				.tos = RT_TOS(iph->tos),
				.scope = RT_SCOPE_UNIVERSE,
			}
		} 
	};
	
	/* The destination address may be overloaded by the target */
	if (route_info->gw)
		fl.fl4_dst = route_info->gw;
	
	/* Trying to route the packet using the standard routing table. */
//	if ((err = ip_route_output_key(dev_net(dev),,&rt, &fl))) {
	if ((err = ip_route_output_key(&init_net,&rt, &fl))) {
		if (net_ratelimit()) 
			DEBUGP("ipt_ROUTE: couldn't route pkt (err: %i)",err);
		return -1;
	}
	
	/* Drop old route. */
	dst_release(skb->dst);
	skb->dst = NULL;

	/* Success if no oif specified or if the oif correspond to the 
	 * one desired */
	if (!ifindex || rt->u.dst.dev->ifindex == ifindex) {
		skb->dst = &rt->u.dst;
		skb->dev = skb->dst->dev;
		skb->protocol = htons(ETH_P_IP);
		return 1;
	}
	
	/* The interface selected by the routing table is not the one
	 * specified by the user. This may happen because the dst address
	 * is one of our own addresses.
	 */
	if (net_ratelimit()) 
		DEBUGP("ipt_ROUTE: failed to route as desired gw=%u.%u.%u.%u oif=%i (got oif=%i)\n", 
		       NIPQUAD(route_info->gw), ifindex, rt->u.dst.dev->ifindex);
	
	return 0;
}
开发者ID:antonywcl,项目名称:AR-5315u_PLD,代码行数:71,代码来源:ipt_ROUTE.c


示例2: rxrpc_call_seq_show

static int rxrpc_call_seq_show(struct seq_file *seq, void *v)
{
	struct rxrpc_transport *trans;
	struct rxrpc_call *call;
	char lbuff[4 + 4 + 4 + 4 + 5 + 1], rbuff[4 + 4 + 4 + 4 + 5 + 1];

	if (v == &rxrpc_calls) {
		seq_puts(seq,
			 "Proto Local                  Remote                "
			 " SvID ConnID   CallID   End Use State    Abort   "
			 " UserID\n");
		return 0;
	}

	call = list_entry(v, struct rxrpc_call, link);
	trans = call->conn->trans;

	sprintf(lbuff, NIPQUAD_FMT":%u",
		NIPQUAD(trans->local->srx.transport.sin.sin_addr),
		ntohs(trans->local->srx.transport.sin.sin_port));

	sprintf(rbuff, NIPQUAD_FMT":%u",
		NIPQUAD(trans->peer->srx.transport.sin.sin_addr),
		ntohs(trans->peer->srx.transport.sin.sin_port));

	seq_printf(seq,
		   "UDP   %-22.22s %-22.22s %4x %08x %08x %s %3u"
		   " %-8.8s %08x %lx\n",
		   lbuff,
		   rbuff,
		   ntohs(call->conn->service_id),
		   ntohl(call->conn->cid),
		   ntohl(call->call_id),
		   call->conn->in_clientflag ? "Svc" : "Clt",
		   atomic_read(&call->usage),
		   rxrpc_call_states[call->state],
		   call->abort_code,
		   call->user_call_ID);

	return 0;
}
开发者ID:LouZiffer,项目名称:m900_kernel_cupcake-SDX,代码行数:41,代码来源:ar-proc.c


示例3: delip_kernel

static int
delip_kernel(struct ip_set *set, 
	     const struct sk_buff *skb,
	     ip_set_ip_t *hash_ip,
	     const u_int32_t *flags,
	     unsigned char index)
{
	ip_set_ip_t port;

	if (flags[index+1] == 0)
		return -EINVAL;
		
	port = get_port(skb, flags[index+1]);

	DP("flag: %s src: %u.%u.%u.%u dst: %u.%u.%u.%u",
	   flags[index] & IPSET_SRC ? "SRC" : "DST",
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
	   NIPQUAD(ip_hdr(skb)->saddr),
	   NIPQUAD(ip_hdr(skb)->daddr));
#else
	   NIPQUAD(skb->nh.iph->saddr),
	   NIPQUAD(skb->nh.iph->daddr));
#endif
	DP("flag %s port %u",
	   flags[index+1] & IPSET_SRC ? "SRC" : "DST", 
	   port);	
	if (port == INVALID_PORT)
		return -EINVAL;	

	return __delip(set,
		       ntohl(flags[index] & IPSET_SRC 
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
				? ip_hdr(skb)->saddr 
				: ip_hdr(skb)->daddr),
#else
		       		? skb->nh.iph->saddr 
				: skb->nh.iph->daddr),
#endif
		       port,
		       hash_ip);
}
开发者ID:nakedible,项目名称:vpnease-l2tp,代码行数:41,代码来源:ip_set_ipporthash.c


示例4: nat_t120

static int nat_t120(struct sk_buff *skb, struct nf_conn *ct,
		    enum ip_conntrack_info ctinfo,
		    unsigned char **data, int dataoff,
		    H245_TransportAddress *taddr, __be16 port,
		    struct nf_conntrack_expect *exp)
{
	int dir = CTINFO2DIR(ctinfo);
	u_int16_t nated_port = ntohs(port);

	/* Set expectations for NAT */
	exp->saved_proto.tcp.port = exp->tuple.dst.u.tcp.port;
	exp->expectfn = nf_nat_follow_master;
	exp->dir = !dir;

	/* Try to get same port: if not, try to change it. */
	for (; nated_port != 0; nated_port++) {
		exp->tuple.dst.u.tcp.port = htons(nated_port);
		if (nf_conntrack_expect_related(exp) == 0)
			break;
	}

	if (nated_port == 0) {	/* No port available */
		if (net_ratelimit())
			printk("nf_nat_h323: out of TCP ports\n");
		return 0;
	}

	/* Modify signal */
	if (set_h245_addr(skb, data, dataoff, taddr,
			  &ct->tuplehash[!dir].tuple.dst.u3,
			  htons(nated_port)) < 0) {
		nf_conntrack_unexpect_related(exp);
		return -1;
	}

	DEBUGP("nf_nat_h323: expect T.120 %u.%u.%u.%u:%hu->%u.%u.%u.%u:%hu\n",
	       NIPQUAD(exp->tuple.src.ip), ntohs(exp->tuple.src.u.tcp.port),
	       NIPQUAD(exp->tuple.dst.ip), ntohs(exp->tuple.dst.u.tcp.port));

	return 0;
}
开发者ID:IgnasD,项目名称:Tomato-RAF,代码行数:41,代码来源:nf_nat_h323.c


示例5: atm_mpoa_disp_qos

/* this is buggered - we need locking for qos_head */
void atm_mpoa_disp_qos(struct seq_file *m)
{
	unsigned char *ip;
	char ipaddr[16];
	struct atm_mpoa_qos *qos;

	qos = qos_head;
	seq_printf(m, "QoS entries for shortcuts:\n");
	seq_printf(m, "IP address\n  TX:max_pcr pcr     min_pcr max_cdv max_sdu\n  RX:max_pcr pcr     min_pcr max_cdv max_sdu\n");

	ipaddr[sizeof(ipaddr)-1] = '\0';
	while (qos != NULL) {
		ip = (unsigned char *)&qos->ipaddr;
		sprintf(ipaddr, "%u.%u.%u.%u", NIPQUAD(ip));
		seq_printf(m, "%u.%u.%u.%u\n     %-7d %-7d %-7d %-7d %-7d\n     %-7d %-7d %-7d %-7d %-7d\n",
				NIPQUAD(ipaddr),
				qos->qos.txtp.max_pcr, qos->qos.txtp.pcr, qos->qos.txtp.min_pcr, qos->qos.txtp.max_cdv, qos->qos.txtp.max_sdu,
				qos->qos.rxtp.max_pcr, qos->qos.rxtp.pcr, qos->qos.rxtp.min_pcr, qos->qos.rxtp.max_cdv, qos->qos.rxtp.max_sdu);
		qos = qos->next;
	}
}
开发者ID:Antonio-Zhou,项目名称:Linux-2.6.11,代码行数:22,代码来源:mpc.c


示例6: iprange_mt_v0

static bool
iprange_mt_v0(const struct sk_buff *skb, const struct xt_match_param *par)
{
	const struct ipt_iprange_info *info = par->matchinfo;
	const struct iphdr *iph = ip_hdr(skb);

	if (info->flags & IPRANGE_SRC) {
		if ((ntohl(iph->saddr) < ntohl(info->src.min_ip)
			  || ntohl(iph->saddr) > ntohl(info->src.max_ip))
			 ^ !!(info->flags & IPRANGE_SRC_INV)) {
			pr_debug("src IP %u.%u.%u.%u NOT in range %s"
				 "%u.%u.%u.%u-%u.%u.%u.%u\n",
				 NIPQUAD(iph->saddr),
				 info->flags & IPRANGE_SRC_INV ? "(INV) " : "",
				 NIPQUAD(info->src.min_ip),
				 NIPQUAD(info->src.max_ip));
			return false;
		}
	}
	if (info->flags & IPRANGE_DST) {
		if ((ntohl(iph->daddr) < ntohl(info->dst.min_ip)
			  || ntohl(iph->daddr) > ntohl(info->dst.max_ip))
			 ^ !!(info->flags & IPRANGE_DST_INV)) {
			pr_debug("dst IP %u.%u.%u.%u NOT in range %s"
				 "%u.%u.%u.%u-%u.%u.%u.%u\n",
				 NIPQUAD(iph->daddr),
				 info->flags & IPRANGE_DST_INV ? "(INV) " : "",
				 NIPQUAD(info->dst.min_ip),
				 NIPQUAD(info->dst.max_ip));
			return false;
		}
	}
	return true;
}
开发者ID:kizukukoto,项目名称:WDN900_GPL,代码行数:34,代码来源:xt_iprange.c


示例7: mms_nat_expected

static unsigned int
mms_nat_expected(struct sk_buff **pskb,
                 unsigned int hooknum,
                 struct ip_conntrack *ct,
                 struct ip_nat_info *info)
{
	struct ip_nat_multi_range mr;
	u_int32_t newdstip, newsrcip, newip;

	struct ip_conntrack *master = master_ct(ct);

	IP_NF_ASSERT(info);
	IP_NF_ASSERT(master);

	IP_NF_ASSERT(!(info->initialized & (1 << HOOK2MANIP(hooknum))));

	DEBUGP("ip_nat_mms: mms_nat_expected: We have a connection!\n");

	newdstip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip;
	newsrcip = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip;
	DEBUGP("ip_nat_mms: mms_nat_expected: hook %s: newsrc->newdst %u.%u.%u.%u->%u.%u.%u.%u\n",
	       hooknum == NF_IP_POST_ROUTING ? "POSTROUTING"
	       : hooknum == NF_IP_PRE_ROUTING ? "PREROUTING"
	       : hooknum == NF_IP_LOCAL_OUT ? "OUTPUT" : "???",
	       NIPQUAD(newsrcip), NIPQUAD(newdstip));

	if (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC)
		newip = newsrcip;
	else
		newip = newdstip;

	DEBUGP("ip_nat_mms: mms_nat_expected: IP to %u.%u.%u.%u\n", NIPQUAD(newip));

	mr.rangesize = 1;
	/* We don't want to manip the per-protocol, just the IPs. */
	mr.range[0].flags = IP_NAT_RANGE_MAP_IPS;
	mr.range[0].min_ip = mr.range[0].max_ip = newip;

	return ip_nat_setup_info(ct, &mr, hooknum);
}
开发者ID:nakedible,项目名称:vpnease-l2tp,代码行数:40,代码来源:ip_nat_mms.c


示例8: gr_log_start

static int gr_log_start(int audit)
{
	char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
	char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
	char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;

	if (audit == GR_DO_AUDIT)
		goto set_fmt;

	if (!grsec_alert_wtime || jiffies - grsec_alert_wtime > CONFIG_GRKERNSEC_FLOODTIME * HZ) {
		grsec_alert_wtime = jiffies;
		grsec_alert_fyet = 0;
	} else if ((jiffies - grsec_alert_wtime < CONFIG_GRKERNSEC_FLOODTIME * HZ) && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
		grsec_alert_fyet++;
	} else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
		grsec_alert_wtime = jiffies;
		grsec_alert_fyet++;
		printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
		return FLOODING;
	} else return FLOODING;

set_fmt:
	memset(buf, 0, PAGE_SIZE);
	if (current->signal->curr_ip && gr_acl_is_enabled()) {
		sprintf(fmt, "%s%s", loglevel, "grsec: From %u.%u.%u.%u: (%.64s:%c:%.950s) ");
		snprintf(buf, PAGE_SIZE - 1, fmt, NIPQUAD(current->signal->curr_ip), current->role->rolename, gr_roletype_to_char(), current->acl->filename);
	} else if (current->signal->curr_ip) {
		sprintf(fmt, "%s%s", loglevel, "grsec: From %u.%u.%u.%u: ");
		snprintf(buf, PAGE_SIZE - 1, fmt, NIPQUAD(current->signal->curr_ip));
	} else if (gr_acl_is_enabled()) {
		sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
		snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
	} else {
		sprintf(fmt, "%s%s", loglevel, "grsec: ");
		strcpy(buf, fmt);
	}

	return NO_FLOODING;
}
开发者ID:mikeberkelaar,项目名称:grhardened,代码行数:39,代码来源:grsec_log.c


示例9: ipv4_subnet_to_string

/* Convert an IPv4 subnet to human-readable a.b.c.d/e format. */
static int ipv4_subnet_to_string(char *buffer, int size,
				 const struct ipv4_subnet *net)
{
	int mask_len;
	if (net->mask == 0) {
		mask_len = 0;
	} else {
		/* count trailing zeroes */
		mask_len = 32 - __builtin_ctz(be32_to_cpu(net->mask));
	}
	return snprintf(buffer, size, "%u.%u.%u.%u/%d",
			NIPQUAD(net->ip), mask_len);
}
开发者ID:edesiocs,项目名称:stubl,代码行数:14,代码来源:stubl.c


示例10: rds_recv_route

static void
rds_recv_route(struct rds_connection *conn, struct rds_incoming *inc,
	       gfp_t gfp)
{
	struct rds_connection *nconn;
	struct rds_nf_hdr  *dst, *org;

	/* pull out the rds header */
	dst = rds_nf_hdr_dst(inc->i_skb);
	org = rds_nf_hdr_org(inc->i_skb);

	/* special case where we are swapping the message back on the same connection */
	if (dst->saddr == org->daddr && dst->daddr == org->saddr) {
		nconn = conn;
	} else {
		/* reroute to a new conn structure, possibly the same one */
		nconn = rds_conn_find(dst->saddr, dst->daddr, conn->c_trans,
				      conn->c_tos);
	}

	/* cannot find a matching connection so drop the request */
	if (NULL == nconn) {
		printk(KERN_ALERT "cannot find matching conn for inc %p, %u.%u.%u.%u -> %u.%u.%u.%u\n",
		       inc, NIPQUAD(dst->saddr), NIPQUAD(dst->daddr));

		rdsdebug("cannot find matching conn for inc %p, %u.%u.%u.%u -> %u.%u.%u.%u",
			 inc, NIPQUAD(dst->saddr), NIPQUAD(dst->daddr));
		rds_recv_drop(conn, dst->saddr, dst->daddr, inc, gfp);
	}
	/* this is a request for our local node, but potentially a different source
	 * either way we process it locally */
	else if (conn->c_trans->skb_local(inc->i_skb)) {
		rds_recv_local(nconn, dst->saddr, dst->daddr, inc, gfp);
	}
	/* looks like this request is going out to another node */
	else {
		rds_recv_forward(nconn, inc, gfp);
	}
}
开发者ID:Cai900205,项目名称:test,代码行数:39,代码来源:recv.c


示例11: create_socket

/** Create a socket.
 * The flags can include values from enum VsockFlag.
 *
 * @param socktype socket type
 * @param saddr address
 * @param port port
 * @param flags flags
 * @param val return value for the socket connection
 * @return 0 on success, error code otherwise
 */
int create_socket(int socktype, uint32_t saddr, uint32_t port, int flags, int *val){
    int err = 0;
    int sock;
    struct sockaddr_in addr_in;
    struct sockaddr *addr = (struct sockaddr *)&addr_in;
    int addr_n = sizeof(addr_in);
    int sockproto = 0;

    //dprintf(">\n");
    addr_in.sin_family      = AF_INET;
    addr_in.sin_addr.s_addr = saddr;
    addr_in.sin_port        = port;
    dprintf("> flags=%s addr=%u.%u.%u.%u port=%d\n",
            socket_flags(flags),
            NIPQUAD(saddr), ntohs(port));

    switch(socktype){
    case SOCK_DGRAM:  sockproto = IPPROTO_UDP; break;
    case SOCK_STREAM: sockproto = IPPROTO_TCP; break;
    }
    sock = socket(AF_INET, socktype, sockproto);
    if(sock < 0) goto exit;
    if(flags & VSOCK_REUSE){
        err = setsock_reuse(sock, 1);
        if(err < 0) goto exit;
    }
    if(flags & VSOCK_BROADCAST){
        err = setsock_broadcast(sock, 1);
        if(err < 0) goto exit;
    }
    if(flags & VSOCK_MULTICAST){
        err = setsock_multicast(sock, saddr);
        if(err < 0) goto exit;
    }
    if(flags & VSOCK_CONNECT){
        err = connect(sock, addr, addr_n);
        if(err < 0) goto exit;
    }
    if(flags & VSOCK_BIND){
        err = bind(sock, addr, addr_n);
        if(err < 0) goto exit;
    }
    if(flags & VSOCK_NONBLOCK){
        err = fcntl(sock, F_SETFL, O_NONBLOCK);
        if(err < 0) goto exit;
    }
  exit:
    *val = (err ? -1 : sock);
    if(err) eprintf("> err=%d errno=%d\n", err, errno);
    return err;
}
开发者ID:Angel666,项目名称:android_hardware_intel,代码行数:61,代码来源:varp_socket.c


示例12: ah_conn_in_get

static struct ip_vs_conn *
ah_conn_in_get(const struct sk_buff *skb,
	       struct ip_vs_protocol *pp,
	       const struct iphdr *iph,
	       unsigned int proto_off,
	       int inverse)
{
	struct ip_vs_conn *cp;

	if (likely(!inverse)) {
		cp = ip_vs_conn_in_get(IPPROTO_UDP,
				       iph->saddr,
				       htons(PORT_ISAKMP),
				       iph->daddr,
				       htons(PORT_ISAKMP));
	} else {
		cp = ip_vs_conn_in_get(IPPROTO_UDP,
				       iph->daddr,
				       htons(PORT_ISAKMP),
				       iph->saddr,
				       htons(PORT_ISAKMP));
	}

	if (!cp) {
		/*
		 * We are not sure if the packet is from our
		 * service, so our conn_schedule hook should return NF_ACCEPT
		 */
		IP_VS_DBG(12, "Unknown ISAKMP entry for outin packet "
			  "%s%s %u.%u.%u.%u->%u.%u.%u.%u\n",
			  inverse ? "ICMP+" : "",
			  pp->name,
			  NIPQUAD(iph->saddr),
			  NIPQUAD(iph->daddr));
	}

	return cp;
}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:38,代码来源:ip_vs_proto_ah.c


示例13: nlmsvc_grant_callback

/*
 * This is the callback from the RPC layer when the NLM_GRANTED_MSG
 * RPC call has succeeded or timed out.
 * Like all RPC callbacks, it is invoked by the rpciod process, so it
 * better not sleep. Therefore, we put the blocked lock on the nlm_blocked
 * chain once more in order to have it removed by lockd itself (which can
 * then sleep on the file semaphore without disrupting e.g. the nfs client).
 */
static void
nlmsvc_grant_callback(struct rpc_task *task)
{
	struct nlm_rqst		*call = (struct nlm_rqst *) task->tk_calldata;
	struct nlm_block	*block;
	unsigned long		timeout;
	struct sockaddr_in	*peer_addr = RPC_PEERADDR(task->tk_client);

	dprintk("lockd: GRANT_MSG RPC callback\n");
	dprintk("callback: looking for cookie %s, host %u.%u.%u.%u\n", 
		nlmdbg_cookie2a(&call->a_args.cookie),
		NIPQUAD(peer_addr->sin_addr.s_addr));
	if (!(block = nlmsvc_find_block(&call->a_args.cookie, peer_addr))) {
		dprintk("lockd: no block for cookie %s, host %u.%u.%u.%u\n",
				nlmdbg_cookie2a(&call->a_args.cookie),
				NIPQUAD(peer_addr->sin_addr.s_addr));
		return;
	}

	/* Technically, we should down the file semaphore here. Since we
	 * move the block towards the head of the queue only, no harm
	 * can be done, though. */
	if (task->tk_status < 0) {
		/* RPC error: Re-insert for retransmission */
		timeout = 10 * HZ;
	} else if (block->b_done) {
		/* Block already removed, kill it for real */
		timeout = 0;
	} else {
		/* Call was successful, now wait for client callback */
		timeout = 60 * HZ;
	}
	nlmsvc_insert_block(block, timeout);
	svc_wake_up(block->b_daemon);
	block->b_incall = 0;

	nlm_release_host(call->a_host);
}
开发者ID:SimonKagstrom,项目名称:mci500h-linux-2.4.27,代码行数:46,代码来源:svclock.c


示例14: validate_ipv4_address

bool validate_ipv4_address(const char *ip) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
    __be32 result_;

    return (in4_pton(ip, strlen(ip), (__u8 *) &result_, '\0', NULL) == 1);
#else
    char           src_ip_[50];
    __be32 result_ = in_aton(ip);
    sprintf(src_ip_, "%d.%d.%d.%d", NIPQUAD(result_));
    src_ip_[strlen(ip)] = '\0';

    return strcmp(ip, src_ip_) == 0;
#endif
}
开发者ID:houzhenggang,项目名称:module-http-whitelist,代码行数:14,代码来源:misc.c


示例15: execute_command2

/* Parses and executes the command using, if necessary, omega_interrupt */
int execute_command2(fd_set *dset) {
	char command[100];
	char cmd;
	unsigned int gid;
	int candidate, notif_type;
	unsigned int TdU, TmU, TmrL;
	struct omega_proc_struct leader;
	int retval = 0;

	scanf("%s", command);

	switch(command[0]) {
		case 'b' : scanf("%c", &cmd);
		           retval = omega_unregister(omega_interrupt);
		           if (retval >= 0) {
		               FD_CLR(omega_interrupt, dset);
		               omega_interrupt = 0;
			       }
		           return retval;
		case 'c' : scanf("%c %u %d %d %u %u %u", &cmd, &gid, &candidate,
				          &notif_type, &TdU, &TmU, &TmrL);
				   candidate = ((candidate == 1) ?
				       CANDIDATE : NOT_CANDIDATE);
				   notif_type = ((notif_type == 1) ?
				       OMEGA_INTERRUPT_ANY_CHANGE : OMEGA_INTERRUPT_NONE);
		           retval = omega_startOmega(omega_interrupt, gid,
		               candidate, notif_type, TdU, TmU, TmrL);
		           return retval;
		case 'd' : scanf("%c %u", &cmd, &gid);
		           retval = omega_stopOmega(omega_interrupt, gid);
		           return retval;
		case 'e' : scanf("%c %u", &cmd, &gid);
		           retval = omega_getleader(omega_interrupt, gid, &leader);
		           if (retval >= 0)
		               printf("Current leader of group: %u is pid: %u address:"
		                      " %u.%u.%u.%u\n", leader.gid, leader.pid,
		                      NIPQUAD(&leader.addr));
		           return retval;
		case 'f' : scanf("%c %u", &cmd, &gid);
		           retval = omega_interrupt_any_change(omega_interrupt,
		                                               gid);
		           return retval;
		case 'g' : scanf("%c %u", &cmd, &gid);
		           retval = omega_interrupt_none(omega_interrupt, gid);
		           return retval;
		case 'h' : exit(0);
		           break;
		default:   return -1;
	}
}
开发者ID:nschiper,项目名称:LeaderElection,代码行数:51,代码来源:ServiceTester.c


示例16: pptp_proc_read

static int pptp_proc_read(char *page, char **start, off_t off,
			       int count, int *eof, void *data)
{
	char *out = page;
	struct list_head	*l, *e;
        struct tuple_table	*tt;
        struct ip_conntrack_tuple *t;
	int len;

	out += sprintf (out, "GRE tuple list\n");

	l = &gre_list;
	for (e=l->next; e!=l; e=e->next) 
	{
		tt = list_entry(e, struct tuple_table, list);
		t = &tt->tuple;
		
		out += sprintf(out, "tuple %p: %u %u.%u.%u.%u CID:%hu -> %u.%u.%u.%u.  PCID=%hu, Master=%p\n",
				t, t->dst.protonum, 
				NIPQUAD(t->src.ip), ntohs(t->src.u.all), 
				NIPQUAD(t->dst.ip), ntohs(t->dst.u.gre.peer_call_id),
				tt->master);
        }

	len = out - page;
	len -= off;
	if (len < count) {
		*eof = 1;
		if (len <= 0)
			return 0;
	} else
		len = count;

	*start = page + off;

	return len;
}
开发者ID:nhanh0,项目名称:hah,代码行数:37,代码来源:ip_conntrack_pptp.c


示例17: zc_handle

void  zc_handle(unsigned char *user, const struct pcap_pkthdr *h, const unsigned char *bytes)
{
	struct ether_header *eth;
	struct iphdr *iph;
	struct tcphdr *th;
	const unsigned char *p = bytes;
	__u16 sport, dport;

	eth = (struct ether_header*)p;

	g_count ++;
	dump_skb("test", bytes, h->caplen);
	printf("\npacket:%d, snaplen:%d\n", g_count, h->caplen);

#if 1
	if (eth->ether_type == ntohs(ETHERTYPE_IP)){
		iph = (struct iphdr *)(eth + 1);
		sport = ((__u16 *)(((void *)iph) + (iph->ihl<<2)))[0];
		dport = ((__u16 *)(((void *)iph) + (iph->ihl<<2)))[1];

		printf("packet length: %d  %u.%u.%u.%u -> %u.%u.%u.%u,  protocal: l3 %x, l4 %u\n",
				h->len, NIPQUAD(iph->saddr), NIPQUAD(iph->daddr), ntohs(eth->ether_type), iph->protocol);
		printf("==================================================================\n");
            
		if(iph->protocol == IPPROTO_TCP) {
			//printf(" port %u -> %u", ntohs(sport), ntohs(dport));
			th = (struct tcphdr *)(((void *)iph) + (iph->ihl<<2));
			//printf("seq: %u, ack: %u, ", ntohl(th->seq), ntohl(th->ack_seq));
		}
		if(iph->protocol == IPPROTO_UDP) {
			//printf(" port %u -> %u", ntohs(sport), ntohs(dport));
		}
	}
	//printf("\n");
#endif
	return;
}
开发者ID:sunzhuo1987,项目名称:aegis--shield,代码行数:37,代码来源:sniff.c


示例18: rt_host_route_read_proc

static int rt_host_route_read_proc(char *buf, char **start, off_t offset,
                                   int count, int *eof, void *data)
{
    RTNET_PROC_PRINT_VARS;
    struct host_route   *entry_ptr;
    struct dest_route   dest_host;
    unsigned int        key;
    unsigned int        index;
    unsigned int        i;
    unsigned long       flags;


    RTNET_PROC_PRINT("Hash\tDestination\tHW Address\t\tDevice\n");
    for (key = 0; key < HOST_HASH_TBL_SIZE; key++) {
        index = 0;
        while (1) {
            rtos_spin_lock_irqsave(&host_table_lock, flags);

            entry_ptr = host_table[key];

            for (i = 0; (i < index) && (entry_ptr != NULL); i++)
                entry_ptr = entry_ptr->next;

            if (entry_ptr == NULL) {
                rtos_spin_unlock_irqrestore(&host_table_lock, flags);
                break;
            }

            memcpy(&dest_host, &entry_ptr->dest_host,
                   sizeof(struct dest_route));
            rtdev_reference(dest_host.rtdev);

            rtos_spin_unlock_irqrestore(&host_table_lock, flags);

            RTNET_PROC_PRINT("%02X\t%u.%u.%u.%-3u\t"
                             "%02X:%02X:%02X:%02X:%02X:%02X\t%s\n",
                             key, NIPQUAD(dest_host.ip),
                             dest_host.dev_addr[0], dest_host.dev_addr[1],
                             dest_host.dev_addr[2], dest_host.dev_addr[3],
                             dest_host.dev_addr[4], dest_host.dev_addr[5],
                             dest_host.rtdev->name);
            rtdev_dereference(dest_host.rtdev);

            index++;
        }
    }

    RTNET_PROC_PRINT_DONE;
}
开发者ID:BackupTheBerlios,项目名称:rtnet-svn,代码行数:49,代码来源:route.c


示例19: main

int main(int argc,char *argv[])
{
	struct mrtt_rx_packet rx_packet;
        int cmd0;
	struct stats *stats;

	memset(stations, 0, sizeof(stations));

	signal (SIGINT, endme);
          
        if ((cmd0 = open("/dev/rtf0", O_RDONLY)) < 0) {
		if ((cmd0 = open("/dev/rtf/0", O_RDONLY)) < 0) {
                	fprintf(stderr, "Error opening /dev/rtf/0 and /dev/rtf0\n");
			exit(1);
		}
        }

	initscr();      /* initialize the curses library */
	keypad(stdscr, TRUE);  /* enable keyboard mapping */
	nonl();         /* tell curses not to do NL->CR/NL on output */
	cbreak();       /* take input chars one at a time, no wait for \n */

	move(0,0);
	addstr("Showtime:");

        while(!end) {
                read (cmd0, &rx_packet, sizeof(struct mrtt_rx_packet));
		stats = lookup(rx_packet.ip_addr);
		if (!stats)
			continue;
		stats->rtt = (rx_packet.rx - rx_packet.tx)/1000;
		if (stats->rtt < stats->min)
			stats->min = stats->rtt;
		if (stats->rtt > stats->max)
			stats->max = stats->rtt;
		stats->count++;

		move(stats - stations + 1, 0);
		printw("%u.%u.%u.%u\t%dus, min=%dus, max=%dus, count=%d",
		       NIPQUAD(stats->ip),
		       stats->rtt, stats->min, stats->max, stats->count);
		refresh();
        }

	close(cmd0);
	endwin();

        return 0;
}
开发者ID:BackupTheBerlios,项目名称:rtnet-svn,代码行数:49,代码来源:showtime.c


示例20: ingress_purge_rcvd

static void ingress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc)
{
	__be32 dst_ip = msg->content.in_info.in_dst_ip;
	__be32 mask = msg->ip_mask;
	in_cache_entry *entry = mpc->in_ops->get_with_mask(dst_ip, mpc, mask);

	if(entry == NULL){
		printk("mpoa: (%s) ingress_purge_rcvd: purge for a non-existing entry, ", mpc->dev->name);
		printk("ip = %u.%u.%u.%u\n", NIPQUAD(dst_ip));
		return;
	}

	do {
		dprintk("mpoa: (%s) ingress_purge_rcvd: removing an ingress entry, ip = %u.%u.%u.%u\n" ,
			mpc->dev->name, NIPQUAD(dst_ip));
		write_lock_bh(&mpc->ingress_lock);
		mpc->in_ops->remove_entry(entry, mpc);
		write_unlock_bh(&mpc->ingress_lock);
		mpc->in_ops->put(entry);
		entry = mpc->in_ops->get_with_mask(dst_ip, mpc, mask);
	} while (entry != NULL);

	return;
}
开发者ID:StephenMacras,项目名称:dsl-n55u-bender,代码行数:24,代码来源:mpc.c



注:本文中的NIPQUAD函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ NLA_ALIGN函数代码示例发布时间:2022-05-30
下一篇:
C++ NINT函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap