Changes in uspace/srv/net/app/print_error.c [b648ae4:aadf01e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/app/print_error.c
rb648ae4 raadf01e 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);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 49 } 50 50 } 51 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);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); 56 56 } 57 switch( error_code){57 switch(error_code){ 58 58 case ICMP_DEST_UNREACH: 59 fprintf( output, "ICMP Destination Unreachable (%d) error", error_code);59 fprintf(output, "ICMP Destination Unreachable (%d) error", error_code); 60 60 break; 61 61 case ICMP_SOURCE_QUENCH: 62 fprintf( output, "ICMP Source Quench (%d) error", error_code);62 fprintf(output, "ICMP Source Quench (%d) error", error_code); 63 63 break; 64 64 case ICMP_REDIRECT: 65 fprintf( output, "ICMP Redirect (%d) error", error_code);65 fprintf(output, "ICMP Redirect (%d) error", error_code); 66 66 break; 67 67 case ICMP_ALTERNATE_ADDR: 68 fprintf( output, "ICMP Alternate Host Address (%d) error", error_code);68 fprintf(output, "ICMP Alternate Host Address (%d) error", error_code); 69 69 break; 70 70 case ICMP_ROUTER_ADV: 71 fprintf( output, "ICMP Router Advertisement (%d) error", error_code);71 fprintf(output, "ICMP Router Advertisement (%d) error", error_code); 72 72 break; 73 73 case ICMP_ROUTER_SOL: 74 fprintf( output, "ICMP Router Solicitation (%d) error", error_code);74 fprintf(output, "ICMP Router Solicitation (%d) error", error_code); 75 75 break; 76 76 case ICMP_TIME_EXCEEDED: 77 fprintf( output, "ICMP Time Exceeded (%d) error", error_code);77 fprintf(output, "ICMP Time Exceeded (%d) error", error_code); 78 78 break; 79 79 case ICMP_PARAMETERPROB: 80 fprintf( output, "ICMP Paramenter Problem (%d) error", error_code);80 fprintf(output, "ICMP Paramenter Problem (%d) error", error_code); 81 81 break; 82 82 case ICMP_CONVERSION_ERROR: 83 fprintf( output, "ICMP Datagram Conversion Error (%d) error", error_code);83 fprintf(output, "ICMP Datagram Conversion Error (%d) error", error_code); 84 84 break; 85 85 case ICMP_REDIRECT_MOBILE: 86 fprintf( output, "ICMP Mobile Host Redirect (%d) error", error_code);86 fprintf(output, "ICMP Mobile Host Redirect (%d) error", error_code); 87 87 break; 88 88 case ICMP_SKIP: 89 fprintf( output, "ICMP SKIP (%d) error", error_code);89 fprintf(output, "ICMP SKIP (%d) error", error_code); 90 90 break; 91 91 case ICMP_PHOTURIS: 92 fprintf( output, "ICMP Photuris (%d) error", error_code);92 fprintf(output, "ICMP Photuris (%d) error", error_code); 93 93 break; 94 94 default: 95 fprintf( output, "Other (%d) error", error_code);95 fprintf(output, "Other (%d) error", error_code); 96 96 } 97 if( suffix){98 fprintf( output, "%s", suffix);97 if(suffix){ 98 fprintf(output, "%s", suffix); 99 99 } 100 100 } 101 101 } 102 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);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.