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