Commit Graph

193 Commits

Author SHA1 Message Date
Pau Espin 3ad56f0408 debian: Install osmo_pcap_clean_old in osmo-pcap-server pkg
Change-Id: Ia4b031fdf54cde3d00818df82e89733420a735ba
2018-11-01 12:52:30 +01:00
Pau Espin a3a6ceb5f7 gitignore: Add compile
Change-Id: Ie801d6929068d11fafd24a1370e60e984b0137c2
2018-11-01 12:52:30 +01:00
Pau Espin 45283d84e3 Install cfg files with autotools
Cfg files are moved to doc/examples like in other osmocom projects.
All the cfg files get installed into
$prefix/share/doc/osmo-pcap/examples/$subdir/, and 1 script per binary is
installed into /etc/osmocom.

Change-Id: If3f3a7d3867c0d4d2b1fe01f465532d1ce4bda66
2018-11-01 12:52:22 +01:00
Pau Espin b29f84ff6c Install systemd services with autotools
Change-Id: Id938f3dab4826ac748abb5e0b169d800c2a625a5
2018-11-01 12:51:39 +01:00
Pau Espin b96c957a22 debian: Clean up to look like other osmocom projects
Change-Id: Id71699642b799f5b2f8f3b794b9493ddaeb70cc0
2018-11-01 12:51:35 +01:00
Pau Espin 80d2b7b8dd contrib/jenkins.sh: Update to current osmocom infra
Otherwise builds end failing in osmocom jenkins/gerrit.

Change-Id: I955b99ce27df143f5d022619dd14e32b763e6c14
2018-11-01 12:42:54 +01: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 b799344ecd client_send_link: snaplen not needed during allocation
We don't send any pkt data, so no need to allocate snaplen bytes extra.

Change-Id: I8d6385f6ff265564492121812a7a9f2bcfea3d5f
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
Pau Espin f10c57801a Replace '.' in counter names with ':'
The '.' is illegal character in counter names, as they are exported
via CTRL interface, where '.' has a special meaning that cannot be
used by strings comprising the variable name.

Change-Id: Icec5338d3242137980fa05d2c7ae2db940afb542
2018-10-08 20:20:43 +02:00
Pau Espin 78262bda57 jenkins.sh: enable werror and sanitize configure flags
Change-Id: Id8ad324ae9e1c57e1328bd1be04977e921125847
2018-10-08 13:41:47 +02:00
Pau Espin e241eada55 configure.ac: Add --enable-sanitize flag
Change-Id: I6a3bc49142b93a35988c8763f3125d7b5ffddaef
2018-10-08 13:39:51 +02:00
Pau Espin f59fabf9dc configure.ac: Add --enable-werror flag
Change-Id: I387a3365fb5b7340bf67fb945df434442924a4c7
2018-10-08 13:38:42 +02:00
Pau Espin d475673b69 osmo_client_send_data: Fix wrong log format
According to pcap.h, type bpf_u_int32 can be 32 bits on some systems,
so better cast explicitly to size_t to make sure always correct size is
used by log function.

Fixes warning:
osmo-pcap/src/osmo_client_network.c:175:4: warning: format ‘%zu’ expects argument of type ‘size_t’, but argument 7 has type ‘bpf_u_int32’ {aka ‘unsigned int’} [-Wformat=]
    "Capture len too big %zu\n", in_hdr->caplen);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~

Change-Id: I98654da143218d3e57da4e57781252eb3d3f3d5b
2018-10-08 13:33:50 +02:00
Pau Espin dc27ca85aa Drop osmo_init_logging and use osmo_init_logging2
Change-Id: Ib1c38f6134b3c1988477caa0f2c281b1ef01d5e0
2018-10-08 13:29:52 +02:00
Pau Espin 5f3c30c40c server: Properly name main talloc ctx
Change-Id: I810417d84c6a6ebcbc4b75a9bc41607bb0637228
2018-10-08 13:29:52 +02:00
Pau Espin 2828690633 client: Properly name main talloc ctx
Change-Id: Ibaa7f0e0add5f5e61cc0bb82341ee3b6b5c0cf07
2018-10-08 13:29:52 +02:00
Pau Espin 6e9bf9aa15 vty: skip installing cmds now always installed by default
Fixes following compilation warning:
osmo-pcap/src/osmo_client_vty.c:511:2: warning: ‘install_default’ is deprecated: Now happens implicitly with install_node() [-Wdeprecated-declarations]

Depends: libosmocore I5021c64a787b63314e0f2f1cba0b8fc7bff4f09b
Change-Id: I943f68dbafd7906313ad9e59f4adb289ae23cdec
2018-10-08 13:29:52 +02:00
Pau Espin 3dfdbc21dc cosmetic: client: rename forward_packet function
Function only checks if packet should be forwarded, it doesn't forward
any packet.

Change-Id: I87cd64290245db134b17bc0d6665c58f1cde17b6
2018-10-08 13:08:52 +02:00
Harald Welte e89231d8b0 debian/control: Fix URLs for homepage, git, gitweb
Change-Id: Iff74cf6b3e53a6786a96738b609a2e2d685b1300
2018-02-09 12:07:50 +01: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
Max 53044df9d5 Use release helper from libosmocore
See
https://osmocom.org/projects/cellular-infrastructure/wiki/Make_a_new_release
for details.

Change-Id: Iafe5905895a656b7055d58ca8f745fcfa4bd9886
Related: OS#1861
2017-08-28 10:57:19 +00:00
Max 93ac357b48 Add gitreview config
Change-Id: I35b3aaa3f8af4127d8a1b00c77ab02ae6a182714
2017-08-22 12:34:59 +02:00
Harald Welte 5f071cd2c6 client: Move to osmo_sock_init2_ofd()
We can simplify the code even further by using the osmo_fd version
of osmo_sock_init2() called osmo_sock_init2_ofd(), which takes care
of filling the osmo_fd.fd member and registering the socket in the
select loop.

Change-Id: Ibf1480e7dee287db77a19bb9f0254edddf7706ab
2017-07-21 18:25:15 +02:00
Harald Welte f266924bac Use libosmocore osmo_sock_init2() instead of local implementation
A related function for "create a socket, bind it locally and connect
remotely" has meanwhile been introduced in libosmocore, so the local
implementation can go.

Change-Id: Ieda77ad8b3f7b89faa09882c0037562ce4d0fc89
2017-07-21 18:20:36 +02:00
Harald Welte 2fe9cb937d Rename osmo_pcap_{client_server} executables to osmo-pcap-{client,server}
This naming is more in line with what all the other osmocom programs are
doing (e.g. osmo-pcu, osmo-bts-sysmo, osmo-bsc, ...).  We don't
generally use osmo_ anywhere else, so I suggest to change it for more
uniformity.

Change-Id: If1e3ce76f93266e0f01c801204769432b571fdb1
2017-07-21 15:21:01 +02: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
Harald Welte 604e071159 sock_src_init(): Don't freeaddrinfo() undefined src_result
src_result is only valid "if (src)", so we cannot unconditionally
free it:

(gdb) bt
    host=0x52 <error: Cannot access memory at address 0x52>, src=0x0)
    at /usr/src/debug/osmo-pcap/0.0.6+gitrAUTOINC+4776b2972e-r1d/git/src/osmo_client_network.c:165

Change-Id: I3b6778d9110583ecb1daec59ef2c86465d5818b9
2017-07-21 13:11:24 +02:00
Holger Hans Peter Freyther 4776b2972e debian: Add -dbg packages for the osmo-pcap-client and osmo-pcap-server
Currently looking at a weird issue. Make it possible to install the
-dbg packages.

Change-Id: I7d6c8e491be459151c1531b86f28bb1dc2ee8bb4
2017-03-07 23:17:41 +01:00
Holger Hans Peter Freyther 17f5b00506 debian: Make a new release with the new feature
Change-Id: Ibe86b761b494e0fb78bbbc78e3c1982e44185750
2017-01-17 09:13:36 +01: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 fdebd88059 debian: Make a new release with the new features we gained
Change-Id: I85e210e6ed14aef085902a5af6407d51685aecba
2016-11-09 02:11:45 +01:00
Holger Hans Peter Freyther 36a183fd78 client: Tolerate an invalid pcap_handle
When not running as root the opening might fail and then we would
crash when sending the link information. Do not crash. This could
have crashed before the re-factoring but due the async connect it
seems more likely we hit it now.

Change-Id: I26a10c401a9a8998acc50a4bd4432d2ac7fceaeb
2016-11-09 01:46:35 +01:00
Holger Hans Peter Freyther 9294c40f14 client: disconnect before connecting the connection
With the VTY a user can write connect, connect, connect and this
would lead to leaking fds. Always close the connection.

Change-Id: Iab94dc2fd28496bf5fd8ceb5611f9e6505ccae1b
2016-11-09 01:04:04 +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 d7ab53dc16 client: Do not connect default connection if no ip/port present
Ignore the default connection if no srv_port and has been specified.

Change-Id: I6a3a9a0af73a9183a6b233937af3357d15a07f25
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 956c3facf1 client: Enable a non-blocking connect to the PCAP server
If we want to have multiple servers we should not block when trying to
connect to one of them. Enable non blocking mode and handle the fd
specially until it is connected. E.g. on failed connect the read will
become readable but fail, otherwise it becomes writable.

Clear the write queue to make sure that the link data is sent first.
We might be able to introduce a osmo_wqueue_prepend.

Change-Id: Iae2bc264d15aa8598beefc194e3b8c4ebe87320a
2016-11-09 01:03:59 +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 bdda28b1f5 client: Finish renaming client to conn in other places of the code
Change-Id: I3c7c499c921b03752cbbcdda3eac8ca360323a22
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 0381276993 Merge branch 'feature/tls'
Add TLS support to the client and server. What is known working is
support of anonymous mode with generated DH params. Mildly tested
by hand over localhost.
2016-09-08 16:32:36 +02:00
Holger Hans Peter Freyther 22acd211f1 test: Add tls config file and enable tls a bit
Change-Id: Iba0008e3e0da276cc65c7501145b65294233febb
2016-09-08 16:24:04 +02:00
Holger Hans Peter Freyther 07b94157ec doc: Add initial documentation for the tls support
Change-Id: Ifc042e6755c223339fafbc3af9106073341f9b45
2016-09-08 16:17:02 +02: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 ff3314e45c server: Allow to enable tls for the pcap server
Add simple vty command to enable tls per client or not. We still
need a lot more tls commands for the server.

Change-Id: I583b7d5c999ed01c135882895fb2a8f04739ad00
2016-09-08 16:17:01 +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