Changeset 735


Ignore:
Timestamp:
04/24/06 18:42:43 (7 years ago)
Author:
perry
Message:

Clean up the various usages of TRACE_ERR_*, add TRACE_ERR_UNSUPPORTED and
shuffle which error was returned where. Document their new usages.

Closes: #13

Also, fix the 802.1q definitions.

Location:
trunk/lib
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/format_erf.c

    r734 r735  
    744744                type=libtrace_to_erf_type(trace_get_link_type(packet)); 
    745745                if (type==(char)-1) { 
    746                         trace_set_err_out(libtrace,TRACE_ERR_BAD_PACKET, 
     746                        trace_set_err_out(libtrace,TRACE_ERR_NO_CONVERSION, 
    747747                                        "No erf type for packet"); 
    748748                        return -1; 
  • trunk/lib/format_pcap.c

    r729 r735  
    175175        return 0; 
    176176#else 
    177         trace_set_err_out(libtrace,TRACE_ERR_NO_INIT_OUT, 
     177        trace_set_err_out(libtrace,TRACE_ERR_UNSUPPORTED, 
    178178                        "writing not supported by this version of pcap"); 
    179179        return -1; 
  • trunk/lib/format_pcapfile.c

    r722 r735  
    102102                 
    103103                if (swapl(libtrace,DATA(libtrace)->header.magic_number) != 0xa1b2c3d4) { 
    104                         trace_set_err(libtrace,TRACE_ERR_BAD_PACKET,"Not a pcap tracefile\n"); 
     104                        trace_set_err(libtrace,TRACE_ERR_INIT_FAILED,"Not a pcap tracefile\n"); 
    105105                        return -1; /* Not a pcap file */ 
    106106                } 
     
    108108                if (swaps(libtrace,DATA(libtrace)->header.version_major)!=2 
    109109                        && swaps(libtrace,DATA(libtrace)->header.version_minor)!=4) { 
    110                         trace_set_err(libtrace,TRACE_ERR_BAD_PACKET,"Unknown pcap tracefile version %d.%d\n", 
     110                        trace_set_err(libtrace,TRACE_ERR_INIT_FAILED,"Unknown pcap tracefile version %d.%d\n", 
    111111                                        swaps(libtrace, 
    112112                                                DATA(libtrace)->header.version_major), 
  • trunk/lib/format_rt.c

    r712 r735  
    324324                                 
    325325                                perror("recv"); 
    326                                 trace_set_err(libtrace, TRACE_ERR_RECV_FAILED, 
     326                                trace_set_err(libtrace, errno, 
    327327                                                "Failed to read data into rt recv buffer"); 
    328328                                return -1; 
  • trunk/lib/libtrace.h

    r730 r735  
    167167/** Enumeration of error codes */ 
    168168enum { 
     169        /** No Error has occured.... yet. */ 
    169170        TRACE_ERR_NOERROR       = 0, 
     171        /** The URI passed to trace_create() is unsupported, or badly formed */ 
    170172        TRACE_ERR_BAD_FORMAT    = -1, 
    171         TRACE_ERR_NO_INIT       = -2, 
    172         TRACE_ERR_NO_INIT_OUT   = -3, 
    173         TRACE_ERR_URI_LONG      = -4, 
    174         TRACE_ERR_URI_NOCOLON   = -5, 
    175         TRACE_ERR_INIT_FAILED   = -6, 
    176         TRACE_ERR_UNKNOWN_OPTION= -7, 
    177         TRACE_ERR_NO_CONVERSION = -8, 
    178         TRACE_ERR_BAD_PACKET    = -9, 
    179         TRACE_ERR_OPTION_UNAVAIL= -10, 
    180         TRACE_ERR_RECV_FAILED   = -11 
     173        /** The trace failed to initialise */ 
     174        TRACE_ERR_INIT_FAILED   = -2, 
     175        /** Unknown config option */ 
     176        TRACE_ERR_UNKNOWN_OPTION= -3, 
     177        /** Option known, but unsupported by this format */ 
     178        TRACE_ERR_OPTION_UNAVAIL= -6, 
     179        /** This output uri cannot write packets of this type */ 
     180        TRACE_ERR_NO_CONVERSION = -4, 
     181        /** This packet is corrupt, or unusable for the action required */  
     182        TRACE_ERR_BAD_PACKET    = -5, 
     183        /** This feature is unsupported */ 
     184        TRACE_ERR_UNSUPPORTED   = -7 
    181185}; 
    182186 
     
    342346typedef struct libtrace_8021q  
    343347{ 
    344   uint8_t  ether_dhost[6];      /**< destination eth addr */ 
    345   uint8_t  ether_shost[6];      /**< source ether addr    */ 
    346   uint16_t ether_type;          /**< packet type ID field , 0x8100 for VLAN */ 
    347348  unsigned int vlan_pri:3;       /**< vlan user priority */ 
    348349  unsigned int vlan_cfi:1;       /**< vlan format indicator,  
  • trunk/lib/trace.c

    r729 r735  
    343343                } 
    344344        } else { 
    345                 trace_set_err(libtrace,TRACE_ERR_NO_INIT, 
     345                trace_set_err(libtrace,TRACE_ERR_UNSUPPORTED, 
    346346                                "Format does not support input (%s)",scan); 
    347347                return libtrace; 
     
    471471                } 
    472472        } else { 
    473                 trace_set_err_out(libtrace,TRACE_ERR_NO_INIT_OUT, 
     473                trace_set_err_out(libtrace,TRACE_ERR_UNSUPPORTED, 
    474474                                "Format does not support writing (%s)",scan); 
    475475                return libtrace; 
     
    682682                } while(1); 
    683683        } 
    684         trace_set_err(libtrace,TRACE_ERR_BAD_FORMAT,"This format does not support reading packets\n"); 
     684        trace_set_err(libtrace,TRACE_ERR_UNSUPPORTED,"This format does not support reading packets\n"); 
    685685        packet->size=-1; 
    686686        return -1; 
Note: See TracChangeset for help on using the changeset viewer.