5 int ventidoublechecksha1 = 1;
8 vtfcallrpc(VtConn *z, VtFcall *ou, VtFcall *in)
13 fprint(2, "%s -> %F\n", argv0, ou);
17 if((p = vtrpc(z, p)) == nil)
19 if(vtfcallunpack(in, p) < 0){
24 fprint(2, "%s <- %F\n", argv0, in);
25 if(in->type == VtRerror){
31 if(in->type != ou->type+1){
32 werrstr("type mismatch: sent %c%d got %c%d",
33 "TR"[ou->type&1], ou->type>>1,
34 "TR"[in->type&1], in->type>>1);
48 memset(&tx, 0, sizeof tx);
50 tx.version = z->version;
54 if(vtfcallrpc(z, &tx, &rx) < 0)
63 vtreadpacket(VtConn *z, uchar score[VtScoreSize], uint type, int n)
67 memset(&tx, 0, sizeof tx);
71 memmove(tx.score, score, VtScoreSize);
72 if(vtfcallrpc(z, &tx, &rx) < 0)
74 if(packetsize(rx.data) > n){
75 werrstr("read returned too much data");
79 if(ventidoublechecksha1){
80 packetsha1(rx.data, tx.score);
81 if(memcmp(score, tx.score, VtScoreSize) != 0){
82 werrstr("read asked for %V got %V", score, tx.score);
91 vtread(VtConn *z, uchar score[VtScoreSize], uint type, uchar *buf, int n)
96 if((p = vtreadpacket(z, score, type, n)) == nil)
99 if(packetconsume(p, buf, nn) < 0)
105 vtwritepacket(VtConn *z, uchar score[VtScoreSize], uint type, Packet *p)
112 if(ventidoublechecksha1)
113 packetsha1(p, score);
114 if(vtfcallrpc(z, &tx, &rx) < 0)
116 if(ventidoublechecksha1){
117 if(memcmp(score, rx.score, VtScoreSize) != 0){
118 werrstr("sha1 hash mismatch: want %V got %V", score, rx.score);
122 memmove(score, rx.score, VtScoreSize);
127 vtwrite(VtConn *z, uchar score[VtScoreSize], uint type, uchar *buf, int n)
131 p = packetforeign(buf, n, nil, nil);
132 return vtwritepacket(z, score, type, p);
141 return vtfcallrpc(z, &tx, &rx);
150 return vtfcallrpc(z, &tx, &rx);