From 92d2aea918f650f309f753349457028032d53280 Mon Sep 17 00:00:00 2001
From: Hans Dedecker <dedeckeh@gmail.com>
Date: Wed, 8 Apr 2015 16:20:22 +0200
Subject: netifd: Interface last error support

Adds interface last error support which preserves the last reported
error reported by the protocol handler till the interface is up;
e.g. survives network reload and interface restarts.
This is mainly usefull for tracking down why an interface fails
to establish; eg auth failure/traffic limit for PPP interfaces

Protocol handlers register last error support by setting lasterror=1
in the proto_init function

Signed-off-by: Johan Peeters <johan.peeters111@gmail.com>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
---
 proto-shell.c | 4 ++++
 1 file changed, 4 insertions(+)

(limited to 'proto-shell.c')

diff --git a/proto-shell.c b/proto-shell.c
index 977cdbc..7a1896b 100644
--- a/proto-shell.c
+++ b/proto-shell.c
@@ -819,6 +819,10 @@ proto_shell_add_handler(const char *script, const char *name, json_object *obj)
 	if (tmp && json_object_get_boolean(tmp))
 		handler->proto.flags |= PROTO_FLAG_RENEW_AVAILABLE;
 
+	tmp = json_get_field(obj, "lasterror", json_type_boolean);
+	if (tmp && json_object_get_boolean(tmp))
+		handler->proto.flags |= PROTO_FLAG_LASTERROR;
+
 	config = json_get_field(obj, "config", json_type_array);
 	if (config)
 		handler->config_buf = netifd_handler_parse_config(&handler->config, config);
-- 
cgit v1.2.3