Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | uch11: Split out uch11 backend guts into seperate header, leave uch11.h for MIT CADR specifics. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | ams/sdl |
Files: | files | file ages | folders |
SHA3-256: |
b32ca4506ba0d1249948cf22cdad13b4 |
User & Date: | ams 2024-06-25 12:45:50 |
Context
2024-06-25
| ||
16:46 | uch11: Random declaration fixes. check-in: a92489a346 user: ams tags: ams/sdl | |
12:45 | uch11: Split out uch11 backend guts into seperate header, leave uch11.h for MIT CADR specifics. check-in: b32ca4506b user: ams tags: ams/sdl | |
11:30 | uch11: Make sure each backend now is a seperate compilation unit. check-in: 200674745d user: ams tags: ams/sdl | |
Changes
Added uch11-backend.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | #pragma once enum { CHAOS_CSR_TIMER_INTERRUPT_ENABLE = (01 << 00), /* CHBUSY */ CHAOS_CSR_LOOP_BACK = (01 << 01), /* CHLPBK */ CHAOS_CSR_RECEIVE_ALL = (01 << 02), /* CHSPY */ CHAOS_CSR_RECEIVER_CLEAR = (01 << 03), CHAOS_CSR_RECEIVE_ENABLE = (01 << 04), /* CHREN */ CHAOS_CSR_TRANSMIT_ENABLE = (01 << 05), /* CHRIEN */ CHAOS_CSR_INTERRUPT_ENABLES = (02 << 04), CHAOS_CSR_TRANSMIT_ABORT = (01 << 06), /* CHABRT */ CHAOS_CSR_TRANSMIT_DONE = (01 << 07), /* CHTDN */ CHAOS_CSR_TRANSMITTER_CLEAR = (01 << 010), /* CHTCLR */ CHAOS_CSR_LOST_COUNT = (04 << 011), /* CHLC */ CHAOS_CSR_RESET = (01 << 015), /* CHRST */ CHAOS_CSR_CRC_ERROR = (01 << 016), /* CHCRC */ CHAOS_CSR_RECEIVE_DONE = (01 << 017), /* CHRDN */ } CHAOS_HARDWARE_VALUES; extern struct queue_head queuehead; extern pthread_mutex_t recvqueue; extern pthread_mutex_t recvqueue; #include <stdbool.h> extern int chaosd_fd; extern int uch11_backend; extern int uch11_myaddr; extern int uch11_serveraddr; extern bool reconnect_chaos; extern int uch11_csr; extern int uch11_bit_count; extern int uch11_lost_count; extern unsigned short uch11_xmit_buffer[4096]; extern int uch11_xmit_buffer_size; extern int uch11_xmit_buffer_ptr; extern unsigned short uch11_rcv_buffer[4096]; extern unsigned short uch11_rcv_buffer_toss[4096]; extern int uch11_rcv_buffer_ptr; extern int uch11_rcv_buffer_size; extern bool uch11_rcv_buffer_empty; // This hack is so that uch11.h (this file) can be included in // Chaosnet for Unix. #ifndef CHAOS_H #define CHAOS_H #include <pthread.h> #include <sys/queue.h> struct packet_queue { TAILQ_ENTRY(packet_queue) next; struct packet *packet; }; TAILQ_HEAD(queue_head, packet_queue); #include "chaos.h" #include "chunix/chsys.h" #include "chunix/chconf.h" #include "chncp/chncp.h" #endif |
Changes to uch11-chaosd.c.
︙ | ︙ | |||
23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> #include "uch11.h" #include "chaosd.h" #include "hosttab.h" #include "misc.h" #include "ucfg.h" #include "ucode.h" #include "usim.h" #include "utrace.h" | > | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> #include "uch11.h" #include "uch11-backend.h" #include "chaosd.h" #include "hosttab.h" #include "misc.h" #include "ucfg.h" #include "ucode.h" #include "usim.h" #include "utrace.h" |
︙ | ︙ |
Changes to uch11-local.c.
︙ | ︙ | |||
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> #include "uch11.h" #include "chaosd.h" #include "hosttab.h" #include "misc.h" #include "ucfg.h" #include "ucode.h" #include "usim.h" #include "utrace.h" | > | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> #include "uch11.h" #include "uch11-backend.h" #include "chaosd.h" #include "hosttab.h" #include "misc.h" #include "ucfg.h" #include "ucode.h" #include "usim.h" #include "utrace.h" static void chaos_queue(struct packet *packet) { struct packet_queue *node; node = malloc(sizeof(struct packet_queue)); node->packet = packet; pthread_mutex_lock(&recvqueue); |
︙ | ︙ | |||
187 188 189 190 191 192 193 | pthread_cond_wait(&conn->queuecond, &conn->queuesem); pthread_mutex_unlock(&conn->queuesem); if (conn->cn_state == CSCLOSED) return NOPKT; } } | | | 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | pthread_cond_wait(&conn->queuecond, &conn->queuesem); pthread_mutex_unlock(&conn->queuesem); if (conn->cn_state == CSCLOSED) return NOPKT; } } static int chaos_queue_time_pkt(unsigned short saddr, unsigned short sidx) { time_t t; struct timeval time; struct packet *answer; INFO(TRACE_CHAOS, "chaos: RFC (TIME): answering...\n"); |
︙ | ︙ | |||
212 213 214 215 216 217 218 | answer->pk_pkn = 0; answer->pk_ackn = 0; *(long *) &answer->pk_cdata[0] = t; chaos_queue(answer); return 0; } | | | | 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | answer->pk_pkn = 0; answer->pk_ackn = 0; *(long *) &answer->pk_cdata[0] = t; chaos_queue(answer); return 0; } static int chaos_queue_uptime_pkt(unsigned short saddr, unsigned short sidx) { struct packet *answer; INFO(TRACE_CHAOS, "chaos: RFC (UPTIME): answering...\n"); answer = pkalloc(sizeof(long), 0); answer->pk_op = ANSOP; SET_PH_LEN(answer->pk_phead, sizeof(long)); SET_CH_ADDR(answer->pk_daddr, saddr); SET_CH_INDEX(answer->pk_didx, sidx); SET_CH_ADDR(answer->pk_saddr, chaos_addr(ucfg.chaos_servername, 0)); SET_CH_INDEX(answer->pk_sidx, 0); answer->pk_pkn = 0; answer->pk_ackn = 0; *(long *) &answer->pk_cdata[0] = 0; chaos_queue(answer); return 0; } static int chaos_queue_status_pkt(unsigned short saddr, unsigned short sidx) { struct packet *answer; struct status *status; INFO(TRACE_CHAOS, "chaos: RFC (STATUS): answering...\n"); answer = pkalloc(CHSTATNAME + 2 * 2, 0); /* Only room for name and subnet+nwords */ |
︙ | ︙ | |||
260 261 262 263 264 265 266 | status->sb_data->sb_ident = (chaos_addr(ucfg.chaos_servername, 0) >> 8) | 0400; /* and say no data is following */ status->sb_data->sb_nshorts = 0 * sizeof(int) / sizeof(short); chaos_queue(answer); return 0; } | | | 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | status->sb_data->sb_ident = (chaos_addr(ucfg.chaos_servername, 0) >> 8) | 0400; /* and say no data is following */ status->sb_data->sb_nshorts = 0 * sizeof(int) / sizeof(short); chaos_queue(answer); return 0; } static int chaos_queue_file_pkt(struct packet *packet) { void processdata(struct connection *conn); struct packet *answer; struct connection *conn; packet->pk_cdata[PH_LEN(packet->pk_phead)] = '\0'; |
︙ | ︙ | |||
283 284 285 286 287 288 289 | *(unsigned short *) &answer->pk_cdata[2] = conn->cn_rwsize; chaos_connection_queue(conn, answer); conn->cn_state = CSLISTEN; processdata(conn); return 0; } | | | 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | *(unsigned short *) &answer->pk_cdata[2] = conn->cn_rwsize; chaos_connection_queue(conn, answer); conn->cn_state = CSLISTEN; processdata(conn); return 0; } static int chaos_queue_mini_pkt(struct packet *packet) { void processmini(struct connection *conn); struct packet *answer; struct connection *conn; packet->pk_cdata[PH_LEN(packet->pk_phead)] = '\0'; |
︙ | ︙ |
Changes to uch11-udp.c.
︙ | ︙ | |||
22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> #include "uch11.h" #include "chaosd.h" #include "hosttab.h" #include "misc.h" #include "ucfg.h" #include "ucode.h" #include "usim.h" #include "utrace.h" | > | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> #include "uch11.h" #include "uch11-backend.h" #include "chaosd.h" #include "hosttab.h" #include "misc.h" #include "ucfg.h" #include "ucode.h" #include "usim.h" #include "utrace.h" |
︙ | ︙ | |||
148 149 150 151 152 153 154 | /* Max: CHUDP header, Chaos header, Chaos data, trailer */ #define CHUDP_MAXLEN (sizeof(struct chudp_header)+sizeof(struct pkt_header)+CH_PK_MAX_DATALEN+sizeof(struct chaos_hw_trailer)) u_char trans_chudpbuf[CHUDP_MAXLEN]; /* So sorry about this. */ | | | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | /* Max: CHUDP header, Chaos header, Chaos data, trailer */ #define CHUDP_MAXLEN (sizeof(struct chudp_header)+sizeof(struct pkt_header)+CH_PK_MAX_DATALEN+sizeof(struct chaos_hw_trailer)) u_char trans_chudpbuf[CHUDP_MAXLEN]; /* So sorry about this. */ static void ntohs_buf(u_short *ibuf, u_short *obuf, int len) { int i; for (i = 0; i < len; i += 2) *obuf++ = ntohs(*ibuf++); } |
︙ | ︙ |
Changes to uch11.c.
︙ | ︙ | |||
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> #include "uch11.h" #include "chaosd.h" #include "hosttab.h" #include "misc.h" #include "ucfg.h" #include "ucode.h" #include "usim.h" #include "utrace.h" | > < < < | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> #include "uch11.h" #include "uch11-backend.h" #include "chaosd.h" #include "hosttab.h" #include "misc.h" #include "ucfg.h" #include "ucode.h" #include "usim.h" #include "utrace.h" int uch11_backend = UCH11_BACKEND_LOCAL; int uch11_myaddr = 0177040; /* LOCAL-CADR */ int uch11_serveraddr = 0177001; /* LOCAL-BRIDGE */ int uch11_csr; int uch11_bit_count; int uch11_lost_count; unsigned short uch11_xmit_buffer[4096]; int uch11_xmit_buffer_size; |
︙ | ︙ |
Changes to uch11.h.
1 2 | #pragma once | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #pragma once #define UCH11_BACKEND_DAEMON 0 #define UCH11_BACKEND_LOCAL 1 #define UCH11_BACKEND_UDP 2 extern int uch11_backend; extern int uch11_serveraddr; extern int uch11_myaddr; extern int hybrid_udp_and_local; extern int uch11_init(void); extern void uch11_poll(void); extern int uch11_get_csr(void); extern void uch11_set_csr(int); extern int uch11_get_bit_count(void); extern int uch11_get_rcv_buffer(void); extern void uch11_put_xmit_buffer(int); extern void uch11_xmit_pkt(void); |