fcallfmt.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <venti.h>
  4. int
  5. vtfcallfmt(Fmt *f)
  6. {
  7. VtFcall *t;
  8. t = va_arg(f->args, VtFcall*);
  9. if(t == nil){
  10. fmtprint(f, "<nil fcall>");
  11. return 0;
  12. }
  13. switch(t->msgtype){
  14. default:
  15. return fmtprint(f, "%c%d tag %ud", "TR"[t->msgtype&1], t->msgtype>>1, t->tag);
  16. case VtRerror:
  17. return fmtprint(f, "Rerror tag %ud error %s", t->tag, t->error);
  18. case VtTping:
  19. return fmtprint(f, "Tping tag %ud", t->tag);
  20. case VtRping:
  21. return fmtprint(f, "Rping tag %ud", t->tag);
  22. case VtThello:
  23. return fmtprint(f, "Thello tag %ud vers %s uid %s strength %d crypto %d:%.*H codec %d:%.*H", t->tag,
  24. t->version, t->uid, t->strength, t->ncrypto, t->ncrypto, t->crypto,
  25. t->ncodec, t->ncodec, t->codec);
  26. case VtRhello:
  27. return fmtprint(f, "Rhello tag %ud sid %s rcrypto %d rcodec %d", t->tag, t->sid, t->rcrypto, t->rcodec);
  28. case VtTgoodbye:
  29. return fmtprint(f, "Tgoodbye tag %ud", t->tag);
  30. case VtRgoodbye:
  31. return fmtprint(f, "Rgoodbye tag %ud", t->tag);
  32. case VtTauth0:
  33. return fmtprint(f, "Tauth0 tag %ud auth %.*H", t->tag, t->nauth, t->auth);
  34. case VtRauth0:
  35. return fmtprint(f, "Rauth0 tag %ud auth %.*H", t->tag, t->nauth, t->auth);
  36. case VtTauth1:
  37. return fmtprint(f, "Tauth1 tag %ud auth %.*H", t->tag, t->nauth, t->auth);
  38. case VtRauth1:
  39. return fmtprint(f, "Rauth1 tag %ud auth %.*H", t->tag, t->nauth, t->auth);
  40. case VtTread:
  41. return fmtprint(f, "Tread tag %ud score %V blocktype %d count %d", t->tag, t->score, t->blocktype, t->count);
  42. case VtRread:
  43. return fmtprint(f, "Rread tag %ud count %d", t->tag, packetsize(t->data));
  44. case VtTwrite:
  45. return fmtprint(f, "Twrite tag %ud blocktype %d count %d", t->tag, t->blocktype, packetsize(t->data));
  46. case VtRwrite:
  47. return fmtprint(f, "Rwrite tag %ud score %V", t->tag, t->score);
  48. case VtTsync:
  49. return fmtprint(f, "Tsync tag %ud", t->tag);
  50. case VtRsync:
  51. return fmtprint(f, "Rsync tag %ud", t->tag);
  52. }
  53. }