Changeset 7715994 in mainline for uspace/srv/net/app/print_error.c


Ignore:
Timestamp:
2010-03-13T12:17:02Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6ba20a6b
Parents:
d0febca (diff), 2070570 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/app/print_error.c

    rd0febca r7715994  
    4242#include "print_error.h"
    4343
    44 void print_error( FILE * output, int error_code, const char * prefix, const char * suffix ){
    45         if( IS_ICMP_ERROR( error_code )){
    46                 icmp_print_error( output, error_code, prefix, suffix );
    47         }else if( IS_SOCKET_ERROR( error_code )){
    48                 socket_print_error( output, error_code, prefix, suffix );
    49         }
    50 }
    51 
    52 void icmp_print_error( FILE * output, int error_code, const char * prefix, const char * suffix ){
    53         if( output ){
    54                 if( prefix ){
    55                         fprintf( output, "%s", prefix );
     44void icmp_print_error(FILE * output, int error_code, const char * prefix, const char * suffix){
     45        if(output){
     46                if(prefix){
     47                        fprintf(output, "%s", prefix);
    5648                }
    57                 switch( error_code ){
     49                switch(error_code){
    5850                        case ICMP_DEST_UNREACH:
    59                                 fprintf( output, "ICMP Destination Unreachable (%d) error", error_code );
     51                                fprintf(output, "ICMP Destination Unreachable (%d) error", error_code);
    6052                                break;
    6153                        case ICMP_SOURCE_QUENCH:
    62                                 fprintf( output, "ICMP Source Quench (%d) error", error_code );
     54                                fprintf(output, "ICMP Source Quench (%d) error", error_code);
    6355                                break;
    6456                        case ICMP_REDIRECT:
    65                                 fprintf( output, "ICMP Redirect (%d) error", error_code );
     57                                fprintf(output, "ICMP Redirect (%d) error", error_code);
    6658                                break;
    6759                        case ICMP_ALTERNATE_ADDR:
    68                                 fprintf( output, "ICMP Alternate Host Address (%d) error", error_code );
     60                                fprintf(output, "ICMP Alternate Host Address (%d) error", error_code);
    6961                                break;
    7062                        case ICMP_ROUTER_ADV:
    71                                 fprintf( output, "ICMP Router Advertisement (%d) error", error_code );
     63                                fprintf(output, "ICMP Router Advertisement (%d) error", error_code);
    7264                                break;
    7365                        case ICMP_ROUTER_SOL:
    74                                 fprintf( output, "ICMP Router Solicitation (%d) error", error_code );
     66                                fprintf(output, "ICMP Router Solicitation (%d) error", error_code);
    7567                                break;
    7668                        case ICMP_TIME_EXCEEDED:
    77                                 fprintf( output, "ICMP Time Exceeded (%d) error", error_code );
     69                                fprintf(output, "ICMP Time Exceeded (%d) error", error_code);
    7870                                break;
    7971                        case ICMP_PARAMETERPROB:
    80                                 fprintf( output, "ICMP Paramenter Problem (%d) error", error_code );
     72                                fprintf(output, "ICMP Paramenter Problem (%d) error", error_code);
    8173                                break;
    8274                        case ICMP_CONVERSION_ERROR:
    83                                 fprintf( output, "ICMP Datagram Conversion Error (%d) error", error_code );
     75                                fprintf(output, "ICMP Datagram Conversion Error (%d) error", error_code);
    8476                                break;
    8577                        case ICMP_REDIRECT_MOBILE:
    86                                 fprintf( output, "ICMP Mobile Host Redirect (%d) error", error_code );
     78                                fprintf(output, "ICMP Mobile Host Redirect (%d) error", error_code);
    8779                                break;
    8880                        case ICMP_SKIP:
    89                                 fprintf( output, "ICMP SKIP (%d) error", error_code );
     81                                fprintf(output, "ICMP SKIP (%d) error", error_code);
    9082                                break;
    9183                        case ICMP_PHOTURIS:
    92                                 fprintf( output, "ICMP Photuris (%d) error", error_code );
     84                                fprintf(output, "ICMP Photuris (%d) error", error_code);
    9385                                break;
    9486                        default:
    95                                 fprintf( output, "Other (%d) error", error_code );
     87                                fprintf(output, "Other (%d) error", error_code);
    9688                }
    97                 if( suffix ){
    98                         fprintf( output, "%s", suffix );
     89                if(suffix){
     90                        fprintf(output, "%s", suffix);
    9991                }
    10092        }
    10193}
    10294
    103 void socket_print_error( FILE * output, int error_code, const char * prefix, const char * suffix ){
    104         if( output ){
    105                 if( prefix ){
    106                         fprintf( output, "%s", prefix );
     95void print_error(FILE * output, int error_code, const char * prefix, const char * suffix){
     96        if(IS_ICMP_ERROR(error_code)){
     97                icmp_print_error(output, error_code, prefix, suffix);
     98        }else if(IS_SOCKET_ERROR(error_code)){
     99                socket_print_error(output, error_code, prefix, suffix);
     100        }
     101}
     102
     103void socket_print_error(FILE * output, int error_code, const char * prefix, const char * suffix){
     104        if(output){
     105                if(prefix){
     106                        fprintf(output, "%s", prefix);
    107107                }
    108                 switch( error_code ){
     108                switch(error_code){
    109109                        case ENOTSOCK:
    110                                 fprintf( output, "Not a socket (%d) error", error_code );
     110                                fprintf(output, "Not a socket (%d) error", error_code);
    111111                                break;
    112112                        case EPROTONOSUPPORT:
    113                                 fprintf( output, "Protocol not supported (%d) error", error_code );
     113                                fprintf(output, "Protocol not supported (%d) error", error_code);
    114114                                break;
    115115                        case ESOCKTNOSUPPORT:
    116                                 fprintf( output, "Socket type not supported (%d) error", error_code );
     116                                fprintf(output, "Socket type not supported (%d) error", error_code);
    117117                                break;
    118118                        case EPFNOSUPPORT:
    119                                 fprintf( output, "Protocol family not supported (%d) error", error_code );
     119                                fprintf(output, "Protocol family not supported (%d) error", error_code);
    120120                                break;
    121121                        case EAFNOSUPPORT:
    122                                 fprintf( output, "Address family not supported (%d) error", error_code );
     122                                fprintf(output, "Address family not supported (%d) error", error_code);
    123123                                break;
    124124                        case EADDRINUSE:
    125                                 fprintf( output, "Address already in use (%d) error", error_code );
     125                                fprintf(output, "Address already in use (%d) error", error_code);
    126126                                break;
    127127                        case ENOTCONN:
    128                                 fprintf( output, "Socket not connected (%d) error", error_code );
     128                                fprintf(output, "Socket not connected (%d) error", error_code);
    129129                                break;
    130130                        case NO_DATA:
    131                                 fprintf( output, "No data (%d) error", error_code );
     131                                fprintf(output, "No data (%d) error", error_code);
    132132                                break;
    133133                        case EINPROGRESS:
    134                                 fprintf( output, "Another operation in progress (%d) error", error_code );
     134                                fprintf(output, "Another operation in progress (%d) error", error_code);
    135135                                break;
    136136                        case EDESTADDRREQ:
    137                                 fprintf( output, "Destination address required (%d) error", error_code );
     137                                fprintf(output, "Destination address required (%d) error", error_code);
    138138                        case TRY_AGAIN:
    139                                 fprintf( output, "Try again (%d) error", error_code );
     139                                fprintf(output, "Try again (%d) error", error_code);
    140140                        default:
    141                                 fprintf( output, "Other (%d) error", error_code );
     141                                fprintf(output, "Other (%d) error", error_code);
    142142                }
    143                 if( suffix ){
    144                         fprintf( output, "%s", suffix );
     143                if(suffix){
     144                        fprintf(output, "%s", suffix);
    145145                }
    146146        }
Note: See TracChangeset for help on using the changeset viewer.