mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 18:50:28 +09:00
pcap: Reformat ssh_pcap_context_write()
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Daiki Ueno <dueno@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
1be9618f4e
commit
fff2e85ab2
19
src/pcap.c
19
src/pcap.c
@@ -353,15 +353,23 @@ static int ssh_pcap_context_connect(ssh_pcap_context ctx){
|
||||
* @returns SSH_OK write is successful
|
||||
* @returns SSH_ERROR an error happened.
|
||||
*/
|
||||
int ssh_pcap_context_write(ssh_pcap_context ctx,enum ssh_pcap_direction direction
|
||||
, void *data, uint32_t len, uint32_t origlen){
|
||||
int ssh_pcap_context_write(ssh_pcap_context ctx,
|
||||
enum ssh_pcap_direction direction,
|
||||
void *data,
|
||||
uint32_t len,
|
||||
uint32_t origlen)
|
||||
{
|
||||
ssh_buffer ip;
|
||||
int rc;
|
||||
if(ctx==NULL || ctx->file ==NULL)
|
||||
|
||||
if (ctx == NULL || ctx->file == NULL) {
|
||||
return SSH_ERROR;
|
||||
if(ctx->connected==0)
|
||||
if(ssh_pcap_context_connect(ctx)==SSH_ERROR)
|
||||
}
|
||||
if (ctx->connected == 0) {
|
||||
if (ssh_pcap_context_connect(ctx) == SSH_ERROR) {
|
||||
return SSH_ERROR;
|
||||
}
|
||||
}
|
||||
ip = ssh_buffer_new();
|
||||
if (ip == NULL) {
|
||||
ssh_set_error_oom(ctx->session);
|
||||
@@ -462,6 +470,7 @@ int ssh_pcap_context_write(ssh_pcap_context ctx,enum ssh_pcap_direction directio
|
||||
goto error;
|
||||
}
|
||||
rc = ssh_pcap_file_write_packet(ctx->file, ip, origlen + TCPIPHDR_LEN);
|
||||
|
||||
error:
|
||||
ssh_buffer_free(ip);
|
||||
return rc;
|
||||
|
||||
Reference in New Issue
Block a user