Changeset 846


Ignore:
Timestamp:
06/01/06 14:28:00 (7 years ago)
Author:
perry
Message:

Add better error handling to tools

Location:
trunk/tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/traceanon/traceanon.c

    r838 r846  
    4444/* Ok this is remarkably complicated 
    4545 * 
    46  * We want to change one, or the other IP address, while preserving the  
    47  * checksum.  TCP and UDP both include the faux header in their checksum 
    48  * calculations, so you have to update them too.  ICMP is even worse -- 
    49  * it can include the original IP packet that caused the error!  So anonymise 
    50  * that too, but remember that it's travelling in the opposite direction so 
    51  * we need to encrypt the destination and source instead of the source and 
    52  * destination! 
     46 * We want to change one, or the other IP address, while preserving 
     47 * the checksum.  TCP and UDP both include the faux header in their 
     48 * checksum calculations, so you have to update them too.  ICMP is 
     49 * even worse -- it can include the original IP packet that caused the 
     50 * error!  So anonymise that too, but remember that it's travelling in 
     51 * the opposite direction so we need to encrypt the destination and 
     52 * source instead of the source and destination! 
    5353 */ 
    5454void encrypt_ips(struct libtrace_ip *ip,bool enc_source,bool enc_dest) 
     
    8585 
    8686        if (icmp) { 
    87                 /* These are error codes that return the IP packet internally */ 
    88                 if (icmp->type == 3 || icmp->type == 5 || icmp->type == 11) { 
     87                /* These are error codes that return the IP packet 
     88                 * internally  
     89                 */ 
     90                if (icmp->type == 3  
     91                                || icmp->type == 5  
     92                                || icmp->type == 11) { 
    8993                        encrypt_ips( 
    90                                         (struct libtrace_ip*)icmp+ 
    91                                                 sizeof(struct libtrace_icmp), 
    92                                         enc_dest, 
    93                                         enc_source); 
     94                                (struct libtrace_ip*)icmp+ 
     95                                        sizeof(struct libtrace_icmp), 
     96                                enc_dest, 
     97                                enc_source); 
    9498                } 
    9599        } 
     
    162166                return 1; 
    163167        } 
    164          
    165         if (optind == argc) { 
    166                 /* no output specified, output in same format to stdout */ 
     168 
     169        if (optind +1>= argc) { 
     170                /* no output specified, output in same format to 
     171                 * stdout  
     172                 */ 
    167173                asprintf(&output,"%s:-","erf"); 
    168174                writer = trace_create_output(output); 
     
    179185        if (trace_start(trace)==-1) { 
    180186                trace_perror(trace,"trace_start"); 
     187                return 1; 
    181188        } 
    182189        if (trace_start_output(writer)==-1) { 
  • trunk/tools/tracesplit/tracesplit.c

    r838 r846  
    105105        output=NULL; 
    106106        input=trace_create(argv[optind]); 
     107        if (trace_is_err(input)) { 
     108                trace_perror(input,""); 
     109                return 1; 
     110        } 
    107111 
    108         trace_start(input); 
     112        if (trace_start(input)==-1) { 
     113                trace_perror(input,""); 
     114                return 1; 
     115        } 
    109116 
    110117        while(1) { 
  • trunk/tools/tracesplit/tracesplit_dir.c

    r838 r846  
    4141                return 1; 
    4242        } 
    43         trace_start(input); 
     43        if (trace_start(input)==-1) { 
     44                trace_perror(input,""); 
     45                return 1; 
     46        } 
    4447         
    4548        while(1) { 
     
    5154                                if (!out_write) { 
    5255                                        out_write = create_output(argv[3]); 
    53                                         if (!out_write) 
     56                                        if (trace_is_err_output(out_write)) { 
     57                                                trace_perror_output(out_write,""); 
    5458                                                return 1; 
     59                                        } 
    5560                                } 
    5661                                if (trace_write_packet(out_write, packet)==-1){ 
     
    6166                        case 1: 
    6267                                if (!in_write) { 
     68                                        in_write = create_output(argv[2]); 
     69                                        if (trace_is_err_output(in_write)) { 
     70                                                trace_perror_output(in_write,""); 
     71                                                return 1; 
     72                                        } 
    6373                                        in_write = create_output(argv[2]); 
    6474                                        if (!in_write) 
Note: See TracChangeset for help on using the changeset viewer.