+ switch (state & NM_MAIN_MASK) {
+ case NM_MAIN_ON:
+ /* We're not alone, so let's transition to ON for now.
+ */
+ nm->nodes[nm->my_id].state = NM_MAIN_ON;
+
+ /* The AWOL timeout is ONLY reset on
+ * NM_MAIN_ON messages.
+ */
+ nm_set_timer_awol(nm);
+
+ 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_set_timer_now(nm);
+
+ /* IMPORTANT: The caller needs to check for
+ * timeouts first, i.e. 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) */
+
+ /* 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.
+ */
+
+ /* Nothing to do. */
+ } else if (next == nm->my_id) {
+ /* It's our turn, do a normal timeout.
+ * This is a period in which anyone we missed
+ * can send its re-login frame to correct us.
+ */
+
+ nm_set_timer_normal(nm);
+ } else {
+ /* We just received a random ON message. */
+
+ /* Nothing to do. */
+ }
+ break;
+ case NM_MAIN_LOGIN:
+ /* Note: sender != nm->my_id */