1 056fe1ba 2003-11-23 devnull #include <u.h>
2 056fe1ba 2003-11-23 devnull #include <libc.h>
3 056fe1ba 2003-11-23 devnull #include <venti.h>
6 056fe1ba 2003-11-23 devnull vtsrvhello(VtConn *z)
8 056fe1ba 2003-11-23 devnull VtFcall tx, rx;
9 056fe1ba 2003-11-23 devnull Packet *p;
11 361e279c 2005-01-18 devnull if((p = vtrecv(z)) == nil)
12 2e965b33 2004-05-05 devnull return -1;
14 056fe1ba 2003-11-23 devnull if(vtfcallunpack(&tx, p) < 0){
15 056fe1ba 2003-11-23 devnull packetfree(p);
16 2e965b33 2004-05-05 devnull return -1;
18 056fe1ba 2003-11-23 devnull packetfree(p);
20 7643b263 2005-07-13 devnull if(tx.msgtype != VtThello){
21 056fe1ba 2003-11-23 devnull vtfcallclear(&tx);
22 7643b263 2005-07-13 devnull werrstr("bad packet type %d; want Thello %d", tx.msgtype, VtThello);
23 2e965b33 2004-05-05 devnull return -1;
25 056fe1ba 2003-11-23 devnull if(tx.tag != 0){
26 056fe1ba 2003-11-23 devnull vtfcallclear(&tx);
27 056fe1ba 2003-11-23 devnull werrstr("bad tag in hello");
28 2e965b33 2004-05-05 devnull return -1;
30 056fe1ba 2003-11-23 devnull if(strcmp(tx.version, z->version) != 0){
31 056fe1ba 2003-11-23 devnull vtfcallclear(&tx);
32 056fe1ba 2003-11-23 devnull werrstr("bad version in hello");
33 2e965b33 2004-05-05 devnull return -1;
35 056fe1ba 2003-11-23 devnull vtfree(z->uid);
36 056fe1ba 2003-11-23 devnull z->uid = tx.uid;
37 056fe1ba 2003-11-23 devnull tx.uid = nil;
38 056fe1ba 2003-11-23 devnull vtfcallclear(&tx);
40 056fe1ba 2003-11-23 devnull memset(&rx, 0, sizeof rx);
41 7643b263 2005-07-13 devnull rx.msgtype = VtRhello;
42 056fe1ba 2003-11-23 devnull rx.tag = tx.tag;
43 056fe1ba 2003-11-23 devnull rx.sid = "anonymous";
44 056fe1ba 2003-11-23 devnull if((p = vtfcallpack(&rx)) == nil)
45 2e965b33 2004-05-05 devnull return -1;
46 056fe1ba 2003-11-23 devnull if(vtsend(z, p) < 0)
47 2e965b33 2004-05-05 devnull return -1;
49 2e965b33 2004-05-05 devnull return 0;