[BACK]Return to externs.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / telnet

Annotation of src/usr.bin/telnet/externs.h, Revision 1.3

1.2       niklas      1: /*     $OpenBSD$       */
1.3     ! art         2: /* $KTH: externs.h,v 1.16 1997/11/29 02:28:35 joda Exp $ */
1.2       niklas      3:
1.1       deraadt     4: /*
                      5:  * Copyright (c) 1988, 1990, 1993
                      6:  *     The Regents of the University of California.  All rights reserved.
                      7:  *
                      8:  * Redistribution and use in source and binary forms, with or without
                      9:  * modification, are permitted provided that the following conditions
                     10:  * are met:
                     11:  * 1. Redistributions of source code must retain the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer.
                     13:  * 2. Redistributions in binary form must reproduce the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer in the
                     15:  *    documentation and/or other materials provided with the distribution.
                     16:  * 3. All advertising materials mentioning features or use of this software
                     17:  *    must display the following acknowledgement:
                     18:  *     This product includes software developed by the University of
                     19:  *     California, Berkeley and its contributors.
                     20:  * 4. Neither the name of the University nor the names of its contributors
                     21:  *    may be used to endorse or promote products derived from this software
                     22:  *    without specific prior written permission.
                     23:  *
                     24:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     25:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     26:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     27:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     28:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     29:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     30:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     31:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     32:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     33:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     34:  * SUCH DAMAGE.
                     35:  *
1.3     ! art        36:  *     @(#)externs.h   8.3 (Berkeley) 5/30/95
1.1       deraadt    37:  */
                     38:
                     39: #ifndef        BSD
                     40: # define BSD 43
                     41: #endif
                     42:
                     43: #ifndef        _POSIX_VDISABLE
                     44: # ifdef sun
                     45: #  include <sys/param.h>       /* pick up VDISABLE definition, mayby */
                     46: # endif
                     47: # ifdef VDISABLE
                     48: #  define _POSIX_VDISABLE VDISABLE
                     49: # else
                     50: #  define _POSIX_VDISABLE ((cc_t)'\377')
                     51: # endif
                     52: #endif
                     53:
                     54: #define        SUBBUFSIZE      256
                     55:
                     56: extern int
                     57:     autologin,         /* Autologin enabled */
                     58:     skiprc,            /* Don't process the ~/.telnetrc file */
                     59:     eight,             /* use eight bit mode (binary in and/or out */
1.3     ! art        60:     binary,
1.1       deraadt    61:     flushout,          /* flush output */
                     62:     connected,         /* Are we connected to the other side? */
                     63:     globalmode,                /* Mode tty should be in */
                     64:     telnetport,                /* Are we connected to the telnet port? */
1.3     ! art        65:     In3270,            /* Are we in 3270 mode? */
1.1       deraadt    66:     localflow,         /* Flow control handled locally */
                     67:     restartany,                /* If flow control, restart output on any character */
                     68:     localchars,                /* we recognize interrupt/quit */
1.2       niklas     69:     donelclchars,      /* the user has set "localchars" */
1.1       deraadt    70:     showoptions,
                     71:     net,               /* Network file descriptor */
                     72:     tin,               /* Terminal input file descriptor */
                     73:     tout,              /* Terminal output file descriptor */
                     74:     crlf,              /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
                     75:     autoflush,         /* flush output when interrupting? */
                     76:     autosynch,         /* send interrupt characters with SYNCH? */
                     77:     SYNCHing,          /* Is the stream in telnet SYNCH mode? */
                     78:     donebinarytoggle,  /* the user has put us in binary */
                     79:     dontlecho,         /* do we suppress local echoing right now? */
                     80:     crmod,
                     81:     netdata,           /* Print out network data flow */
                     82:     prettydump,                /* Print "netdata" output in user readable format */
                     83:     termdata,          /* Print out terminal data flow */
1.3     ! art        84:     debug;             /* Debug level */
1.1       deraadt    85:
                     86: extern cc_t escape;    /* Escape to command mode */
                     87: extern cc_t rlogin;    /* Rlogin mode escape character */
                     88: #ifdef KLUDGELINEMODE
                     89: extern cc_t echoc;     /* Toggle local echoing */
                     90: #endif
                     91:
                     92: extern char
                     93:     *prompt;           /* Prompt for command. */
                     94:
                     95: extern char
                     96:     doopt[],
                     97:     dont[],
                     98:     will[],
                     99:     wont[],
                    100:     options[],         /* All the little options */
                    101:     *hostname;         /* Who are we connected to? */
1.3     ! art       102: #if    defined(ENCRYPTION)
        !           103: extern void (*encrypt_output) (unsigned char *, int);
        !           104: extern int (*decrypt_input) (int);
        !           105: #endif
1.1       deraadt   106:
                    107: /*
                    108:  * We keep track of each side of the option negotiation.
                    109:  */
                    110:
                    111: #define        MY_STATE_WILL           0x01
                    112: #define        MY_WANT_STATE_WILL      0x02
                    113: #define        MY_STATE_DO             0x04
                    114: #define        MY_WANT_STATE_DO        0x08
                    115:
                    116: /*
                    117:  * Macros to check the current state of things
                    118:  */
                    119:
                    120: #define        my_state_is_do(opt)             (options[opt]&MY_STATE_DO)
                    121: #define        my_state_is_will(opt)           (options[opt]&MY_STATE_WILL)
                    122: #define my_want_state_is_do(opt)       (options[opt]&MY_WANT_STATE_DO)
                    123: #define my_want_state_is_will(opt)     (options[opt]&MY_WANT_STATE_WILL)
                    124:
                    125: #define        my_state_is_dont(opt)           (!my_state_is_do(opt))
                    126: #define        my_state_is_wont(opt)           (!my_state_is_will(opt))
                    127: #define my_want_state_is_dont(opt)     (!my_want_state_is_do(opt))
                    128: #define my_want_state_is_wont(opt)     (!my_want_state_is_will(opt))
                    129:
                    130: #define        set_my_state_do(opt)            {options[opt] |= MY_STATE_DO;}
                    131: #define        set_my_state_will(opt)          {options[opt] |= MY_STATE_WILL;}
                    132: #define        set_my_want_state_do(opt)       {options[opt] |= MY_WANT_STATE_DO;}
                    133: #define        set_my_want_state_will(opt)     {options[opt] |= MY_WANT_STATE_WILL;}
                    134:
                    135: #define        set_my_state_dont(opt)          {options[opt] &= ~MY_STATE_DO;}
                    136: #define        set_my_state_wont(opt)          {options[opt] &= ~MY_STATE_WILL;}
                    137: #define        set_my_want_state_dont(opt)     {options[opt] &= ~MY_WANT_STATE_DO;}
                    138: #define        set_my_want_state_wont(opt)     {options[opt] &= ~MY_WANT_STATE_WILL;}
                    139:
                    140: /*
                    141:  * Make everything symetrical
                    142:  */
                    143:
                    144: #define        HIS_STATE_WILL                  MY_STATE_DO
                    145: #define        HIS_WANT_STATE_WILL             MY_WANT_STATE_DO
                    146: #define HIS_STATE_DO                   MY_STATE_WILL
                    147: #define HIS_WANT_STATE_DO              MY_WANT_STATE_WILL
                    148:
                    149: #define        his_state_is_do                 my_state_is_will
                    150: #define        his_state_is_will               my_state_is_do
                    151: #define his_want_state_is_do           my_want_state_is_will
                    152: #define his_want_state_is_will         my_want_state_is_do
                    153:
                    154: #define        his_state_is_dont               my_state_is_wont
                    155: #define        his_state_is_wont               my_state_is_dont
                    156: #define his_want_state_is_dont         my_want_state_is_wont
                    157: #define his_want_state_is_wont         my_want_state_is_dont
                    158:
                    159: #define        set_his_state_do                set_my_state_will
                    160: #define        set_his_state_will              set_my_state_do
                    161: #define        set_his_want_state_do           set_my_want_state_will
                    162: #define        set_his_want_state_will         set_my_want_state_do
                    163:
                    164: #define        set_his_state_dont              set_my_state_wont
                    165: #define        set_his_state_wont              set_my_state_dont
                    166: #define        set_his_want_state_dont         set_my_want_state_wont
                    167: #define        set_his_want_state_wont         set_my_want_state_dont
                    168:
                    169:
                    170: extern FILE
                    171:     *NetTrace;         /* Where debugging output goes */
                    172: extern unsigned char
                    173:     NetTraceFile[];    /* Name of file where debugging output goes */
                    174: extern void
1.3     ! art       175:     SetNetTrace (char *);      /* Function to change where debugging goes */
1.1       deraadt   176:
                    177: extern jmp_buf
                    178:     peerdied,
                    179:     toplevel;          /* For error conditions. */
                    180:
1.3     ! art       181: /* authenc.c */
1.1       deraadt   182:
1.3     ! art       183: #if    defined(AUTHENTICATION) || defined(ENCRYPTION)
        !           184: int net_write(unsigned char *str, int len);
        !           185: void net_encrypt(void);
        !           186: int telnet_spin(void);
        !           187: char *telnet_getenv(char *val);
        !           188: char *telnet_gets(char *prompt, char *result, int length, int echo);
        !           189: #endif
        !           190:
        !           191: /* commands.c */
        !           192:
        !           193: struct env_lst *env_define (unsigned char *, unsigned char *);
        !           194: struct env_lst *env_find(unsigned char *var);
        !           195: void env_init (void);
        !           196: void env_undefine (unsigned char *);
        !           197: void env_export (unsigned char *);
        !           198: void env_unexport (unsigned char *);
        !           199: void env_send (unsigned char *);
        !           200: void env_list (void);
        !           201: unsigned char * env_default(int init, int welldefined);
        !           202: unsigned char * env_getvalue(unsigned char *var);
        !           203:
        !           204: void set_escape_char(char *s);
        !           205: unsigned long sourceroute(char *arg, char **cpp, int *lenp);
        !           206:
        !           207: #if    defined(AUTHENTICATION)
        !           208: int auth_enable (char *);
        !           209: int auth_disable (char *);
        !           210: int auth_status (void);
        !           211: #endif
        !           212:
        !           213: #if defined(ENCRYPTION)
        !           214: int    EncryptEnable (char *, char *);
        !           215: int    EncryptDisable (char *, char *);
        !           216: int    EncryptType (char *, char *);
        !           217: int    EncryptStart (char *);
        !           218: int    EncryptStartInput (void);
        !           219: int    EncryptStartOutput (void);
        !           220: int    EncryptStop (char *);
        !           221: int    EncryptStopInput (void);
        !           222: int    EncryptStopOutput (void);
        !           223: int    EncryptStatus (void);
        !           224: #endif
        !           225:
        !           226: #ifdef SIGINFO
        !           227: void ayt_status(void);
        !           228: #endif
        !           229: int tn(int argc, char **argv);
        !           230: void command(int top, char *tbuf, int cnt);
        !           231:
        !           232: /* main.c */
        !           233:
        !           234: void tninit(void);
        !           235: void usage(void);
        !           236:
        !           237: /* network.c */
        !           238:
        !           239: void init_network(void);
        !           240: int stilloob(void);
        !           241: void setneturg(void);
        !           242: int netflush(void);
        !           243:
        !           244: /* sys_bsd.c */
        !           245:
        !           246: void init_sys(void);
        !           247: int TerminalWrite(char *buf, int n);
        !           248: int TerminalRead(unsigned char *buf, int n);
        !           249: int TerminalAutoFlush(void);
        !           250: int TerminalSpecialChars(int c);
        !           251: void TerminalFlushOutput(void);
        !           252: void TerminalSaveState(void);
        !           253: void TerminalDefaultChars(void);
        !           254: void TerminalNewMode(int f);
        !           255: cc_t *tcval(int func);
        !           256: void TerminalSpeeds(long *input_speed, long *output_speed);
        !           257: int TerminalWindowSize(long *rows, long *cols);
        !           258: int NetClose(int fd);
        !           259: void NetNonblockingIO(int fd, int onoff);
        !           260: int process_rings(int netin, int netout, int netex, int ttyin, int ttyout,
        !           261:                  int poll);
        !           262:
        !           263: /* telnet.c */
        !           264:
        !           265: void init_telnet(void);
        !           266:
        !           267: void tel_leave_binary(int rw);
        !           268: void tel_enter_binary(int rw);
        !           269: int opt_welldefined(char *ep);
        !           270: int telrcv(void);
        !           271: int rlogin_susp(void);
        !           272: void intp(void);
        !           273: void sendbrk(void);
        !           274: void sendabort(void);
        !           275: void sendsusp(void);
        !           276: void sendeof(void);
        !           277: void sendayt(void);
        !           278:
        !           279: void xmitAO(void);
        !           280: void xmitEL(void);
        !           281: void xmitEC(void);
        !           282:
        !           283:
        !           284: void     Dump (char, unsigned char *, int);
        !           285: void     printoption (char *, int, int);
        !           286: void     printsub (char, unsigned char *, int);
        !           287: void     sendnaws (void);
        !           288: void     setconnmode (int);
        !           289: void     setcommandmode (void);
        !           290: void     setneturg (void);
        !           291: void     sys_telnet_init (void);
        !           292: void     telnet (char *);
        !           293: void     tel_enter_binary (int);
        !           294: void     TerminalFlushOutput (void);
        !           295: void     TerminalNewMode (int);
        !           296: void     TerminalRestoreState (void);
        !           297: void     TerminalSaveState (void);
        !           298: void     tninit (void);
        !           299: void     willoption (int);
        !           300: void     wontoption (int);
        !           301:
        !           302:
        !           303: void     send_do (int, int);
        !           304: void     send_dont (int, int);
        !           305: void     send_will (int, int);
        !           306: void     send_wont (int, int);
        !           307:
        !           308: void     lm_will (unsigned char *, int);
        !           309: void     lm_wont (unsigned char *, int);
        !           310: void     lm_do (unsigned char *, int);
        !           311: void     lm_dont (unsigned char *, int);
        !           312: void     lm_mode (unsigned char *, int, int);
        !           313:
        !           314: void     slc_init (void);
        !           315: void     slcstate (void);
        !           316: void     slc_mode_export (void);
        !           317: void     slc_mode_import (int);
        !           318: void     slc_import (int);
        !           319: void     slc_export (void);
        !           320: void     slc (unsigned char *, int);
        !           321: void     slc_check (void);
        !           322: void     slc_start_reply (void);
        !           323: void     slc_add_reply (unsigned char, unsigned char, cc_t);
        !           324: void     slc_end_reply (void);
        !           325: int     slc_update (void);
        !           326:
        !           327: void     env_opt (unsigned char *, int);
        !           328: void     env_opt_start (void);
        !           329: void     env_opt_start_info (void);
        !           330: void     env_opt_add (unsigned char *);
        !           331: void     env_opt_end (int);
        !           332:
        !           333: unsigned char     *env_default (int, int);
        !           334: unsigned char     *env_getvalue (unsigned char *);
        !           335:
        !           336: int get_status (void);
        !           337: int dosynch (void);
        !           338:
        !           339: cc_t *tcval (int);
        !           340:
        !           341: int quit (void);
        !           342:
        !           343: /* terminal.c */
        !           344:
        !           345: void init_terminal(void);
        !           346: int ttyflush(int drop);
        !           347: int getconnmode(void);
        !           348:
        !           349: /* utilities.c */
        !           350:
        !           351: int SetSockOpt(int fd, int level, int option, int yesno);
        !           352: void SetNetTrace(char *file);
        !           353: void Dump(char direction, unsigned char *buffer, int length);
        !           354: void printoption(char *direction, int cmd, int option);
        !           355: void optionstatus(void);
        !           356: void printsub(char direction, unsigned char *pointer, int length);
        !           357: void EmptyTerminal(void);
        !           358: void SetForExit(void);
        !           359: void Exit(int returnCode);
        !           360: void ExitString(char *string, int returnCode);
1.1       deraadt   361:
1.3     ! art       362: extern struct  termios new_tc;
1.1       deraadt   363:
                    364: # define termEofChar           new_tc.c_cc[VEOF]
                    365: # define termEraseChar         new_tc.c_cc[VERASE]
                    366: # define termIntChar           new_tc.c_cc[VINTR]
                    367: # define termKillChar          new_tc.c_cc[VKILL]
                    368: # define termQuitChar          new_tc.c_cc[VQUIT]
                    369:
                    370: # ifndef       VSUSP
                    371: extern cc_t termSuspChar;
                    372: # else
                    373: #  define termSuspChar         new_tc.c_cc[VSUSP]
                    374: # endif
                    375: # if   defined(VFLUSHO) && !defined(VDISCARD)
                    376: #  define VDISCARD VFLUSHO
                    377: # endif
                    378: # ifndef       VDISCARD
                    379: extern cc_t termFlushChar;
                    380: # else
                    381: #  define termFlushChar                new_tc.c_cc[VDISCARD]
                    382: # endif
                    383: # ifndef VWERASE
                    384: extern cc_t termWerasChar;
                    385: # else
                    386: #  define termWerasChar                new_tc.c_cc[VWERASE]
                    387: # endif
                    388: # ifndef       VREPRINT
                    389: extern cc_t termRprntChar;
                    390: # else
                    391: #  define termRprntChar                new_tc.c_cc[VREPRINT]
                    392: # endif
                    393: # ifndef       VLNEXT
                    394: extern cc_t termLiteralNextChar;
                    395: # else
                    396: #  define termLiteralNextChar  new_tc.c_cc[VLNEXT]
                    397: # endif
                    398: # ifndef       VSTART
                    399: extern cc_t termStartChar;
                    400: # else
                    401: #  define termStartChar                new_tc.c_cc[VSTART]
                    402: # endif
                    403: # ifndef       VSTOP
                    404: extern cc_t termStopChar;
                    405: # else
                    406: #  define termStopChar         new_tc.c_cc[VSTOP]
                    407: # endif
                    408: # ifndef       VEOL
                    409: extern cc_t termForw1Char;
                    410: # else
                    411: #  define termForw1Char                new_tc.c_cc[VEOL]
                    412: # endif
                    413: # ifndef       VEOL2
                    414: extern cc_t termForw2Char;
                    415: # else
                    416: #  define termForw2Char                new_tc.c_cc[VEOL]
                    417: # endif
                    418: # ifndef       VSTATUS
                    419: extern cc_t termAytChar;
                    420: #else
                    421: #  define termAytChar          new_tc.c_cc[VSTATUS]
                    422: #endif
                    423:
                    424: /* Ring buffer structures which are shared */
                    425:
                    426: extern Ring
                    427:     netoring,
                    428:     netiring,
                    429:     ttyoring,
                    430:     ttyiring;
                    431: