|
|
1.1 ! root 1: /* ! 2: * C H S E R V I C E ! 3: * ! 4: * Built-in services for the Chaosnet line discipline. ! 5: * ! 6: * ! 7: * (c) Copyright 1984 Nirvonics, Inc. ! 8: * ! 9: * Written by Kurt Gollhardt ! 10: * Last update Tue Nov 13 14:27:51 1984 ! 11: * ! 12: * This software is the property of Nirvonics, Inc. ! 13: * All rights reserved. ! 14: * ! 15: */ ! 16: ! 17: #include "ch.h" ! 18: #if NCH > 0 ! 19: #include "../h/param.h" ! 20: #include "../h/systm.h" ! 21: #include "../chaosld/types.h" ! 22: #include "../chaosld/constants.h" ! 23: #include "../chaosld/globals.h" ! 24: #include "../chaosld/chrouteld.h" ! 25: ! 26: extern struct chroute Chroute[]; ! 27: ! 28: static status_rfc(), time_rfc(), uptime_rfc(), dumprt_rfc(); ! 29: ! 30: struct service Chservice[] = { ! 31: "STATUS", 6, status_rfc, ! 32: "TIME", 4, time_rfc, ! 33: "UPTIME", 6, uptime_rfc, ! 34: "DUMP-ROUTING-TABLE", 18, dumprt_rfc, ! 35: 0, 0, 0 ! 36: }; ! 37: ! 38: /* ! 39: * process a RFC for contact name STATUS ! 40: */ ! 41: static status_rfc(pkt) ! 42: register struct packet *pkt; ! 43: { ! 44: register struct chroute *r; ! 45: register struct chif *ifp; ! 46: struct statdata sd; ! 47: ! 48: free_pkdata(pkt); ! 49: append_packet(pkt, Chmyname, CHSTATNAME); ! 50: ! 51: for (r = Chroute; r < &Chroute[CHNSUBNET]; r++) ! 52: if (r->rt_type == CHDIRECT) { ! 53: ifp = r->rt_path.ifp; ! 54: sd.sb_ident = 0400 + ifp->my_addr.ch_subnet; ! 55: sd.sb_nshorts = sizeof(struct statxcvr) / sizeof(short); ! 56: sd.sb_xstat = ifp->if_stat; ! 57: #ifdef pdp11 ! 58: swaplong(&sd.sb_xstat, ! 59: sizeof(struct statxcvr) / sizeof(long)); ! 60: #endif ! 61: append_packet(pkt, &sd, sizeof(sd)); ! 62: } ! 63: ! 64: pkt->pk_op = ANSOP; ! 65: pkt->pk_didx.ci_idx = pkt->pk_pkn = pkt->pk_ackn = 0; ! 66: reflect(pkt); ! 67: } ! 68: ! 69: /* ! 70: * process an RFC for contact name TIME ! 71: */ ! 72: static time_rfc(pkt) ! 73: register struct packet *pkt; ! 74: { ! 75: long t; ! 76: ! 77: pkt->pk_op = ANSOP; ! 78: pkt->pk_pkn = pkt->pk_ackn = 0; ! 79: ch_time(&t); ! 80: #ifdef pdp11 ! 81: swaplong(&t, 1); ! 82: #endif pdp11 ! 83: free_pkdata(pkt); ! 84: append_packet(pkt, &t, sizeof(long)); ! 85: reflect(pkt); ! 86: } ! 87: ! 88: /* ! 89: * process an RFC for contact name UPTIME ! 90: */ ! 91: static uptime_rfc(pkt) ! 92: register struct packet *pkt; ! 93: { ! 94: long t; ! 95: ! 96: pkt->pk_op = ANSOP; ! 97: pkt->pk_pkn = pkt->pk_ackn = 0; ! 98: ch_uptime(&t); ! 99: #ifdef pdp11 ! 100: swaplong(&t, 1); ! 101: #endif pdp11 ! 102: free_pkdata(pkt); ! 103: append_packet(pkt, &t, sizeof(long)); ! 104: reflect(pkt); ! 105: } ! 106: ! 107: /* ! 108: * process an RFC for contact name DUMP-ROUTING-TABLE ! 109: */ ! 110: static dumprt_rfc(pkt) ! 111: register struct packet *pkt; ! 112: { ! 113: register struct chroute *r; ! 114: register int ndirect, i; ! 115: struct { ! 116: short word1, word2; ! 117: } sd; ! 118: ! 119: free_pkdata(pkt); ! 120: ndirect = i = 0; ! 121: for (r = Chroute; r < &Chroute[CHNSUBNET]; r++, i++) { ! 122: sd.word2 = r->rt_cost; ! 123: if (r->rt_type == CHDIRECT) ! 124: sd.word1 = (ndirect++ << 1) + 1; ! 125: else if (r->rt_type != CHNOPATH) ! 126: sd.word1 = r->rt_path.bridge.ch_addr; ! 127: else ! 128: sd.word1 = 0; ! 129: append_packet(pkt, &sd, sizeof(sd)); ! 130: } ! 131: ! 132: pkt->pk_op = ANSOP; ! 133: pkt->pk_didx.ci_idx = pkt->pk_pkn = pkt->pk_ackn = 0; ! 134: reflect(pkt); ! 135: } ! 136: ! 137: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.