+static void
+clear_interface_errors(struct interface *iface)
+{
+ struct interface_error *error, *tmp;
+
+ list_for_each_entry_safe(error, tmp, &iface->errors, list) {
+ list_del(&error->list);
+ free(error);
+ }
+}
+
+void interface_add_error(struct interface *iface, const char *subsystem,
+ const char *code, const char **data, int n_data)
+{
+ struct interface_error *error;
+ int i, len = 0;
+ int *datalen;
+ char *dest;
+
+ if (n_data) {
+ len = n_data * sizeof(char *);
+ datalen = alloca(len);
+ for (i = 0; i < n_data; i++) {
+ datalen[i] = strlen(data[i]) + 1;
+ len += datalen[i];
+ }
+ }
+
+ error = calloc(1, sizeof(*error) + sizeof(char *) + len);
+ if (!error)
+ return;
+
+ list_add_tail(&error->list, &iface->errors);
+ error->subsystem = subsystem;
+ error->code = code;
+
+ dest = (char *) &error->data[n_data + 1];
+ for (i = 0; i < n_data; i++) {
+ error->data[i] = dest;
+ memcpy(dest, data[i], datalen[i]);
+ dest += datalen[i];
+ }
+ error->data[n_data] = NULL;
+}
+
+static int
+interface_event(struct interface *iface, enum interface_event ev)