1
0

network 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. _ni=0; // network indent level
  2. defn
  3. _ni() {
  4. loop 1,_ni do {
  5. print("\t");
  6. }
  7. }
  8. defn
  9. ipdev(n) {
  10. _ipfs(*(ipfs+4*n));
  11. }
  12. // the funny _foo/foo pairs exist so that if we get
  13. // interrupted in the middle of one of these, _ni will
  14. // get reset to 0 next time an external call happens.
  15. defn
  16. _ipfs(fs) {
  17. complex Fs fs;
  18. local i;
  19. print("ipfs(", fs\X, ") #I", fs.dev\D, "\n");
  20. i=0;
  21. _ni = _ni+1;
  22. while i < fs.np do {
  23. _proto(*(fs.p+i*4));
  24. i = i + 1;
  25. }
  26. _ni = _ni-1;
  27. }
  28. defn
  29. ipfs(fs) {
  30. _ni = 0;
  31. _ipfs(fs);
  32. }
  33. defn
  34. _proto(p) {
  35. local c;
  36. complex Proto p;
  37. _ni();
  38. print("proto(", p\X, ") ", *(p.name\s), "\n");
  39. _ni = _ni+1;
  40. local i;
  41. i = 0;
  42. while i < p.nc do {
  43. c = *(p.conv+i*4);
  44. complex Conv c;
  45. if c != 0 && c.inuse then
  46. _conv(*(p.conv+i*4));
  47. i = i + 1;
  48. }
  49. _ni = _ni - 1;
  50. }
  51. defn
  52. proto(p) {
  53. _ni = 0;
  54. _proto(p);
  55. }
  56. defn
  57. _conv(c) {
  58. complex Conv c;
  59. _ni();
  60. local p;
  61. p = c.p;
  62. complex Proto p;
  63. print("conv(", c\X, ") ", *(p.name\s), "/", c.x\D, " ",
  64. iptostr(*(c.laddr+12)), "!", c.lport\D, " ", iptostr(*(c.raddr+12)),
  65. "!", c.rport\D, " rq ", qtostr(c.rq), " wq ", qtostr(c.wq),
  66. " eq ", qtostr(c.eq), "\n");
  67. }
  68. defn
  69. conv(c) {
  70. _ni = 0;
  71. _conv(c);
  72. }
  73. defn
  74. iptostr(a)
  75. {
  76. // BUG: little endian
  77. return itoa(a&0xFF)+"."+itoa((a>>8)&0xFF)+"."+itoa((a>>16)&0xFF)+"."+itoa((a>>24)&0xFF);
  78. }
  79. defn
  80. qtostr(q)
  81. {
  82. complex Queue q;
  83. return "queue("+itoa(q, "%lx")+") ["+itoa(q.len, "%d")+","+itoa(q.dlen, "%d")+","+itoa(qblocks(q), "%d")+"]";
  84. }
  85. defn
  86. qblocks(q)
  87. {
  88. complex Queue q;
  89. local b, n;
  90. b = q.bfirst;
  91. n = 0;
  92. while b != 0 do {
  93. n = n + 1;
  94. complex Block b;
  95. b = b.next;
  96. }
  97. return n;
  98. }
  99. defn
  100. _queue(q)
  101. {
  102. complex Queue q;
  103. local b;
  104. print("queue(", q\X, ") len ", q.len\D, " dlen ", q.dlen\D, " limit ", q.limit\D, " nblocks ", qblocks(q)\D);
  105. if q.state & Qstarve then
  106. print(" starve");
  107. if q.state & Qmsg then
  108. print(" msg");
  109. if q.state & Qclosed then
  110. print(" closed");
  111. if q.state & Qflow then
  112. print(" flow");
  113. if q.state & Qcoalesce then
  114. print(" coalesce");
  115. print("\n");
  116. b = q.bfirst;
  117. _ni = _ni+1;
  118. while b != 0 do {
  119. _block(b);
  120. complex Block b;
  121. b = b.next;
  122. }
  123. _ni = _ni - 1;
  124. }
  125. defn
  126. queue(q)
  127. {
  128. _ni = 0;
  129. _queue(q);
  130. }
  131. defn
  132. _block(b)
  133. {
  134. complex Block b;
  135. _ni();
  136. print("block(", b\X, ") base ", b.base\X, " rp ", b.rp\X, "/", b.rp-b.base\D, " wp ", b.wp\X, "/", b.wp-b.base\D, " lim ", b.lim\X, "/", b.lim-b.base\D, "\n");
  137. }
  138. defn
  139. block(b)
  140. {
  141. _ni = 0;
  142. block(b);
  143. }
  144. print("/sys/lib/acid/network");
  145. needacid("tcp");
  146. needacid("qio");