예제 #1
0
DEBUG_NO_STATIC struct net_device_stats *ipsec_mast_get_stats(
    struct net_device *dev)
{
    return &(netdev_to_mastpriv(dev)->mystats);
}
예제 #2
0
/*
 * Revectored calls.
 * For each of these calls, a field exists in our private structure.
 */
DEBUG_NO_STATIC int ipsec_mast_hard_header(struct sk_buff *skb,
        struct net_device *dev,
        unsigned short type, void *daddr,
        void *saddr, unsigned len)
{
    struct mastpriv *mprv = netdev_to_mastpriv(dev);
    struct net_device_stats *stats; /* This device's statistics */
    int ret = 0;

    if (skb == NULL) {
        KLIPS_PRINT(debug_mast & DB_MAST_REVEC,
                    "klips_debug:ipsec_mast_hard_header: "
                    "no skb...\n");
        return -ENODATA;
    }

    if (dev == NULL) {
        KLIPS_PRINT(debug_mast & DB_MAST_REVEC,
                    "klips_debug:ipsec_mast_hard_header: "
                    "no device...\n");
        return -ENODEV;
    }

    KLIPS_PRINT(debug_mast & DB_MAST_REVEC,
                "klips_debug:ipsec_mast_hard_header: "
                "skb->dev=%s\n",
                dev->name);

    if (prv == NULL) {
        KLIPS_PRINT(debug_mast & DB_MAST_REVEC,
                    "klips_debug:ipsec_mast_hard_header: "
                    "no private space associated with dev=%s\n",
                    dev->name ? dev->name : "NULL");
        return -ENODEV;
    }

    stats = (struct net_device_stats *) &(prv->mystats);

    /* check if we have to send a IPv6 packet. It might be a Router
       Solicitation, where the building of the packet happens in
       reverse order:
       1. ll hdr,
       2. IPv6 hdr,
       3. ICMPv6 hdr
       -> skb->nh.raw is still uninitialized when this function is
       called!!  If this is no IPv6 packet, we can print debugging
       messages, otherwise we skip all debugging messages and just
       build the ll header */
    if (type != ETH_P_IPV6) {
        /* execute this only, if we don't have to build the
           header for a IPv6 packet */
        if (!prv->hard_header) {
            KLIPS_PRINT(debug_mast & DB_MAST_REVEC,
                        "klips_debug:ipsec_mast_hard_header: "
                        "physical device has been detached, packet dropped 0p%p->0p%p len=%d type=%d dev=%s->NULL ",
                        saddr,
                        daddr,
                        len,
                        type,
                        dev->name);
            KLIPS_PRINTMORE(debug_mast & DB_MAST_REVEC,
                            "ip=%08x->%08x\n",
                            (__u32)ntohl(skb->nh.iph->saddr),
                            (__u32)ntohl(skb->nh.iph->daddr) );
            stats->tx_dropped++;
            return -ENODEV;
        }
    } else {
        KLIPS_PRINT(debug_mast,
                    "klips_debug:ipsec_mast_hard_header: "
                    "is IPv6 packet, skip debugging messages, only revector and build linklocal header.\n");
    }

    return ret;
}
예제 #3
0
int ipsec_mast_device_event(struct notifier_block *unused, unsigned long event,
			    void *ptr)
{
	struct net_device *dev = ptr;
	struct mastpriv *priv = netdev_to_mastpriv(dev);

	priv = priv;

	if (dev == NULL) {
		KLIPS_PRINT(debug_mast & DB_MAST_INIT,
			    "klips_debug:ipsec_mast_device_event: "
			    "dev=NULL for event type %ld.\n",
			    event);
		return NOTIFY_DONE;
	}

	/* check for loopback devices */
	if (dev && (dev->flags & IFF_LOOPBACK))
		return NOTIFY_DONE;

	switch (event) {
	case NETDEV_DOWN:
	/* look very carefully at the scope of these compiler
	   directives before changing anything... -- RGB */

	case NETDEV_UNREGISTER:
		switch (event) {
		case NETDEV_DOWN:
			KLIPS_PRINT(debug_mast & DB_MAST_INIT,
				    "klips_debug:ipsec_mast_device_event: "
				    "NETDEV_DOWN dev=%s flags=%x\n",
				    dev->name,
				    dev->flags);
			if (strncmp(dev->name, "ipsec",
				    strlen("ipsec")) == 0) {
				printk(
					KERN_CRIT "IPSEC EVENT: KLIPS device %s shut down.\n",
					dev->name);
			}
			break;
		case NETDEV_UNREGISTER:
			KLIPS_PRINT(debug_mast & DB_MAST_INIT,
				    "klips_debug:ipsec_mast_device_event: "
				    "NETDEV_UNREGISTER dev=%s flags=%x\n",
				    dev->name,
				    dev->flags);
			break;
		}
		break;

	case NETDEV_UP:
		KLIPS_PRINT(debug_mast & DB_MAST_INIT,
			    "klips_debug:ipsec_mast_device_event: "
			    "NETDEV_UP dev=%s\n",
			    dev->name);
		break;

	case NETDEV_REBOOT:
		KLIPS_PRINT(debug_mast & DB_MAST_INIT,
			    "klips_debug:ipsec_mast_device_event: "
			    "NETDEV_REBOOT dev=%s\n",
			    dev->name);
		break;

	case NETDEV_CHANGE:
		KLIPS_PRINT(debug_mast & DB_MAST_INIT,
			    "klips_debug:ipsec_mast_device_event: "
			    "NETDEV_CHANGE dev=%s flags=%x\n",
			    dev->name,
			    dev->flags);
		break;

	case NETDEV_REGISTER:
		KLIPS_PRINT(debug_mast & DB_MAST_INIT,
			    "klips_debug:ipsec_mast_device_event: "
			    "NETDEV_REGISTER dev=%s\n",
			    dev->name);
		break;

	case NETDEV_CHANGEMTU:
		KLIPS_PRINT(debug_mast & DB_MAST_INIT,
			    "klips_debug:ipsec_mast_device_event: "
			    "NETDEV_CHANGEMTU dev=%s to mtu=%d\n",
			    dev->name,
			    dev->mtu);
		break;

	case NETDEV_CHANGEADDR:
		KLIPS_PRINT(debug_mast & DB_MAST_INIT,
			    "klips_debug:ipsec_mast_device_event: "
			    "NETDEV_CHANGEADDR dev=%s\n",
			    dev->name);
		break;

	case NETDEV_GOING_DOWN:
		KLIPS_PRINT(debug_mast & DB_MAST_INIT,
			    "klips_debug:ipsec_mast_device_event: "
			    "NETDEV_GOING_DOWN dev=%s\n",
			    dev->name);
		break;

	case NETDEV_CHANGENAME:
		KLIPS_PRINT(debug_mast & DB_MAST_INIT,
			    "klips_debug:ipsec_mast_device_event: "
			    "NETDEV_CHANGENAME dev=%s\n",
			    dev->name);
		break;

	default:
		KLIPS_PRINT(debug_mast & DB_MAST_INIT,
			    "klips_debug:ipsec_mast_device_event: "
			    "event type %ld unrecognised for dev=%s\n",
			    event,
			    dev->name);
		break;
	}
	return NOTIFY_DONE;
}