fcallfmt.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include <u.h>
  10. #include <libc.h>
  11. #include <venti.h>
  12. int
  13. vtfcallfmt(Fmt *f)
  14. {
  15. VtFcall *t;
  16. t = va_arg(f->args, VtFcall*);
  17. if(t == nil){
  18. fmtprint(f, "<nil fcall>");
  19. return 0;
  20. }
  21. switch(t->msgtype){
  22. default:
  23. return fmtprint(f, "%c%d tag %u", "TR"[t->msgtype&1], t->msgtype>>1, t->tag);
  24. case VtRerror:
  25. return fmtprint(f, "Rerror tag %u error %s", t->tag, t->error);
  26. case VtTping:
  27. return fmtprint(f, "Tping tag %u", t->tag);
  28. case VtRping:
  29. return fmtprint(f, "Rping tag %u", t->tag);
  30. case VtThello:
  31. return fmtprint(f, "Thello tag %u vers %s uid %s strength %d crypto %d:%.*H codec %d:%.*H", t->tag,
  32. t->version, t->uid, t->strength, t->ncrypto, t->ncrypto, t->crypto,
  33. t->ncodec, t->ncodec, t->codec);
  34. case VtRhello:
  35. return fmtprint(f, "Rhello tag %u sid %s rcrypto %d rcodec %d", t->tag, t->sid, t->rcrypto, t->rcodec);
  36. case VtTgoodbye:
  37. return fmtprint(f, "Tgoodbye tag %u", t->tag);
  38. case VtRgoodbye:
  39. return fmtprint(f, "Rgoodbye tag %u", t->tag);
  40. case VtTauth0:
  41. return fmtprint(f, "Tauth0 tag %u auth %.*H", t->tag, t->nauth, t->auth);
  42. case VtRauth0:
  43. return fmtprint(f, "Rauth0 tag %u auth %.*H", t->tag, t->nauth, t->auth);
  44. case VtTauth1:
  45. return fmtprint(f, "Tauth1 tag %u auth %.*H", t->tag, t->nauth, t->auth);
  46. case VtRauth1:
  47. return fmtprint(f, "Rauth1 tag %u auth %.*H", t->tag, t->nauth, t->auth);
  48. case VtTread:
  49. return fmtprint(f, "Tread tag %u score %V blocktype %d count %d", t->tag, t->score, t->blocktype, t->count);
  50. case VtRread:
  51. return fmtprint(f, "Rread tag %u count %d", t->tag, packetsize(t->data));
  52. case VtTwrite:
  53. return fmtprint(f, "Twrite tag %u blocktype %d count %d", t->tag, t->blocktype, packetsize(t->data));
  54. case VtRwrite:
  55. return fmtprint(f, "Rwrite tag %u score %V", t->tag, t->score);
  56. case VtTsync:
  57. return fmtprint(f, "Tsync tag %u", t->tag);
  58. case VtRsync:
  59. return fmtprint(f, "Rsync tag %u", t->tag);
  60. }
  61. }