Changes in uspace/app/netecho/print_error.c [c6533a7:da9f13f3] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/netecho/print_error.c
rc6533a7 rda9f13f3 40 40 #include <errno.h> 41 41 42 #include <net/icmp_codes.h> 43 44 /** Prints the specific ICMP error description. 45 * 46 * @param[in] output The description output stream. May be NULL. 47 * @param[in] error_code The ICMP error code. 48 * @param[in] prefix The error description prefix. May be NULL. 49 * @param[in] suffix The error description suffix. May be NULL. 50 */ 51 void icmp_print_error(FILE *output, int error_code, const char *prefix, const char *suffix) 52 { 53 if (!output) 54 return; 55 56 if (prefix) 57 fprintf(output, "%s", prefix); 58 59 switch (error_code) { 60 case ICMP_DEST_UNREACH: 61 fprintf(output, "ICMP Destination Unreachable (%d) error", error_code); 62 break; 63 case ICMP_SOURCE_QUENCH: 64 fprintf(output, "ICMP Source Quench (%d) error", error_code); 65 break; 66 case ICMP_REDIRECT: 67 fprintf(output, "ICMP Redirect (%d) error", error_code); 68 break; 69 case ICMP_ALTERNATE_ADDR: 70 fprintf(output, "ICMP Alternate Host Address (%d) error", error_code); 71 break; 72 case ICMP_ROUTER_ADV: 73 fprintf(output, "ICMP Router Advertisement (%d) error", error_code); 74 break; 75 case ICMP_ROUTER_SOL: 76 fprintf(output, "ICMP Router Solicitation (%d) error", error_code); 77 break; 78 case ICMP_TIME_EXCEEDED: 79 fprintf(output, "ICMP Time Exceeded (%d) error", error_code); 80 break; 81 case ICMP_PARAMETERPROB: 82 fprintf(output, "ICMP Paramenter Problem (%d) error", error_code); 83 break; 84 case ICMP_CONVERSION_ERROR: 85 fprintf(output, "ICMP Datagram Conversion Error (%d) error", error_code); 86 break; 87 case ICMP_REDIRECT_MOBILE: 88 fprintf(output, "ICMP Mobile Host Redirect (%d) error", error_code); 89 break; 90 case ICMP_SKIP: 91 fprintf(output, "ICMP SKIP (%d) error", error_code); 92 break; 93 case ICMP_PHOTURIS: 94 fprintf(output, "ICMP Photuris (%d) error", error_code); 95 break; 96 default: 97 fprintf(output, "Other (%d) error", error_code); 98 } 99 100 if (suffix) 101 fprintf(output, "%s", suffix); 102 } 103 42 104 /** Prints the error description. 43 105 * 44 * Supports socket error codes.106 * Supports ICMP and socket error codes. 45 107 * 46 108 * @param[in] output The description output stream. May be NULL. … … 51 113 void print_error(FILE *output, int error_code, const char *prefix, const char *suffix) 52 114 { 53 if(IS_SOCKET_ERROR(error_code)) 115 if (IS_ICMP_ERROR(error_code)) 116 icmp_print_error(output, error_code, prefix, suffix); 117 else if(IS_SOCKET_ERROR(error_code)) 54 118 socket_print_error(output, error_code, prefix, suffix); 55 119 }
Note:
See TracChangeset
for help on using the changeset viewer.