/[dynamips]/upstream/dynamips-0.2.5/dev_vtty.h
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /upstream/dynamips-0.2.5/dev_vtty.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Sat Oct 6 16:01:44 2007 UTC (12 years, 2 months ago) by dpavlin
File MIME type: text/plain
File size: 2566 byte(s)
import 0.2.5 from upstream

1 /*
2 * Cisco 7200 (Predator) simulation platform.
3 * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr)
4 *
5 * Virtual console TTY.
6 */
7
8 #ifndef __DEV_VTTY_H__
9 #define __DEV_VTTY_H__
10
11 #include <sys/types.h>
12 #include <pthread.h>
13
14 #include "vm.h"
15 #include <stdio.h>
16
17 /* 4 Kb should be enough for a keyboard buffer */
18 #define VTTY_BUFFER_SIZE 4096
19
20 /* VTTY connection types */
21 enum {
22 VTTY_TYPE_NONE = 0,
23 VTTY_TYPE_TERM,
24 VTTY_TYPE_TCP,
25 VTTY_TYPE_SERIAL,
26 };
27
28 /* VTTY connection states (for TCP) */
29 enum {
30 VTTY_STATE_TCP_INVALID, /* connection is not working */
31 VTTY_STATE_TCP_WAITING, /* waiting for incoming connection */
32 VTTY_STATE_TCP_RUNNING, /* character reading/writing ok */
33 };
34
35 /* VTTY input states */
36 enum {
37 VTTY_INPUT_TEXT,
38 VTTY_INPUT_VT1,
39 VTTY_INPUT_VT2,
40 VTTY_INPUT_REMOTE,
41 VTTY_INPUT_TELNET,
42 VTTY_INPUT_TELNET_IYOU,
43 VTTY_INPUT_TELNET_SB1,
44 VTTY_INPUT_TELNET_SB2,
45 VTTY_INPUT_TELNET_SB_TTYPE,
46 VTTY_INPUT_TELNET_NEXT
47 };
48
49
50 /* Commmand line support utility */
51 typedef struct vtty_serial_option vtty_serial_option_t;
52 struct vtty_serial_option {
53 char *device;
54 int baudrate, databits, parity, stopbits, hwflow;
55 };
56
57 int vtty_parse_serial_option(vtty_serial_option_t *params, char *optarg);
58
59 /* Virtual TTY structure */
60 typedef struct virtual_tty vtty_t;
61 struct virtual_tty {
62 vm_instance_t *vm;
63 char *name;
64 int type,state;
65 int tcp_port;
66 int terminal_support;
67 int input_state;
68 int telnet_cmd, telnet_opt, telnet_qual;
69 int fd,accept_fd,*select_fd;
70 int managed_flush;
71 FILE *fstream;
72 u_char buffer[VTTY_BUFFER_SIZE];
73 u_int read_ptr,write_ptr;
74 pthread_mutex_t lock;
75 vtty_t *next,**pprev;
76 void *priv_data;
77
78 /* Read notification */
79 void (*read_notifier)(vtty_t *);
80 };
81
82 #define VTTY_LOCK(tty) pthread_mutex_lock(&(tty)->lock);
83 #define VTTY_UNLOCK(tty) pthread_mutex_unlock(&(tty)->lock);
84
85 /* create a virtual tty */
86 vtty_t *vtty_create(vm_instance_t *vm,char *name,int type,int tcp_port,
87 const vtty_serial_option_t *option);
88
89 /* delete a virtual tty */
90 void vtty_delete(vtty_t *vtty);
91
92 /* read a character from the buffer (-1 if the buffer is empty) */
93 int vtty_get_char(vtty_t *vtty);
94
95 /* print a character to vtty */
96 void vtty_put_char(vtty_t *vtty, char ch);
97
98 /* Flush VTTY output */
99 void vtty_flush(vtty_t *vtty);
100
101 /* returns TRUE if a character is available in buffer */
102 int vtty_is_char_avail(vtty_t *vtty);
103
104 /* write CTRL+C to buffer */
105 int vtty_store_ctrlc(vtty_t *);
106
107 /* Initialize the VTTY thread */
108 int vtty_init(void);
109
110 #endif

  ViewVC Help
Powered by ViewVC 1.1.26