int init_kgdboe(void)
{
	/* Already done? */
	if (configured == 2)
		return 0;

	if (strlen(config))
		option_setup(config);

	if (!configured) {
		printk("kgdboe: configuration incorrect - kgdboe not "
		       "loaded.\n");
		printk("  Usage: kgdboe=[src-port]@[src-ip]/[dev],[tgt-port]"
		       "@<tgt-ip>/[tgt-macaddr]\n");
		return -EINVAL;
	}

	if (netpoll_setup(&np)) {
		printk("kgdboe: netpoll_setup failed kgdboe failed\n");
		return -EINVAL;
	}

	if (kgdb_register_io_module(&local_kgdb_io_ops))
		return -EINVAL;

	printk(KERN_INFO "kgdboe: debugging over ethernet enabled\n");

	configured = 2;

	return 0;
}
Exemple #2
0
static int init_netdump(void)
{
	int configured = 0;

	if (strlen(config))
		configured = option_setup(config);

	if (!configured) {
		printk(KERN_ERR "netdump: not configured, aborting\n");
		return -EINVAL;
	}

	if (netpoll_setup(&np))
		return -EINVAL;

	if (magic1 || magic2)
		netdump_magic = magic1 + (((u64)magic2)<<32);

	/*
	 *  Allocate a separate stack for netdump.
	 */
	platform_init_stack(&netdump_stack);

	platform_jiffy_cycles(&jiffy_cycles);

	printk(KERN_INFO "netdump: network crash dump enabled\n");
	return 0;
}
static struct netconsole_target *alloc_param_target(char *target_config)
{
	int err = -ENOMEM;
	struct netconsole_target *nt;

	nt = kzalloc(sizeof(*nt), GFP_KERNEL);
	if (!nt)
		goto fail;

	nt->np.name = "netconsole";
	strlcpy(nt->np.dev_name, "eth0", IFNAMSIZ);
	nt->np.local_port = 6665;
	nt->np.remote_port = 6666;
	memset(nt->np.remote_mac, 0xff, ETH_ALEN);

	
	err = netpoll_parse_options(&nt->np, target_config);
	if (err)
		goto fail;

	err = netpoll_setup(&nt->np);
	if (err)
		goto fail;

	nt->enabled = 1;

	return nt;

fail:
	kfree(nt);
	return ERR_PTR(err);
}
Exemple #4
0
/*..........................................................................*/
void QF_onStartup(void)
{
#ifdef Q_SPY
	int rc;
	char *target_config = "@/,[email protected]/00:13:72:f7:14:73";

	np.name = "QSPY";
	strlcpy(np.dev_name, "eth0", IFNAMSIZ);
	np.local_port  = 6600;
	np.remote_port = 6601;
	memset(np.remote_mac, 0xff, ETH_ALEN);

	rc = netpoll_parse_options(&np, target_config);
	if (rc == 0) {
		rc = netpoll_setup(&np);
	}
	if (rc)
		np.dev = NULL;
	printk("rc: %d, %p\n", rc, np.dev);

	idle_running = 1;
	kthread_run(idleThread, NULL, "AO_Idle");
	complete(&idle_done);
#endif
}
Exemple #5
0
int init_kgdboe(void)
{
	if (!configured || netpoll_setup(&np))
		return 1;

	printk(KERN_INFO "kgdb: debugging over ethernet enabled\n");

	return 0;
}
/* Allocate new target (from boot/module param) and setup netpoll for it */
static struct brcm_netconsole_target *alloc_param_target(char *target_config)
{
	int err = -ENOMEM;
	struct brcm_netconsole_target *nt;
	u8 remote_mac[ETH_ALEN];

	/*
	 * Allocate and initialize with defaults.
	 * Note that these targets get their config_item fields zeroed-out.
	 */
	nt = kzalloc(sizeof(*nt), GFP_KERNEL);
	if (!nt) {
		pr_err("brcm_netconsole: failed to allocate memory\n");
		goto fail;
	}

	nt->np.name = "brcm_netconsole";
	strlcpy(nt->np.dev_name, "rndis0", IFNAMSIZ);
	nt->np.local_port = 5042;
	nt->np.remote_port = 5042;
	remote_mac[0] = 0xaa;
	remote_mac[1] = 0xbb;
	remote_mac[2] = 0xcc;
	remote_mac[3] = 0xdd;
	remote_mac[4] = 0xee;
	remote_mac[5] = 0xff;
	memcpy(nt->np.remote_mac, remote_mac, ETH_ALEN);
	nt->np.remote_ip = in_aton("255.255.255.255");
	nt->np.local_ip = in_aton("192.168.42.129");

	/* Parse parameters and setup netpoll */
#if 0				/* kevin */
	err = netpoll_parse_options(&nt->np, target_config);
	if (err)
		goto fail;
#endif

	err = netpoll_setup(&nt->np);
	if (err)
		goto fail;

	nt->enabled = 1;
	nt_enabled = TRUE;

	return nt;

fail:
	kfree(nt);
	return ERR_PTR(err);
}
Exemple #7
0
static int init_netconsole(void)
{
	if(strlen(config))
		option_setup(config);

	if(!configured) {
		printk("netconsole: not configured, aborting\n");
		return -EINVAL;
	}

	if(netpoll_setup(&np))
		return -EINVAL;

	register_console(&netconsole);
	printk(KERN_INFO "netconsole: network logging started\n");
	return 0;
}
Exemple #8
0
/* Allocate new target (from boot/module param) and setup netpoll for it */
static struct netpoll_target *alloc_param_target(struct netpoll_targets *nts,
						 char *target_config)
{
	int err = -ENOMEM;
	struct netpoll_target *nt;

	/*
	 * Allocate and initialize with defaults.
	 * Note that these targets get their config_item fields zeroed-out.
	 */
	nt = kzalloc(sizeof(*nt), GFP_KERNEL);
	if (!nt) {
		printk(KERN_ERR "%s: failed to allocate memory\n",
		       nts->subsys_name);
		goto fail;
	}

	nt->nts = nts;
	nt->np.name = nts->subsys_name;
	strlcpy(nt->np.dev_name, "eth0", IFNAMSIZ);
	nt->np.local_port = nts->default_local_port;
	nt->np.remote_port = nts->default_remote_port;
	memset(nt->np.remote_mac, 0xff, ETH_ALEN);
	INIT_WORK(&nt->cleanup_work, deferred_netpoll_cleanup);

	/* Parse parameters and setup netpoll */
	err = netpoll_parse_options(&nt->np, target_config);
	if (err)
		goto fail;

	err = netpoll_setup(&nt->np);
	if (err)
		goto fail;

	nt->np_state = NETPOLL_ENABLED;

	return nt;

fail:
	kfree(nt);
	return ERR_PTR(err);
}
/* 
 * Function to initiate the sending parameters 
 * make sure to call init_netpoll before calling sendUdp()
 */
void init_netpoll(char *input_ip)
{
	
	u8 tmp[4];
        int ret;

	//convert the ipv4 to integer
	ret = in4_pton(input_ip, -1, tmp, -1, NULL);
        __u32 ip = 0;

        /* hack to convert byte array to __u32 */
        ip |= tmp[0] & 0xFF;
        ip <<= 8;
        ip |= tmp[1] & 0xFF;
        ip <<= 8;
        ip |= tmp[2] & 0xFF;
        ip <<= 8;
        ip |= tmp[3] & 0xFF;


	np_t.name = "LRNG";
	strlcpy(np_t.dev_name, "eth0", IFNAMSIZ);
	
	np_t.local_ip.ip = htonl((unsigned long int)0xc0a83865); 
	np_t.local_ip.in.s_addr = htonl((unsigned long int)0xc0a3865); 
	
	np_t.remote_ip.ip = htonl((unsigned long int)ip); 
	np_t.remote_ip.in.s_addr = htonl((unsigned long int)ip); 
    
	np_t.ipv6 = 0;//no IPv6
	
	np_t.local_port = 6666;
	np_t.remote_port = 514;
        
	memset(np_t.remote_mac, 0xff, ETH_ALEN);
        netpoll_print_options(&np_t);
        
	netpoll_setup(&np_t);
        np = &np_t;
}
/* Allocate new target (from boot/module param) and setup netpoll for it */
static struct netconsole_target *alloc_param_target(char *target_config)
{
	int err = -ENOMEM;
	struct netconsole_target *nt;

	/*
	 * Allocate and initialize with defaults.
	 * Note that these targets get their config_item fields zeroed-out.
	 */
	nt = kzalloc(sizeof(*nt), GFP_KERNEL);
	if (!nt) {
		printk(KERN_ERR "netconsole: failed to allocate memory\n");
		goto fail;
	}

	nt->np.name = "netconsole";
	strlcpy(nt->np.dev_name, "eth0", IFNAMSIZ);
	nt->np.local_port = 6665;
	nt->np.remote_port = 6666;
	memset(nt->np.remote_mac, 0xff, ETH_ALEN);

	/* Parse parameters and setup netpoll */
	err = netpoll_parse_options(&nt->np, target_config);
	if (err)
		goto fail;

	err = netpoll_setup(&nt->np);
	if (err)
		goto fail;

	nt->enabled = 1;

	return nt;

fail:
	kfree(nt);
	return ERR_PTR(err);
}
Exemple #11
0
struct netpoll_wrapper *netpoll_wrapper_create(const char *pDeviceName, int localPort, const char *pOptionalLocalIp)
{
	struct net_device *pDevice;
	struct netpoll_wrapper *pResult;
	int localIp;
	int err;

	if (!pDeviceName || !localPort)
	{
		printk(KERN_ERR "kgdboe: cannot create a netpoll wrapper without a device name\n");
		return NULL;
	}

	pDevice = dev_get_by_name(&init_net, pDeviceName);
	if (!pDevice)
	{
		printk(KERN_ERR "kgdboe: Cannot find network device by name: %s\n", pDeviceName);
		return NULL;
	}


	if (pOptionalLocalIp)
	{
		localIp = in_aton(pOptionalLocalIp);
		if (!localIp)
		{
			printk(KERN_ERR "kgdboe: Invalid local IP: %s\n", pOptionalLocalIp);
			return NULL;
		}
	}
	else
	{
		if (!pDevice->ip_ptr)
		{
			printk(KERN_ERR "kgdboe: %s does not have an in_device associated. Cannot get default IP address.\n", pDeviceName);
			return NULL;
		}
		if (!pDevice->ip_ptr->ifa_list)
		{
			printk(KERN_ERR "kgdboe: %s does not have a in_ifaddr struct associated. Cannot get default IP address.\n", pDeviceName);
			return NULL;
		}

		localIp = pDevice->ip_ptr->ifa_list->ifa_local;
	}

	pResult = (struct netpoll_wrapper *)kmalloc(sizeof(struct netpoll_wrapper), GFP_KERNEL);
	if (!pResult)
	{
		printk(KERN_ERR "kgdboe: cannot allocate memory for netpoll wrapper\n");
		return NULL;
	}

	memset(pResult, 0, sizeof(*pResult));

#ifdef NETPOLL_POLL_DEV_USABLE
	pResult->netpoll_poll_dev = (void(*)(struct net_device *))kallsyms_lookup_name("netpoll_poll_dev");
	if (!pResult->netpoll_poll_dev)
	{
		printk(KERN_ERR "kgdboe: Cannot find netpoll_poll_dev(). Aborting.\n");
		netpoll_wrapper_free(pResult);
		return NULL;
	}
#else
	pResult->zap_completion_queue = (void(*)(void))kallsyms_lookup_name("zap_completion_queue");
	if (!pResult->zap_completion_queue)
	{
		printk(KERN_ERR "kgdboe: Cannot find zap_completion_queue(). Aborting.\n");
		netpoll_wrapper_free(pResult);
		return NULL;
	}
#endif

	rtnl_lock();
	err = netdev_rx_handler_register(pDevice, netpoll_wrapper_rx_handler, pResult);
	rtnl_unlock();
	if (err < 0)
	{
		printk(KERN_ERR "kgdboe: Failed to register rx handler for %s, code %d\n", pDeviceName, err);
		netpoll_wrapper_free(pResult);
		return NULL;
	}

	register_tracepoint_wrapper(netif_receive_skb, hook_receive_skb, pResult);
	pResult->tracepoint_registered = true;

	pResult->pDeviceWithHandler = pDevice;

	strncpy(pResult->netpoll_obj.dev_name, pDeviceName, sizeof(pResult->netpoll_obj.dev_name));
	pResult->netpoll_obj.name = "kgdboe";
	pResult->netpoll_obj.local_port = localPort;
	memset(pResult->netpoll_obj.remote_mac, 0xFF, sizeof(pResult->netpoll_obj.remote_mac));

	err = netpoll_setup(&pResult->netpoll_obj);
	if (err < 0)
	{
		printk(KERN_ERR "kgdboe: Failed to setup netpoll for %s, code %d\n", pDeviceName, err);
		netpoll_wrapper_free(pResult);
		return NULL;
	}

	pResult->netpoll_initialized = true;

	return pResult;
}