Пример #1
0
void
vpn_user_init (struct config_data_vpn *vpn, char *seed, int len)
{
	int d, d1;
	struct config_data_vpn *p;
	char *q;
	struct msgbuf buf[2];

	mp = mempool_new (0, 1, true);
	d = newprocess ("vpn");
	if (d < 0)
		panic ("newprocess vpn");
	d1 = msgopen ("ttyout");
	if (d1 < 0)
		panic ("msgopen ttyout");
	msgsenddesc (d, d1);
	msgsenddesc (d, d1);
	msgclose (d1);
	p = mempool_allocmem (mp, sizeof *p);
	memcpy (p, vpn, sizeof *p);
	q = mempool_allocmem (mp, len);
	memcpy (q, seed, len);
	setmsgbuf (&buf[0], p, sizeof *p, 0);
	setmsgbuf (&buf[1], q, sizeof *q, 0);
	if (msgsendbuf (d, 0, buf, 2))
		panic ("vpn init failed");
	mempool_freemem (mp, q);
	mempool_freemem (mp, p);
	msgclose (d);
}
Пример #2
0
void
sendex (char *buf)
{
	unsigned char d[32];
	int a, i;

	a = msgopen ("recvex");
	if (a < 0) {
		printf ("msgopen failed.\n");
		return;
	}
	memset (d, 0, 32);
	printf ("sending buf %p len 0x%x recvbuf %p len 0x%lx\n",
		buf, strlen (buf), d, (unsigned long)sizeof d);
	if (msgsendbuf (a, 0, buf, strlen (buf), d, sizeof d)) {
		printf ("msgsendbuf failed.\n");
		msgclose (a);
		return;
	}
	msgclose (a);
	printf ("received: ");
	for (i = 0; i < 32; i++)
		printf ("0x%02x ", d[i]);
	printf ("\n");
}
Пример #3
0
static void
callsub (int c, struct msgbuf *buf, int bufcnt)
{
	int r;

	for (;;) {
		r = msgsendbuf (desc, c, buf, bufcnt);
		if (r == 0)
			break;
		panic ("vpn msgsendbuf failed (%d)", c);
	}
}