summaryrefslogtreecommitdiffstats
path: root/libssh/pcap.c
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2009-11-16 23:20:16 +0100
committerAris Adamantiadis <aris@0xbadc0de.be>2009-11-16 23:20:16 +0100
commitae11589205291f78c4cf5e9417f69853440d5307 (patch)
tree6c06f35afa99b2c3005b97213711a8abd7982bd1 /libssh/pcap.c
parent70b947544958eb982984b4d37d584037d1801c6f (diff)
downloadlibssh-ae11589205291f78c4cf5e9417f69853440d5307.tar.gz
libssh-ae11589205291f78c4cf5e9417f69853440d5307.tar.xz
libssh-ae11589205291f78c4cf5e9417f69853440d5307.zip
Pcap: more cleanup and minimalist API
Diffstat (limited to 'libssh/pcap.c')
-rw-r--r--libssh/pcap.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/libssh/pcap.c b/libssh/pcap.c
index 2ff2e4d5..2da0087e 100644
--- a/libssh/pcap.c
+++ b/libssh/pcap.c
@@ -220,6 +220,10 @@ ssh_pcap_context ssh_pcap_context_new(ssh_session session){
return ctx;
}
+void ssh_pcap_context_free(ssh_pcap_context ctx){
+ SAFE_FREE(ctx);
+}
+
void ssh_pcap_context_set_file(ssh_pcap_context ctx, ssh_pcap_file pcap){
ctx->file=pcap;
}
@@ -355,8 +359,23 @@ int ssh_pcap_context_write(ssh_pcap_context ctx,enum ssh_pcap_direction directio
return err;
}
-void ssh_set_pcap_context(ssh_session session, ssh_pcap_context pcap){
- session->pcap_ctx=pcap;
+/** @brief sets the pcap file used to trace the session
+ * @param current session
+ * @param pcap an handler to a pcap file. A pcap file may be used in several
+ * sessions.
+ * @returns SSH_ERROR in case of error, SSH_OK otherwise.
+ */
+int ssh_set_pcap_file(ssh_session session, ssh_pcap_file pcap){
+ ssh_pcap_context ctx=ssh_pcap_context_new(session);
+ if(ctx==NULL){
+ ssh_set_error_oom(session);
+ return SSH_ERROR;
+ }
+ ctx->file=pcap;
+ if(session->pcap_ctx)
+ ssh_pcap_context_free(session->pcap_ctx);
+ session->pcap_ctx=ctx;
+ return SSH_OK;
}