blob: 9dd6f34731fae295de1e02a94ca0d0dc3b52e95b [file] [log] [blame]
rscbe7cbb42005-07-12 15:24:18 +00001.TH VENTI-SERVER 3
2.SH NAME
3vtsrvhello, vtlisten, vtgetreq, vtrespond \- Venti server
4.SH SYNOPSIS
5.PP
6.ft L
7#include <u.h>
8.br
9#include <libc.h>
10.br
11#include <venti.h>
12.ta +\w'\fLVtReq* 'u
13.PP
14.ft L
15.nf
16typedef struct VtReq
17{
18 VtFcall tx;
19 VtFcall rx;
20 ...
21} VtReq;
22.PP
23.B
24int vtsrvhello(VtConn *z)
25.PP
26.B
27VtSrv* vtlisten(char *addr)
28.PP
29.B
30VtReq* vtgetreq(VtSrv *srv)
31.PP
32.B
33void vtrespond(VtReq *req)
34.SH DESCRIPTION
35These routines execute the server side of the
36.IR venti (7)
37protocol.
38.PP
39.I Vtsrvhello
40executes the server side of the initial
41.B hello
42transaction.
43It sets
44.IB z -> uid
45with the user name claimed by the other side.
46Each new connection must be initialized by running
47.I vtversion
48and then
49.IR vtsrvhello .
50The framework below takes care of this detail automatically;
51.I vtsrvhello
52is provided for programs that do not use the functions below.
53.PP
54.IR Vtlisten ,
55.IR vtgetreq ,
56and
57.I vtrespond
58provide a simple framework for writing Venti servers.
59.PP
60.I Vtlisten
61announces at the network address
62.IR addr ,
63returning a fresh
64.B VtSrv
65structure representing the service.
66.PP
67.I Vtgetreq
68waits for and returns
69the next
70.BR read ,
71.BR write ,
72.BR sync ,
73or
74.B ping
75request from any client connected to
76the service
77.IR srv .
78.B Hello
79and
80.B goodbye
81messages are handled internally and not returned to the client.
82The interface does not distinguish between the
83different clients that may be connected at any given time.
84The request can be found in the
85.I tx
86field of the returned
87.BR VtReq .
88.PP
89Once a request has been served and a response stored in
90.IB r ->rx \fR,
91the server should call
92.IR vtrespond
93to send the response to the client.
94.I Vtrespond
95frees the structure
96.I r
97as well as the packets
98.IB r ->tx.data
99and
100.IB r ->rx.data \fR.
101.SH EXAMPLE
102.B \*9/src/venti/cmd
103contains two simple Venti servers
104.B ro.c
105and
106.B devnull.c
107written using these routines.
108.I Ro
109is a read-only Venti proxy (it rejects
110.B write
111requests).
112.I Devnull
113is a write-only Venti server: it discards all
114blocks written to it and returns error on all reads.
115.SH SOURCE
116.B \*9/src/libventi
117.SH SEE ALSO
118.IR venti (1),
119.IR venti (3),
120.IR venti-conn (3),
121.IR venti-packet (3)