libosmovty 1.13.1.1-afb4 Osmocom VTY library

Functions | Variables
telnet_interface.c File Reference

Telnet interface towards Osmocom VTY. More...

`#include <sys/socket.h>`
`#include <netinet/in.h>`
`#include <errno.h>`
`#include <stdlib.h>`
`#include <stdio.h>`
`#include <string.h>`
`#include <unistd.h>`
`#include <osmocom/core/msgb.h>`
`#include <osmocom/core/socket.h>`
`#include <osmocom/core/talloc.h>`
`#include <osmocom/core/logging.h>`
`#include <osmocom/core/signal.h>`
`#include <osmocom/vty/telnet_interface.h>`
`#include <osmocom/vty/buffer.h>`
`#include <osmocom/vty/command.h>`

## Functions
| LLIST_HEAD (active_connections)
static int | telnet_new_connection (struct osmo_fd *fd, unsigned int what)
static int | _telnet_init_dynif (void *tall_ctx, void *priv, const char *ip, int port)
int | telnet_init (void *tall_ctx, void *priv, int port)
| Initialize telnet based VTY interface listening to 127.0.0.1. More...
int | telnet_init_dynif (void *tall_ctx, void *priv, const char *ip, int port)
| Initialize telnet based VTY interface. More...
int | telnet_init_default (void *tall_ctx, void *priv, int default_port)
| Initializes telnet based VTY interface using the configured bind addr/port. More...
int | telnet_close_client (struct osmo_fd *fd)
| close a telnet connection More...
static int | client_data (struct osmo_fd *fd, unsigned int what)
bool | vty_is_active (struct vty *vty)
void | vty_event (enum event event, int sock, struct vty *vty)
| callback from core VTY code about VTY related events More...
void | telnet_exit (void)
| Close all telnet connections and release the telnet socket. More...

## Variables
static void * | tall_telnet_ctx
static struct osmo_fd | server_socket
struct host | host

## Detailed Description

Telnet interface towards Osmocom VTY.

This module contains the code implementing a telnet server for VTY access. This telnet server gets linked into each libosmovty-using process in order to enable interactive command-line introspection, interaction and configuration.

You typically call telnet_init_default once from your application code to enable this.

## Function Documentation

## ◆ _telnet_init_dynif()

static int _telnet_init_dynif | ( | void * | tall_ctx,
|  | void * | priv,
|  | const char * | ip,
|  | int | port
| ) |  |
| static

References osmo_fd::data, DLGLOBAL, LOGL_ERROR, LOGL_NOTICE, LOGP, OSMO_SOCK_F_BIND, osmo_sock_init_ofd(), server_socket, and tall_telnet_ctx.

Referenced by telnet_init(), telnet_init_default(), and telnet_init_dynif().

## ◆ client_data()

static int client_data | ( | struct osmo_fd * | fd,
|  | unsigned int | what
| ) |  |
| static

References BUFFER_EMPTY, buffer_flush_all(), osmo_fd::data, osmo_fd::fd, telnet_connection::fd, vty::obuf, OSMO_FD_READ, OSMO_FD_WRITE, telnet_connection::vty, vty_read(), and osmo_fd::when.

Referenced by telnet_new_connection().

## ◆ LLIST_HEAD()

LLIST_HEAD | ( | active_connections |  | ) |

## ◆ telnet_close_client()

int telnet_close_client | ( | struct osmo_fd * | fd | ) |

close a telnet connection

References osmo_fd::data, telnet_connection::dbg, DLGLOBAL, telnet_connection::entry, osmo_fd::fd, telnet_connection::fd, llist_del(), log_del_target(), LOGL_INFO, LOGP, osmo_fd_unregister(), osmo_sock_get_name_buf(), and OSMO_SOCK_NAME_MAXLEN.

Referenced by telnet_exit(), and vty_event().

## ◆ telnet_new_connection()

static int telnet_new_connection | ( | struct osmo_fd * | fd,
|  | unsigned int | what
| ) |  |
| static

References osmo_fd::cb, client_data(), osmo_fd::data, DLGLOBAL, telnet_connection::entry, osmo_fd::fd, telnet_connection::fd, len(), llist_add_tail(), LOGL_ERROR, LOGL_INFO, LOGP, OSMO_FD_READ, osmo_fd_register(), osmo_sock_get_name_buf(), OSMO_SOCK_NAME_MAXLEN, telnet_connection::priv, tall_telnet_ctx, telnet_connection::vty, vty_create(), and osmo_fd::when.

## ◆ vty_event()

void vty_event | ( | enum event event event | ,
|  | int | sock,
|  | struct vty * | vty
| ) |  |

callback from core VTY code about VTY related events

References vty_signal_data::event, telnet_connection::fd, osmo_fd_read_enable(), osmo_fd_write_enable(), osmo_signal_dispatch(), vty::priv, S_VTY_EVENT, vty_signal_data::sock, SS_L_VTY, telnet_close_client(), vty::type, vty_signal_data::vty, vty, VTY_CLOSED, VTY_READ, VTY_TERM, and VTY_WRITE.

Referenced by vty_close(), vty_create(), vty_out_va(), and vty_read().

## Variable Documentation

## ◆ server_socket

struct osmo_fd server_socket
| static

Initial value:
= {
.when = OSMO_FD_READ,
.cb = telnet_new_connection,
.priv_nr = 0,
}
OSMO_FD_READ
#define OSMO_FD_READ
telnet_new_connection
static int telnet_new_connection(struct osmo_fd *fd, unsigned int what)
Definition: telnet_interface.c:177

Referenced by _telnet_init_dynif(), and telnet_exit().

## ◆ tall_telnet_ctx

void* tall_telnet_ctx
| static

Referenced by _telnet_init_dynif(), telnet_exit(), and telnet_new_connection().