pespin has uploaded this change for review.

View Change

client: Avoid sending link frame over non-connected conn

Otherwise error messages appear upon start when starting the capture and
the conns haven't yet been established (they are started immediately
afterwards in main.c).
The errors are actually harmless since network code takes care of
sending a link frame upon connection TCP/TLS handshake completes.

Change-Id: I091523e1d9f644e97b114b4cc524307a83dd564f
---
M include/osmo-pcap/osmo_pcap_client.h
M src/osmo_client_core.c
M src/osmo_client_network.c
3 files changed, 18 insertions(+), 1 deletion(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/45/39945/1
diff --git a/include/osmo-pcap/osmo_pcap_client.h b/include/osmo-pcap/osmo_pcap_client.h
index fdd59f9..fc65132 100644
--- a/include/osmo-pcap/osmo_pcap_client.h
+++ b/include/osmo-pcap/osmo_pcap_client.h
@@ -149,6 +149,7 @@
void osmo_client_conn_connect(struct osmo_pcap_client_conn *conn);
void osmo_client_conn_disconnect(struct osmo_pcap_client_conn *conn);
void osmo_client_conn_reconnect(struct osmo_pcap_client_conn *conn);
+bool osmo_client_conn_is_connected(const struct osmo_pcap_client_conn *conn);


struct osmo_pcap_handle *osmo_pcap_handle_alloc(struct osmo_pcap_client *client, const char *devname);
diff --git a/src/osmo_client_core.c b/src/osmo_client_core.c
index dd16878..7df14ca 100644
--- a/src/osmo_client_core.c
+++ b/src/osmo_client_core.c
@@ -277,8 +277,10 @@
return rc;
}

+ /* Restart already initialized pcap files to adapt for new capture parameters: */
llist_for_each_entry(conn, &client->conns, entry)
- osmo_client_conn_send_link(conn);
+ if (osmo_client_conn_is_connected(conn))
+ osmo_client_conn_send_link(conn);
return 0;
}

diff --git a/src/osmo_client_network.c b/src/osmo_client_network.c
index 412fe56..73eccac 100644
--- a/src/osmo_client_network.c
+++ b/src/osmo_client_network.c
@@ -605,3 +605,17 @@
}
}
}
+
+bool osmo_client_conn_is_connected(const struct osmo_pcap_client_conn *conn)
+{
+ if (conn->tls_on) {
+ /* No socket yet. */
+ if (conn->wqueue.bfd.fd < 0)
+ return false; /* No socket yet. */
+ if (conn->wqueue.bfd.cb == conn_cb)
+ return false; /* Still doing TLS handshake */
+ return true;
+ }
+
+ return conn->cli && osmo_stream_cli_is_connected(conn->cli);
+}

To view, visit change 39945. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: osmo-pcap
Gerrit-Branch: master
Gerrit-Change-Id: I091523e1d9f644e97b114b4cc524307a83dd564f
Gerrit-Change-Number: 39945
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>