+ if (next == nm->nodes[nm->my_id].next
+ && nm->nodes[nm->my_id].next != nm->my_id) {
+ /* sender doesn't know we exist */
+
+ nm->nodes[nm->my_id].state = NM_MAIN_LOGIN;
+
+ nm->tv.tv_sec = 0;
+ nm->tv.tv_usec = 0;
+ /* IMPORTANT: The caller needs to check for
+ * timeouts first, so no other NM frames are
+ * received until our correcting login has
+ * been sent.
+ */
+ } else if (next == nm->nodes[nm->my_id].next) {
+ /* where nm->nodes[nm->my_id].next == nm->my_id */
+
+ /* TODO: Is this a case we need to handle? */
+
+ /* It can happen when:
+ * - our sent frames don't go anywhere
+ * - we just logged in and immediately
+ * afterwards another ECU sent a regular
+ * NM frame without knowing that we exist.
+ */
+ } else if (next == nm->my_id) {
+ /* It's our turn.
+ * Reset the timeout so anyone we missed
+ * can send its login frame to correct us.
+ */
+ nm->tv.tv_sec = 0;
+ nm->tv.tv_usec = NM_USECS_MY_TURN;
+ } else {
+ /* We just got some random ON message.
+ * Reset the timer looking out for broken
+ * connectivity.
+ */
+ nm->tv.tv_sec = 0;
+ nm->tv.tv_usec = NM_USECS_OTHER_TURN;