Commit Graph

47 Commits

Author SHA1 Message Date
Pau Espin a55253f438 client: Add 'wqueue max-length <0-4294967295>' VTY command
This allows setting a suitable write-queue max length per client. The
desired value can be different based on a lot of variables, like memory
availabilty, network and CPU load, input/output link state, etc.

Related: SYS#5921
Change-Id: I4e9d5d836ddda215f9e7a075aa8e10d2d3854dd2
2022-04-14 18:32:23 +02:00
Pau Espin b9be6767ab server: Add vty command file-permission-mask
Related: SYS#5792
Change-Id: I78e0b56b38de438ee5fb679ae41c65b02ea2e722
2022-01-12 17:44:38 +01:00
Oliver Smith eedd83c113 Change default ports of client, server
Resolve conflict with other Osmocom software by moving ports:

osmo-pcap-client 4237 -> 4227
osmo-pcap-server 4238 -> 4228

Notably the defines OSMO_VTY_PORT_PCAP_CLIENT and _SERVER are currently
not provided by libosmocore, but will be added with the related commit.

Related: OS#5203
Related: libosmocore I098f211370bba61995ce424ab64029bdd4c49e2d
Change-Id: I3b18b1fbbca2799f868f28104e2f5d513f93d46c
2021-08-05 19:24:02 +02:00
Vadim Yanitskiy ff3f4b3bef vty_{client,server}_init(): remove unused argument
Change-Id: I65256c8602e91bcdbe5fe9e532b6ce7d347d3980
2021-04-16 20:30:18 +02:00
Pau Espin a82aaef507 server: Add pcap snaplen VTY cmd
Change-Id: I8fdcdc1a58926ec66a1dc5dc7a5e57ed4dceb4b4
2018-10-08 20:20:43 +02:00
Pau Espin 868a501213 server: Improve verification of messages from client
Take the chance to define SERVER_MAX_DATA_SIZE as pcap payload, which we
can later match to configurable snaplen parameter.

Change-Id: I45d4c59026faf1108c0976eb6ad8c270e3577dbf
2018-10-08 20:20:43 +02:00
Pau Espin f946fa21ee client: Add pcap snaplen VTY cmd
Change-Id: I84fda9f27b725e031c218187ab679392dfa7ec3d
2018-10-08 20:20:43 +02:00
Pau Espin 168949e119 client: Set snaplen to MAXIMUM_SNAPLEN
Despite this value not being exported publicly, the truth is that
tcpdump and wireshark nowadays avoid processing any file with snaplen
bigger than this value:
"tcpdump: pcap_loop: invalid packet capture length 861244, bigger than
snaplen of 262144"
It also fails to set snaplen to values bigger than that:
"tcpdump -s 262145" --> "tcpdump: invalid snaplen 262145"

pcapfix also warns about wrong packet length if bigger than same value
(defined as PCAP_MAX_SNAPLEN there).

MAXIMUM_SPANPLEN is defined in tcpdump's netdissect.h and libpcap's
pcap-int.h. It is also defined as WTAP_MAX_PACKET_SIZE in
wireshark/wiretap/wtap.h (this one being the only publicly available).

Change-Id: Ib7449d5aba9da342c150704ebd0e1f09e7f7276c
2018-10-08 20:20:43 +02:00
Pau Espin db7be44632 Use enum for PKT_LINK_*
Makes it easier to understand different types and how they relate to
same field.

Change-Id: I1bec4d5d132a1476f9c418502ad808b7c778cee2
2018-10-08 20:20:43 +02:00
Harald Welte f335e37ed5 Add support for generating IPIP to osmo-pcap-client
This allows the user to change the configuration between either using

a) the classic OsmoPCAP protocol (over TCP with or without TLS)
   which is used when you want to talk to an osmo-pcap-server

b) the (new) IPIP encapsulation, which will simply take the IP
   packet (without Ethernet or pcap header) and transmit it inside IPIP
   to the specified server IP address.  This is useful for gettin
   real-time streaming into wireshark.

Change-Id: I8056fc163ac2f15adcb964d867dd5e51df4e4710
2018-02-09 12:07:50 +01:00
Harald Welte 2aea8704f3 Use TCP port numbers for VTY that don't overlap with other Osmocom Software
osmo-pcap for historical reasons uses the same port numbers as
OsmoPCU and OsmoBTS.  This leads to problems when wanting to run related
software together on one system.  Let's break the historical assumptions
and start with non-overlapping port numbers that are allocated/assigned
from https://osmocom.org/projects/cellular-infrastructure/wiki/Port_Numbers

Change-Id: I638ac0534517931d0987ce9f72f5db4f5b6c16b7
2017-07-21 15:18:02 +02:00
Holger Hans Peter Freyther 40c1e85499 client: Allow to bind to a specific source_ip
Modify the osmo_sock_init (code clone to be integrated upstream)
to allow binding to a specific source ip and source port. Allow
the source ip to be configured but allow the kernel to pick a
random port for us.

This is necessary for systems with multiple interfaces where the
default route is not necessarily the right one to connect to the
pcap server.

Change-Id: I84e728b0752213d28f970fcbbfd6565c441ccfeb
2017-01-17 09:06:42 +01:00
Holger Hans Peter Freyther 0a94e57b72 client: Allow to stop and remove a connection
Change-Id: I2118723345caf6a68f03de74a4182506e7bf105c
2016-11-09 01:04:04 +01:00
Holger Hans Peter Freyther 1448f50db4 client: Allow to configure and connect multiple servers
Allow to configure multiple servers and connect. Introduce a new VTY
node to allow multiple servers. Add an explicit connect. Do not put
the main connection into the same list but assume it exists.

Change-Id: I9448ad4a005dd7c7eb1c615d03e57d6cb058ae4d
2016-11-09 01:04:04 +01:00
Holger Hans Peter Freyther e3d7c3e154 client: Prepare to work with a list of servers
There is no VTY code yet and no servers in the list but it looks
good client this.

Change-Id: Ic35748f1a95a880a9fa49dd18361592d8ac941ba
2016-11-09 00:20:29 +01:00
Holger Hans Peter Freyther 13f397c68c client: Prepare to have multiple server connections
Take out various fields into a new connection class. We will have the
option to connect to multiple servers.

Change-Id: I820176d133fbdb0240a16eb4e1a6d505e5c080c6
2016-11-09 00:20:29 +01:00
Holger Hans Peter Freyther cf29fd7069 server: Add vty interface for the TLS configuration
Make the priority configurable, load DH params, allow to specify
certificates or anonymous operations.

Change-Id: I8ec3c0f8e1ee2089e1b7dacd9de842260930032f
2016-09-08 16:17:02 +02:00
Holger Hans Peter Freyther 9ea4da4bbb server: Introduce tls mode for the server
Using tls priority of NORMAL:+ANON-ECDH:+ANON-DH already allows a
client to connect to a server and protect the data using tls.

Generate the dh params on load (and do that for the client right
now as well) but that will go away soon.

Change-Id: Ifa2ad24c0a631573c259a3bf94b91a946ad9ec9d
2016-09-08 16:17:01 +02:00
Holger Hans Peter Freyther 1bec9d5d09 server: Add API function to close a connection
Change-Id: I4295854c749d86ca8c34a979c877363d9f48e176
2016-09-08 16:17:00 +02:00
Holger Hans Peter Freyther 098850d0a8 server: Move to a write_queue for the conn socket
We are only reading from the socket and never write but the osmo_tls
code is integrated with it. We will never write and the queue size is
set to 0. Simplify the read_cb.

Change-Id: I32335b1f7b7ed06b92c6222516c185301ce13781
2016-09-08 16:17:00 +02:00
Holger Hans Peter Freyther c266796caa client: Initial support for TLS in the client
Use GNUtls because it is GPL compatible and instead of mbedTLS seems
to have a working non-blocking I/O integration. GNUtls has various
issues that could not be resolved easily:

* Pick spdy as sub protocol
* gmt_time not randomized
* private key loaded to RAM (but not verified)

This is the beginning and not the end. Client support might need more
work with actual tls verification. Maybe more manual x509 cert
verification is needed and maybe client certs don't work at all. I try
to ignore renegotiation as I threw away the key.

Reload x509 creds and keys as they might have changed from one
connection to another.

Change-Id: I9128e14084da1fc2705f858393f98b8133996172
2016-09-08 16:16:55 +02:00
Holger Hans Peter Freyther c1c194393b client: Add API function to close and re-connect network connection
Change-Id: Ib4e17948ffa84e73c1c81734e6002a73251d744b
2016-09-08 15:48:02 +02:00
Holger Hans Peter Freyther fa5572e2af client: Use pcap_stats and export them as statistics
Attempt to write code that detects the wrap and is doing the
right thing when it happens.

Change-Id: I501ebc49d3e86b0605ec1fbe2f62aee3f362aa36
2016-08-19 20:28:21 +02:00
Holger Hans Peter Freyther 99526a6ad0 server: Add global and per client counters and begin to count
Add the basics for getting a picture what a client and the server
is doing. We need to create unique descriptions as the code is
working with names and not numbers for clients.

Change-Id: I4a9be5bdd815d280cccf0199efc2ca79fc77d393
2016-08-19 19:23:00 +02:00
Holger Hans Peter Freyther c3455dcb79 client: Additional counters for the statistics
Add more counters and start counting them when reading from the
PCAP library and when trying to write to the socket.

Change-Id: I52d3064a265b402ac849d8578a14f718156c0805
2016-08-19 17:31:01 +02:00
Holger Hans Peter Freyther f416463a3c client: First round of statistics in the pcap client
Count certain events that can help to understand what is going on.
This includes OOM, failure to queues.

Change-Id: I4a2dad32afb577822c7181d2813ea5a7e693c704
2016-08-18 18:39:53 +02:00
Holger Hans Peter Freyther df92652c95 vty: Fix compiler warning about type changes
osmo_client_main.c:57:2: warning: initialization from incompatible pointer type
  .go_parent_cb = osmopcap_go_parent,
  ^
osmo_client_main.c:57:2: warning: (near initialization for ‘vty_info.go_parent_cb’)
  CCLD     osmo_pcap_client
  CC       osmo_server_main.o
osmo_server_main.c:56:2: warning: initialization from incompatible pointer type
  .go_parent_cb = osmopcap_go_parent,
  ^
osmo_server_main.c:56:2: warning: (near initialization for ‘vty_info.go_parent_cb’)

Change-Id: If73c85a64789ef4bff63dcfe008e918e650b428f
2016-08-13 10:29:46 +02:00
Holger Hans Peter Freyther e024869a72 server: Add zmq based event and data interface to the server
To allow easily extracting or streaming the data to an external
analysis system, zeromq can be configured (and reconfigured). The
system works as fire and forget and no loss detection is present.

A simple go based client application is provided to subscribe to
the publisher.

Change-Id: I4f3e6d675023a81b7d2ee19bf1f44a2be0ca003c
2016-08-05 16:10:05 +02:00
Holger Hans Peter Freyther ad29ce6f06 server: Add zmq interface for publishing events
Change-Id: I383558bb9aad3cb149f35e13910a1d6aa79afc84
2016-08-04 18:02:57 +02:00
Holger Hans Peter Freyther 2899428be2 server: Add a config knob to not store the pcap stream
We might only want to centralize the data streams but handle the
data differently. This will be combined with an upcoming ZeroMQ
publisher feature to broadcast all events out.

Change-Id: I12c6bf16310820d882fa28c6930931650475e0bb
2016-08-04 16:14:38 +02:00
Holger Hans Peter Freyther 66b80cc8f5 client: Deal with external representation for pcap files
We need to convert the 64bit timeval on a 64bit userspace (or on
OpenBSD) into a 32bit truncated value for being able to write the
file. This means we have 2038 issue here?
2015-12-03 22:13:38 +01:00
Holger Hans Peter Freyther ff1a5dc751 server: Deal with jumbo frames on the wire
The 2000 as a number is too small. Modern networks can have a
higher MTU (up to 9000). Take this number and assume there is
a big header in front of it.
2015-12-03 19:53:24 +01:00
Holger Hans Peter Freyther b7a834b4cb gprs: Add a custom GPRS filter
Allow to inspect UDP messages and check for GPRS, NS, BSSGP
and then filter LLC frames. Parsing the vL datastructure with
the libpcap syntax is a pain. It could be done using BPF but
we do not want to use bpf asm to specify the entire ruleset.

I looked into using libepan/libwireshark but this has memory
issues and is painful too. So let's parse UDP, NS, BSSGP using
the info we already have. I tried a bit of editcap to generate
a bit of broken data. The length check might still be bad.

I used my crash_20100602.pcap file to count the LLC frames we
detect and compare that to wireshark it ended with the right
number.

  pcap add-filter gprs

can be used to enable the new filtering option after the OS
has received the packet.

Fixes: ONW#1314
2015-09-10 16:55:33 +02:00
Holger Hans Peter Freyther e8b9177706 dist: Attempt to fix the make distcheck 2012-01-06 00:46:38 +01:00
Holger Hans Peter Freyther 56d12cb505 dist: Attempt to fix the make distcheck 2012-01-06 00:45:14 +01:00
Daniel Willmann c7401c6c23 server: Register signal handler to reopen logfiles on SIGHUP 2011-07-19 17:56:07 +02:00
Holger Hans Peter Freyther 39d904f149 osmo-pcap-server: Try to read the the data with a simple state machine 2011-06-01 18:49:07 +02:00
Holger Hans Peter Freyther 9df7dc5f69 wireformat: Send the length in the network order..
this is a format change. but it is necessary now.
2011-06-01 17:34:09 +02:00
Holger Hans Peter Freyther 88c07f2b7e osmo-pcap-server: Prepare a file limit, initialize the base path 2011-06-01 14:02:54 +02:00
Holger Hans Peter Freyther 80b8b606c5 osmo-pcap-server: Accept the client connection from a given host
We now read from a given system.
2011-05-31 23:42:48 +02:00
Holger Hans Peter Freyther 9f6127f592 osmo-pcap-server: Work on the generic VTY interface for the server
Work on being able to configure clients that are allowed to
connect to the server.
2011-05-31 23:42:48 +02:00
Holger Hans Peter Freyther 13619dd235 osmo-pcap-server: Start with the skeleton of the pcap server 2011-05-31 23:42:48 +02:00
Holger Hans Peter Freyther 77288207fa osmo-pcap-client: Connect to a server, send the data to it 2011-05-31 21:19:52 +02:00
Holger Hans Peter Freyther cd2d3db3b7 osmo-pcap-client: Set the filter string on the pcap device.. 2011-05-31 21:19:51 +02:00
Holger Hans Peter Freyther 3b9b38ca68 osmo-pcap-client: Work on the client code, be able to open the device
Add vty code to allow changing the device, this will just attempt
to open and close the device. Nothing else is done.
2011-05-31 17:42:53 +02:00
Holger Hans Peter Freyther 530ecc0879 osmo_pcap_client: Start with the framework for the pcap client
This is just the normal skeleton for the osmocom code.
2011-05-31 15:47:44 +02:00
Holger Hans Peter Freyther 430366a2c5 osmo-pcap: Create a dummy client. 2011-05-31 11:16:55 +02:00