Esempio n. 1
0
File: send.c Progetto: LucasBe/sendd
static unsigned int nd_hook(const struct nf_hook_ops *ops, 
                            struct sk_buff *skb, 
                            const struct net_device *in, 
                            const struct net_device *out, 
                            int (*okfn)(struct sk_buff *))
{
  struct ipv6hdr *ip6_header = ipv6_hdr(skb);
  struct icmp6hdr *icmp6_header;
  
  if(ip6_header->nexthdr == NEXTHDR_ICMP)
  {
    icmp6_header = icmp6_hdr(skb);
    switch(icmp6_header->icmp6_type)
    {
      case NDISC_ROUTER_SOLICITATION:
      case NDISC_ROUTER_ADVERTISEMENT:
      case NDISC_NEIGHBOUR_SOLICITATION:
      case NDISC_NEIGHBOUR_ADVERTISEMENT:
      case NDISC_REDIRECT:
        //printk(KERN_INFO "%s%s, ND packet.\n", in ? "Hello" : "", out ? "Farewell" : "");
        return NF_QUEUE_NR(SND_NFQ_NUM);
      default:
        return NF_ACCEPT;
    }
  } else {
    return NF_ACCEPT;
  }
}
static unsigned int
nfqueue_tg(struct sk_buff *skb, const struct xt_target_param *par)
{
	const struct xt_NFQ_info *tinfo = par->targinfo;

	return NF_QUEUE_NR(tinfo->queuenum);
}
Esempio n. 3
0
static void nft_queue_eval(const struct nft_expr *expr,
			   struct nft_data data[NFT_REG_MAX + 1],
			   const struct nft_pktinfo *pkt)
{
	struct nft_queue *priv = nft_expr_priv(expr);
	u32 queue = priv->queuenum;
	u32 ret;

	if (priv->queues_total > 1) {
		if (priv->flags & NFT_QUEUE_FLAG_CPU_FANOUT) {
			int cpu = smp_processor_id();

			queue = priv->queuenum + cpu % priv->queues_total;
		} else {
			queue = nfqueue_hash(pkt->skb, queue,
					     priv->queues_total, pkt->ops->pf,
					     jhash_initval);
		}
	}

	ret = NF_QUEUE_NR(queue);
	if (priv->flags & NFT_QUEUE_FLAG_BYPASS)
		ret |= NF_VERDICT_FLAG_QUEUE_BYPASS;

	data[NFT_REG_VERDICT].verdict = ret;
}
Esempio n. 4
0
int cb(struct nfq_q_handle *h, struct nfgenmsg *nfmsg, struct nfq_data *nfa, void *data)
{
        printf("Packet received \n");
int id = ntohl(nfq_get_msg_packet_hdr(nfa)->packet_id);
	nfq_set_verdict(h, id, NF_QUEUE_NR(1), 0, NULL);

}
Esempio n. 5
0
static void nft_queue_eval(const struct nft_expr *expr,
			   struct nft_regs *regs,
			   const struct nft_pktinfo *pkt)
{
	struct nft_queue *priv = nft_expr_priv(expr);
	u32 queue = priv->queuenum;
	u32 ret;

	if (priv->queues_total > 1) {
		if (priv->flags & NFT_QUEUE_FLAG_CPU_FANOUT) {
			int cpu = raw_smp_processor_id();

			queue = priv->queuenum + cpu % priv->queues_total;
		} else {
			queue = nfqueue_hash(pkt->skb, queue,
					     priv->queues_total, nft_pf(pkt),
					     jhash_initval);
		}
	}

	ret = NF_QUEUE_NR(queue);
	if (priv->flags & NFT_QUEUE_FLAG_BYPASS)
		ret |= NF_VERDICT_FLAG_QUEUE_BYPASS;

	regs->verdict.code = ret;
}
static unsigned int
nfqueue_tg(struct sk_buff *skb, const struct net_device *in,
           const struct net_device *out, unsigned int hooknum,
           const struct xt_target *target, const void *targinfo)
{
	const struct xt_NFQ_info *tinfo = targinfo;

	return NF_QUEUE_NR(tinfo->queuenum);
}
Esempio n. 7
0
static unsigned int
nfqueue_tg6_v1(struct sk_buff *skb, const struct xt_target_param *par)
{
    const struct xt_NFQ_info_v1 *info = par->targinfo;
    u32 queue = info->queuenum;

    if (info->queues_total > 1)
        queue = hash_v6(skb) % info->queues_total + queue;
    return NF_QUEUE_NR(queue);
}
Esempio n. 8
0
static unsigned int
nfqueue_tg_v1(struct sk_buff *skb, const struct xt_action_param *par)
{
	const struct xt_NFQ_info_v1 *info = par->targinfo;
	u32 queue = info->queuenum;

	if (info->queues_total > 1) {
		queue = nfqueue_hash(skb, queue, info->queues_total,
				     par->family, jhash_initval);
	}
	return NF_QUEUE_NR(queue);
}
static unsigned int
target(struct sk_buff **pskb,
       const struct net_device *in,
       const struct net_device *out,
       unsigned int hooknum,
       const void *targinfo,
       void *userinfo)
{
	const struct ipt_NFQ_info *tinfo = targinfo;

	return NF_QUEUE_NR(tinfo->queuenum);
}
Esempio n. 10
0
static void nft_queue_sreg_eval(const struct nft_expr *expr,
				struct nft_regs *regs,
				const struct nft_pktinfo *pkt)
{
	struct nft_queue *priv = nft_expr_priv(expr);
	u32 queue, ret;

	queue = regs->data[priv->sreg_qnum];

	ret = NF_QUEUE_NR(queue);
	if (priv->flags & NFT_QUEUE_FLAG_BYPASS)
		ret |= NF_VERDICT_FLAG_QUEUE_BYPASS;

	regs->verdict.code = ret;
}
static unsigned int
nfqueue_tg_v3(struct sk_buff *skb, const struct xt_action_param *par)
{
	const struct xt_NFQ_info_v3 *info = par->targinfo;
	u32 queue = info->queuenum;

	if (info->queues_total > 1) {
		if (info->flags & NFQ_FLAG_CPU_FANOUT) {
			int cpu = smp_processor_id();

			queue = info->queuenum + cpu % info->queues_total;
		} else {
			queue = nfqueue_hash(skb, queue, info->queues_total,
					     par->family, jhash_initval);
		}
	}

	return NF_QUEUE_NR(queue);
}