Currently, the calls within lldpctl are assumed to be all associated with
synchronous sockets. With async sockets, the data read can be varied and so
its useful to process as much of the data as possible. However, lldpctl_recv
only processes one message and there isn't a call to be made to process
data that's sitting in a control connection's buffer. This patch adds such a
call for external users to call. It simply calls check_for_notification and
returns whatever check_for_notification returns with 0 signalling more
processing is possible and non-zero indicating buffer is fully processed
(though there may still be data).
Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
Signed-off-by: Sam Tannous <stannous@cumulusnetworks.com>
return rc;
}
-static void
+static int
check_for_notification(lldpctl_conn_t *conn)
{
struct lldpd_neighbor_change *change;
NOTIFICATION,
&p,
&MARSHAL_INFO(lldpd_neighbor_change));
- if (rc != 0) return;
+ if (rc != 0) return rc;
change = p;
/* We have a notification, call the callback */
}
free(change->ifname);
free(change);
+
+ /* Indicate if more data remains in the buffer for processing */
+ return (rc);
}
ssize_t
return conn->input_buffer_len;
}
+int lldpctl_process_conn_buffer(lldpctl_conn_t *conn)
+{
+ int rc;
+
+ rc = check_for_notification(conn);
+
+ RESET_ERROR(conn);
+
+ return rc;
+}
+
ssize_t
lldpctl_send(lldpctl_conn_t *conn)
{
*/
ssize_t lldpctl_send(lldpctl_conn_t *conn);
+/**
+ * Function invoked to see if there's more data to be processed in the buffer.
+ *
+ * This function should be invoked to check for notifications in the data that
+ * has already been read. Its used typically for asynchronous connections.
+ *
+ * @param conn Handle to the connection to lldpd.
+ * @return 0 to indicate maybe more data is available for processing
+ * !0 to indicate no data or insufficient data for processing
+ */
+int lldpctl_process_conn_buffer(lldpctl_conn_t *conn);
+
+
/**
* Allocate a new handler for connecting to lldpd.
*