Ignore:
Timestamp:
06/01/06 14:28:00 (15 years ago)
Author:
Perry Lorier <perry@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
3b49843
Parents:
e49ec63
Message:

Add better error handling to tools

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/traceanon/traceanon.c

    r853603a rfc0f131  
    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) {
Note: See TracChangeset for help on using the changeset viewer.