Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
 
4
/*
5
 * Since the SSL device uses decimal file descriptors to name channels,
6
 * it is impossible for a user-level file server to stand in for the kernel device.
7
 * Thus we hard-code #D rather than use /net/ssl.
8
 */
9
 
10
int
11
pushssl(int fd, char *alg, char *secin, char *secout, int *cfd)
12
{
13
	char buf[8];
14
	char dname[64];
15
	int n, data, ctl;
16
 
17
	ctl = open("#D/ssl/clone", ORDWR);
18
	if(ctl < 0)
19
		return -1;
20
	n = read(ctl, buf, sizeof(buf)-1);
21
	if(n < 0)
22
		goto error;
23
	buf[n] = 0;
24
	sprint(dname, "#D/ssl/%s/data", buf);
25
	data = open(dname, ORDWR);
26
	if(data < 0)
27
		goto error;
28
	if(fprint(ctl, "fd %d", fd) < 0 ||
29
	   fprint(ctl, "secretin %s", secin) < 0 ||
30
	   fprint(ctl, "secretout %s", secout) < 0 ||
31
	   fprint(ctl, "alg %s", alg) < 0){
32
		close(data);
33
		goto error;
34
	}
35
	close(fd);
36
	if(cfd != 0)
37
		*cfd = ctl;
38
	else
39
		close(ctl);
40
	return data;
41
error:
42
	close(ctl);
43
	return -1;
44
}