Changeset 858fc90 in mainline for uspace/srv/net/app/print_error.c
- Timestamp:
- 2010-03-15T19:35:25Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6092b56e
- Parents:
- 92307f1 (diff), 4684368 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/app/print_error.c
r92307f1 r858fc90 42 42 #include "print_error.h" 43 43 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 ); 44 void 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); 56 48 } 57 switch( error_code){49 switch(error_code){ 58 50 case ICMP_DEST_UNREACH: 59 fprintf( output, "ICMP Destination Unreachable (%d) error", error_code);51 fprintf(output, "ICMP Destination Unreachable (%d) error", error_code); 60 52 break; 61 53 case ICMP_SOURCE_QUENCH: 62 fprintf( output, "ICMP Source Quench (%d) error", error_code);54 fprintf(output, "ICMP Source Quench (%d) error", error_code); 63 55 break; 64 56 case ICMP_REDIRECT: 65 fprintf( output, "ICMP Redirect (%d) error", error_code);57 fprintf(output, "ICMP Redirect (%d) error", error_code); 66 58 break; 67 59 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); 69 61 break; 70 62 case ICMP_ROUTER_ADV: 71 fprintf( output, "ICMP Router Advertisement (%d) error", error_code);63 fprintf(output, "ICMP Router Advertisement (%d) error", error_code); 72 64 break; 73 65 case ICMP_ROUTER_SOL: 74 fprintf( output, "ICMP Router Solicitation (%d) error", error_code);66 fprintf(output, "ICMP Router Solicitation (%d) error", error_code); 75 67 break; 76 68 case ICMP_TIME_EXCEEDED: 77 fprintf( output, "ICMP Time Exceeded (%d) error", error_code);69 fprintf(output, "ICMP Time Exceeded (%d) error", error_code); 78 70 break; 79 71 case ICMP_PARAMETERPROB: 80 fprintf( output, "ICMP Paramenter Problem (%d) error", error_code);72 fprintf(output, "ICMP Paramenter Problem (%d) error", error_code); 81 73 break; 82 74 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); 84 76 break; 85 77 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); 87 79 break; 88 80 case ICMP_SKIP: 89 fprintf( output, "ICMP SKIP (%d) error", error_code);81 fprintf(output, "ICMP SKIP (%d) error", error_code); 90 82 break; 91 83 case ICMP_PHOTURIS: 92 fprintf( output, "ICMP Photuris (%d) error", error_code);84 fprintf(output, "ICMP Photuris (%d) error", error_code); 93 85 break; 94 86 default: 95 fprintf( output, "Other (%d) error", error_code);87 fprintf(output, "Other (%d) error", error_code); 96 88 } 97 if( suffix){98 fprintf( output, "%s", suffix);89 if(suffix){ 90 fprintf(output, "%s", suffix); 99 91 } 100 92 } 101 93 } 102 94 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 ); 95 void 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 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); 107 107 } 108 switch( error_code){108 switch(error_code){ 109 109 case ENOTSOCK: 110 fprintf( output, "Not a socket (%d) error", error_code);110 fprintf(output, "Not a socket (%d) error", error_code); 111 111 break; 112 112 case EPROTONOSUPPORT: 113 fprintf( output, "Protocol not supported (%d) error", error_code);113 fprintf(output, "Protocol not supported (%d) error", error_code); 114 114 break; 115 115 case ESOCKTNOSUPPORT: 116 fprintf( output, "Socket type not supported (%d) error", error_code);116 fprintf(output, "Socket type not supported (%d) error", error_code); 117 117 break; 118 118 case EPFNOSUPPORT: 119 fprintf( output, "Protocol family not supported (%d) error", error_code);119 fprintf(output, "Protocol family not supported (%d) error", error_code); 120 120 break; 121 121 case EAFNOSUPPORT: 122 fprintf( output, "Address family not supported (%d) error", error_code);122 fprintf(output, "Address family not supported (%d) error", error_code); 123 123 break; 124 124 case EADDRINUSE: 125 fprintf( output, "Address already in use (%d) error", error_code);125 fprintf(output, "Address already in use (%d) error", error_code); 126 126 break; 127 127 case ENOTCONN: 128 fprintf( output, "Socket not connected (%d) error", error_code);128 fprintf(output, "Socket not connected (%d) error", error_code); 129 129 break; 130 130 case NO_DATA: 131 fprintf( output, "No data (%d) error", error_code);131 fprintf(output, "No data (%d) error", error_code); 132 132 break; 133 133 case EINPROGRESS: 134 fprintf( output, "Another operation in progress (%d) error", error_code);134 fprintf(output, "Another operation in progress (%d) error", error_code); 135 135 break; 136 136 case EDESTADDRREQ: 137 fprintf( output, "Destination address required (%d) error", error_code);137 fprintf(output, "Destination address required (%d) error", error_code); 138 138 case TRY_AGAIN: 139 fprintf( output, "Try again (%d) error", error_code);139 fprintf(output, "Try again (%d) error", error_code); 140 140 default: 141 fprintf( output, "Other (%d) error", error_code);141 fprintf(output, "Other (%d) error", error_code); 142 142 } 143 if( suffix){144 fprintf( output, "%s", suffix);143 if(suffix){ 144 fprintf(output, "%s", suffix); 145 145 } 146 146 }
Note:
See TracChangeset
for help on using the changeset viewer.