Loading...
Searching...
No Matches
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.
int | telnet_init_dynif (void *tall_ctx, void *priv, const char *ip, int port)
| Initialize telnet based VTY interface.
int | telnet_init_default (void *tall_ctx, void *priv, int default_port)
| Initializes telnet based VTY interface using the configured bind addr/port.
int | telnet_close_client (struct osmo_fd *fd)
| close a telnet connection
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
void | telnet_exit (void)
| Close all telnet connections and release the telnet socket.

## 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()

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

static

References server_socket, and tall_telnet_ctx.

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

## client_data()

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, 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, telnet_connection::entry, osmo_fd::fd, and telnet_connection::fd.

Referenced by telnet_exit(), and vty_event().

## telnet_new_connection()

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

static

References osmo_fd::cb, client_data(), osmo_fd::data, telnet_connection::entry, osmo_fd::fd, telnet_connection::fd, 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, vty::priv, S_VTY_EVENT, vty_signal_data::sock, telnet_close_client(), vty::type, vty_signal_data::vty, VTY_CLOSED, VTY_READ, VTY_TERM, VTY_WRITE, and osmo_fd::when.

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().