#define TELOPTS #include #include #include #include "ring.h" #include "externs.h" FILE *NetTrace = 0; /* Not in bss, since needs to stay */ /* * upcase() * * Upcase (in place) the argument. */ void upcase(argument) register char *argument; { register int c; while ((c = *argument) != 0) { if (islower(c)) { *argument = toupper(c); } argument++; } } /* * SetSockOpt() * * Compensate for differences in 4.2 and 4.3 systems. */ int SetSockOpt(fd, level, option, yesno) int fd, level, option, yesno; { #ifndef NOT43 return setsockopt(fd, level, option, (char *)&yesno, sizeof yesno); #else /* NOT43 */ if (yesno == 0) { /* Can't do that in 4.2! */ fprintf(stderr, "Error: attempt to turn off an option 0x%x.\n", option); return -1; } return setsockopt(fd, level, option, 0, 0); #endif /* NOT43 */ } /* * The following are routines used to print out debugging information. */ void Dump(direction, buffer, length) char direction; char *buffer; int length; { # define BYTES_PER_LINE 32 # define min(x,y) ((x" */ *pointer; /* where suboption data sits */ int length; /* length of suboption data */ { if (showoptions) { fprintf(NetTrace, "%s suboption ", (direction[0] == '<')? "Received":"Sent"); switch (pointer[0]) { case TELOPT_TTYPE: fprintf(NetTrace, "Terminal type "); switch (pointer[1]) { case TELQUAL_IS: { char tmpbuf[SUBBUFSIZE]; int minlen = min(length, sizeof tmpbuf); memcpy(tmpbuf, pointer+2, minlen); tmpbuf[minlen-1] = 0; fprintf(NetTrace, "is %s.\n", tmpbuf); } break; case TELQUAL_SEND: fprintf(NetTrace, "- request to send.\n"); break; default: fprintf(NetTrace, "- unknown qualifier %d (0x%x).\n", pointer[1]); } break; default: fprintf(NetTrace, "Unknown option %d (0x%x)\n", pointer[0], pointer[0]); } } }