--- embedaddon/mtr/ui/display.c 2019/10/21 14:25:31 1.1.1.1 +++ embedaddon/mtr/ui/display.c 2021/03/17 00:07:30 1.1.1.2 @@ -11,15 +11,17 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "config.h" +#include #include #include +#include #include #include @@ -79,9 +81,11 @@ void display_open( case DisplayTXT: txt_open(); break; +#ifdef HAVE_JANSSON case DisplayJSON: json_open(); break; +#endif case DisplayXML: xml_open(); break; @@ -125,9 +129,11 @@ void display_close( case DisplayTXT: txt_close(ctl); break; +#ifdef HAVE_JANSSON case DisplayJSON: json_close(ctl); break; +#endif case DisplayXML: xml_close(ctl); break; @@ -223,10 +229,11 @@ void display_rawping( void display_rawhost( struct mtr_ctl *ctl, int host, - ip_t * ip_addr) + ip_t * ip_addr, + struct mplslen *mpls) { if (ctl->DisplayMode == DisplayRaw) - raw_rawhost(ctl, host, ip_addr); + raw_rawhost(ctl, host, ip_addr, mpls); } @@ -249,4 +256,27 @@ void display_clear( if (ctl->DisplayMode == DisplayCurses) mtr_curses_clear(ctl); #endif +} + + +/* + Given an errno error code corresponding to a host entry, return a + user readable error string. +*/ +char *host_error_to_string( + int err) +{ + if (err == ENETUNREACH) { + return "no route to host"; + } + + if (err == ENETDOWN) { + return "network down"; + } + + if (err == 0) { + return "waiting for reply"; + } + + return strerror(err); }