Ejemplo n.º 1
0
/*
 * Description: This function is called by Netfilter when packet hits
 *              the bridge pre routing hook. All IP packets are given
 *              to EMFL for its processing.
 *
 * Input:       skb - Pointer to the packet buffer. Other parameters
 *                     are not used.
 *
 * Return:      Returns the value indicating packet can be forwarded
 *              or packet is stolen.
 */
static uint32
emf_br_pre_hook(uint32 hook, struct sk_buff *skb,
                const struct net_device *in,
                const struct net_device *out,
                int32 (*okfn)(struct sk_buff *))
{
	emf_info_t *emfi;

	EMF_INFO("Frame at BR_PRE_HOOK received from if %p %s\n",
	         skb->dev, skb->dev->name);

	/* Find the bridge that the receive interface corresponds to */
	emfi = emf_instance_find_by_ifptr(emf, skb->dev);
	if (emfi == NULL)
	{
		EMF_INFO("No EMF processing needed for unknown ports\n");
		return (NF_ACCEPT);
	}

	/* Non IP packet received from LAN port is returned back to
	 * bridge.
	 */
	if (skb->protocol != __constant_htons(ETH_P_IP))
	{
		EMF_INFO("Ignoring non IP packets from LAN ports\n");
		return (NF_ACCEPT);
	}

	EMF_DUMP_PKT(skb->data);

	return (emfc_input(emfi->emfci, skb, skb->dev,
	                   PKTDATA(NULL, skb), FALSE));
}
Ejemplo n.º 2
0
/*
 * Description: This function is called by Netfilter when packet hits
 *              the ip post routing hook. The packet is sent to EMFL
 *              only when it is going on to bridge port.
 *
 * Input:       skb - Pointer to the packet buffer. Other parameters
 *                     are not used.
 *
 * Return:      Returns the value indicating packet can be forwarded
 *              or packet is stolen.
 */
static uint32
emf_ip_post_hook(uint32 hook, struct sk_buff *skb,
                 const struct net_device *in,
                 const struct net_device *out,
                 int32 (*okfn)(struct sk_buff *))
{
	emf_info_t *emfi;

	ASSERT(skb->protocol == __constant_htons(ETH_P_IP));

	EMF_DEBUG("Frame at IP_POST_HOOK going to if %p %s\n",
	          skb->dev, skb->dev->name);

	/* Find the LAN that the bridge interface corresponds to */
	emfi = emf_instance_find_by_brptr(emf, skb->dev);
	if (emfi == NULL)
	{
		EMF_INFO("No EMF processing needed for unknown ports\n");
		return (NF_ACCEPT);
	}

	EMF_DUMP_PKT(skb->data);

	return (emfc_input(emfi->emfci, skb, skb->dev,
	                   PKTDATA(NULL, skb), TRUE));
}
Ejemplo n.º 3
0
/*
 * Description: This function is called by Netfilter when packet hits
 *              the ip post routing hook. The packet is sent to EMFL
 *              only when it is going on to bridge port.
 *
 * Input:       pskb - Pointer to the packet buffer. Other parameters
 *                     are not used.
 *
 * Return:      Returns the value indicating packet can be forwarded
 *              or packet is stolen.
 */
static uint32
emf_ip_post_hook(
	uint32 hook,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
	struct sk_buff *skb,
#else
	struct sk_buff **pskb,
#endif
	const struct net_device *in,
	const struct net_device *out,
	int32 (*okfn)(struct sk_buff *))
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
	struct sk_buff **pskb = &skb;
#endif
	emf_info_t *emfi;

	ASSERT((*pskb)->protocol == __constant_htons(ETH_P_IP));

	EMF_DEBUG("Frame at IP_POST_HOOK going to if %p %s\n",
	          (*pskb)->dev, (*pskb)->dev->name);

	/* Find the LAN that the bridge interface corresponds to */
	emfi = emf_instance_find_by_brptr(emf, (*pskb)->dev);
	if (emfi == NULL)
	{
		EMF_INFO("No EMF processing needed for unknown ports\n");
		return (NF_ACCEPT);
	}

	EMF_DUMP_PKT((*pskb)->data);

	return (emfc_input(emfi->emfci, *pskb, (*pskb)->dev,
	                   PKTDATA(NULL, *pskb), TRUE));
}