1 /*
2 * This file is part of the SSH Library
3 *
4 * Copyright (c) 2009 by Aris Adamantiadis
5 *
6 * The SSH Library is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or (at your
9 * option) any later version.
10 *
11 * The SSH Library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 * License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with the SSH Library; see the file COPYING. If not, write to
18 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
19 * MA 02111-1307, USA.
20 */
21
22 /* Simple test for the pcap functions */
23
24 #include <libssh/libssh.h>
25 #include <libssh/pcap.h>
26 #include <libssh/buffer.h>
27
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <string.h>
31
main(int argc,char ** argv)32 int main(int argc, char **argv){
33 ssh_pcap_file pcap;
34 ssh_pcap_context ctx;
35 ssh_buffer buffer=ssh_buffer_new();
36 char *str="Hello, this is a test string to test the capabilities of the"
37 "pcap file writer.";
38 printf("Simple pcap tester\n");
39 pcap=ssh_pcap_file_new();
40 if(ssh_pcap_file_open(pcap,"test.cap") != SSH_OK){
41 printf("error happened\n");
42 return EXIT_FAILURE;
43 }
44 buffer_add_data(buffer,str,strlen(str));
45 ctx=ssh_pcap_context_new(NULL);
46 ssh_pcap_context_set_file(ctx,pcap);
47 ssh_pcap_context_write(ctx,SSH_PCAP_DIR_OUT,str,strlen(str),strlen(str));
48
49 return EXIT_SUCCESS;
50 }
51