diff options
author | Chris Hall <GMCH@hestia.halldom.com> | 2010-03-16 01:35:19 +0000 |
---|---|---|
committer | Chris Hall <GMCH@hestia.halldom.com> | 2010-03-16 01:35:19 +0000 |
commit | d87a9d74eab06082ea49313083ffa0aa41f666f9 (patch) | |
tree | 7c6f7ae0be39683b7c90ea298454ec28d49406cb /lib/keystroke.h | |
parent | 05fb7fd0421b395c089bb08dd0e0d78d3746b8cf (diff) | |
download | quagga-d87a9d74eab06082ea49313083ffa0aa41f666f9.tar.bz2 quagga-d87a9d74eab06082ea49313083ffa0aa41f666f9.tar.xz |
Major update
bgpd/bgp_advertise.c
bgpd/bgp_advertise.h
The adj_in and adj_out objects are now put on a list based
on the peer to whom the route belongs.
The adj_in and adj_out objects also now point to the bgp_node
which they are routes for.
This substantially reduces the work needed to shut down a peer.
bgpd/bgp_damp.c
Changes to adj_in and adj_out forced small change to macros
used in bgp_damp.c to manage its lists.
bgpd/bgp_debug.c
Replaced direct access to vty->node by the required vty_get_node().
bgpd/bgp_dump.c
Changes to the names of fields in bgp_info structures.
bgpd/bgp_engine.h
Modified the debug and trace functions.
bgpd/bgp_fsm.c
Make use of sockunion2str() consistent with common usage.
Improved some documentation.
bgpd/bgp_main.c
Use the newly extended qpn_add_hook_function() facility.
bgpd/bgp_mplsvpn.c
Changes to the names of fields in bgp_info structures.
bgpd/bgp_msg_read.c
Bug fix: correct handling of capability code length.
Improvement: better casting in calculation of message length.
bgpd/bgp_msg_write.c
Bug fix: correct byte ordering of bgp_id in open message.
bgpd/bgp_network.c
Bug fix: correct handling of incoming connections.
Takes advantage of improvements in sockunion.c.
bgpd/bgp_nexthop.c
Changes to the names of fields in bgp_info structures.
bgpd/bgp_open_state.c
Remove mistaken #include of memtypes.h
bgpd/bgp_packet.c
Improvements to handling of withdrawing routes for peers.
bgpd/bgp_peer.c
Tidying up the state of peers as they are enabled and disabled.
Improvements to handling of withdrawing routes for peers.
bgpd/bgp_peer.h
Adding list bases for lists of routes originated by the peer.
bgpd/bgp_peer_index.c
Bug fix: correct freeing of peer indexes.
bgpd/bgp_route.c
Implement lists of bgp_info based in the owning peer. Adjust
for name changes to bgp_info fields.
Reimplemented all the clearing functions to use the lists of
items that belong to the peer -- rather than searching route
tables for stuff to withdraw.
Changed work queue handling for added/changed routes, so
that queues run through existing items, rather than having
queues of auxiliary items -- lower memory overhead.
bgpd/bgp_route.h
Added fields to bgp_info to allow all bgp_info originated by
each peer to live on lists based in the peer. And changed the
name of existing fields to avoid confusion.
bgpd/bgp_routemap.c
Removing redundant code and fixing a memory leak.
bgpd/bgp_table.h
Based work queue for added/changed routes directly in the
table, rather than having auxiliary structures.
bgpd/bgp_vty.c
Use vty_get_node() and vty_set_node() rather than direct
access to the vty field.
bgpd/bgpd.c
Implement changes to route clearing.
bgpd/bgpd.h
Changes to work queue handling.
lib/buffer.c
Changes to allow embedded buffer structures.
lib/buffer.h
Moved struct buffer here so that could have embedded buffer
structurs.
lib/command.c
Substantial tidy up and document exercise.
Restructured the top level command processing and finding
of descriptions and command completion.
Removal of unpleasant messing around with the insides of
vector structures.
Movement of some command actions to vty.c.
Uses uty.h to pick up the "private" functions from vty.c
et al.
lib/command.h
Moved the "node" values to node_type.h, so that can use an
enum node_type in places where cannot include command.h.
lib/command_queue.c
Updated to cope with the called command changing the node
value.
Improved handling of revoked commands, so the the command
line handler does not get stuck waiting for a command to
complete which has been revoked !
lib/command_queue.h
Improved message format.
lib/if.c
Use vty_set_node().
lib/keychain.c
Use vty_set_node().
new lib/keystroke.c
new lib/keystroke.h
New code to implement a keystroke FIFO.
This moves some complexity out of the command handler.
The handling of mixtures of escapes and Telnet IACs is
tightened up.
It would be possible to extend this to, say, UTF-8.
Regularises the "stealing" of keystrokes for the "--more--"
output handling... which was a bit hit and miss.
new lib/list_util.c
new lib/list_util.h
New code to implement various forms of linked list,
where the list pointers are embedded in structures.
lib/log.c
Changed the handling of log messages, so that all types
of log output (except syslog) use the same message buffer
scheme, and the message is constructed once and once
only.
Changes to the handling of VTY_LOCK() etc.
Uses uty.h to pick up the "private" functions from vty.c
et al.
lib/log.h
Changes to the buffering of log messages.
new lib/mem_tracker.c
New code to track memory allocation/deallocation, for
debug purposes.
lib/memory.c
lib/memory.h
Updated to allow the use of the mem_tracker.
lib/memtypes.awk
Made the memtypes into a named enum MTYPE.
lib/memtypes.c
Various new memory types.
lib/mqueue.c
lib/mqueue.h
Add mqueue_finish function for close-down.
lib/network.c
lib/network.h
Added non-blocking read_nb() and write_nb().
new lib/node_type.h
As above.
lib/plist.c
Remove vty_puts() which wasn't a good idea.
lib/qlib_init.c
Added qps_init() to first stage and mqueue_finish to
finish.
lib/qpnexus.c
lib/qpnexus.h
More flexible hooks for in_thread_init and in_thread_final.
lib/qpselect.c
lib/qpselect.h
Added qps_start_up() to build the required maps once and
for all.
Added qdebug to control the debug checks and validation.
Improved validation and test functions.
new lib/qstring.c
new lib/qstring.h
New code for limited flexible string handling.
lib/qtimers.c
Added qdebug to control the debug checks and validation.
lib/routemap.c
Use vty_set_node().
lib/sockunion.c
lib/sockunion.h
Tidied up and regularised the handling of sin_len and
sin6_len.
Created common function for setting port into socket.
Created common function for initialisation/allocation of
new sockunion.
Reduced various functions by using common sub-functions.
Rationalised some code.
Added sockunion_listen() and sockunion_new_sockaddr().
Renamed sockunion_new() to sockunion_new_prefix().
Improved some logging messages.
Added documentation.
new lib/uty.h
Functions etc. used only by vty/command/log/vty_io and
vty_cli.
lib/vector.c
lib/vector.h
Added vector_t type.
Removed VECTOR_INDEX, vector_only_wrapper_free() and
vector_only_index_free() -- following improvement of
code in command.c.
Added vector_set_min_length(), vector_set_new_min_length()
and vector_length() functions.
new lib/vio_fifo.c
new lib/vio_fifo.h
New code to manage simple FIFO of indefinite length.
lib/vty.c
lib/vty.h
Reworked. Broken into vty.c, vty_io.c and vty_cli.c.
new lib/vty_cli.c
new lib/vty_cli.h
CLI handling parts of the vty family.
new lib/vty_io.c
new lib/vty_io.h
I/O parts of the vty family.
lib/workqueue.h
Introduced tyedefs for the various call-back entries.
new tests/test-list_util.c
Tests for the list-util stuff.
vtysh/vtysh.c
Small change to interface for cmd_execute_command()
Diffstat (limited to 'lib/keystroke.h')
-rw-r--r-- | lib/keystroke.h | 187 |
1 files changed, 187 insertions, 0 deletions
diff --git a/lib/keystroke.h b/lib/keystroke.h new file mode 100644 index 00000000..4dc94d12 --- /dev/null +++ b/lib/keystroke.h @@ -0,0 +1,187 @@ +/* Keystroke Buffering -- header + * Copyright (C) 2010 Chris Hall (GMCH), Highwayman + * + * This file is part of GNU Zebra. + * + * GNU Zebra is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * GNU Zebra is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Zebra; see the file COPYING. If not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef _ZEBRA_KEYSTROKE_H +#define _ZEBRA_KEYSTROKE_H + +#include <stddef.h> +#include <stdint.h> +#include <stdbool.h> + +#include <arpa/telnet.h> + +#include "zassert.h" +#include "vio_fifo.h" + +#ifndef Inline +#define Inline static inline +#endif + +/*============================================================================== + * Keystroke buffering + */ + +enum { keystroke_max_len = 100 } ; + +enum keystroke_type +{ + ks_null = 0, /* nothing, nada, bupkis... */ + ks_char, /* character -- uint32_t */ + ks_esc, /* ESC xx */ + ks_csi, /* ESC [ ... or CSI ... */ + ks_iac, /* Telnet command */ + + ks_type_count, + + ks_type_reserved = 0x0F, +} ; +CONFIRM(ks_type_count <= ks_type_reserved) ; + +enum keystroke_null +{ + knull_not_eof, + knull_eof +}; + +enum keystroke_flags +{ + kf_compound = 0x80, /* marker on all compound characters */ + kf_reserved = 0x40, + kf_broken = 0x20, /* badly formed in some way */ + kf_truncated = 0x10, /* too big for buffer ! */ + /* for ks_null => EOF */ + + kf_type_mask = 0x0F, /* extraction of type */ +} ; + +CONFIRM(ks_type_reserved == kf_type_mask) ; + +typedef struct keystroke* keystroke ; +typedef struct keystroke_stream* keystroke_stream ; + +struct keystroke +{ + enum keystroke_type type ; + uint8_t flags ; + + uint32_t value ; + + unsigned len ; + uint8_t buf[keystroke_max_len] ; +} ; + +/* Telnet commands/options */ +enum tn_Command +{ + tn_IAC = IAC, /* IAC IAC interpret as command: */ + tn_DONT = DONT, /* IAC DONT <opt> you are not to use option */ + tn_DO = DO, /* IAC DO <opt> please, you use option */ + tn_WONT = WONT, /* IAC WONT <opt> I won't use option */ + tn_WILL = WILL, /* IAC WILL <opt> I will use option */ + tn_SB = SB, /* IAC SB <opt> interpret as subnegotiation */ + tn_GA = GA, /* IAC GA you may reverse the line */ + tn_EL = EL, /* IAC EL erase the current line */ + tn_EC = EC, /* IAC EC erase the current character */ + tn_AYT = AYT, /* IAC AYT are you there */ + tn_AO = AO, /* IAC AO abort output--but let prog finish */ + tn_IP = IP, /* IAC IP interrupt process--permanently */ + tn_BREAK = BREAK, /* IAC BREAK break */ + tn_DM = DM, /* IAC DM data mark--for connect. cleaning */ + tn_NOP = NOP, /* IAC NOP nop */ + tn_SE = SE, /* IAC SE end sub negotiation */ + tn_EOR = EOR, /* IAC EOR end of record (transparent mode) */ + tn_ABORT = ABORT, /* IAC ABORT Abort process */ + tn_SUSP = SUSP, /* IAC SUSP Suspend process */ + tn_EOF = xEOF, /* IAC xEOF End of file: EOF is already used... */ + + tn_SYNCH = SYNCH, /* IAC SYNCH for telfunc calls */ +} ; + +enum tn_Option +{ + to_BINARY = TELOPT_BINARY, /* 8-bit data path */ + to_ECHO = TELOPT_ECHO, /* echo */ + to_RCP = TELOPT_RCP, /* prepare to reconnect */ + to_SGA = TELOPT_SGA, /* suppress go ahead */ + to_NAMS = TELOPT_NAMS, /* approximate message size */ + to_STATUS = TELOPT_STATUS, /* give status */ + to_TM = TELOPT_TM, /* timing mark */ + to_RCTE = TELOPT_RCTE, /* remote controlled tx and echo */ + to_NAOL = TELOPT_NAOL, /* neg. about output line width */ + to_NAOP = TELOPT_NAOP, /* neg. about output page size */ + to_NAOCRD = TELOPT_NAOCRD, /* neg. about CR disposition */ + to_NAOHTS = TELOPT_NAOHTS, /* neg. about horizontal tabstops */ + to_NAOHTD = TELOPT_NAOHTD, /* neg. about horizontal tab disp. */ + to_NAOFFD = TELOPT_NAOFFD, /* neg. about formfeed disposition */ + to_NAOVTS = TELOPT_NAOVTS, /* neg. about vertical tab stops */ + to_NAOVTD = TELOPT_NAOVTD, /* neg. about vertical tab disp. */ + to_NAOLFD = TELOPT_NAOLFD, /* neg. about output LF disposition */ + to_XASCII = TELOPT_XASCII, /* extended ascii character set */ + to_LOGOUT = TELOPT_LOGOUT, /* force logout */ + to_BM = TELOPT_BM, /* byte macro */ + to_DET = TELOPT_DET, /* data entry terminal */ + to_SUPDUP = TELOPT_SUPDUP, /* supdup protocol */ + to_SUPDUPOUTPUT = TELOPT_SUPDUPOUTPUT,/* supdup output */ + to_SNDLOC = TELOPT_SNDLOC, /* send location */ + to_TTYPE = TELOPT_TTYPE, /* terminal type */ + to_EOR = TELOPT_EOR, /* end or record */ + to_TUID = TELOPT_TUID, /* TACACS user identification */ + to_OUTMRK = TELOPT_OUTMRK, /* output marking */ + to_TTYLOC = TELOPT_TTYLOC, /* terminal location number */ + to_3270REGIME = TELOPT_3270REGIME, /* 3270 regime */ + to_X3PAD = TELOPT_X3PAD, /* X.3 PAD */ + to_NAWS = TELOPT_NAWS, /* window size */ + to_TSPEED = TELOPT_TSPEED, /* terminal speed */ + to_LFLOW = TELOPT_LFLOW, /* remote flow control */ + to_LINEMODE = TELOPT_LINEMODE, /* Linemode option */ + to_XDISPLOC = TELOPT_XDISPLOC, /* X Display Location */ + to_OLD_ENVIRON = TELOPT_OLD_ENVIRON, /* Old - Environment variables */ + to_AUTHENTICATION = TELOPT_AUTHENTICATION, /* Authenticate */ + to_ENCRYPT = TELOPT_ENCRYPT, /* Encryption option */ + to_NEW_ENVIRON = TELOPT_NEW_ENVIRON, /* New - Environment variables */ + to_EXOPL = TELOPT_EXOPL, /* extended-options-list */ +} ; + + +/*============================================================================== + * Functions + */ +extern keystroke_stream +keystroke_stream_new(uint8_t csi_char) ; + +extern void +keystroke_stream_set_eof(keystroke_stream stream) ; + +extern void +keystroke_stream_free(keystroke_stream stream) ; + +extern bool +keystroke_stream_empty(keystroke_stream stream) ; +extern bool +keystroke_stream_eof(keystroke_stream stream) ; + +extern void +keystroke_input(keystroke_stream stream, uint8_t* ptr, size_t len, + keystroke steal) ; +extern int +keystroke_get(keystroke_stream stream, keystroke stroke) ; + +#endif /* _ZEBRA_KEYSTROKE_H */ |