+ uint8_t *as = (uint8_t *) &ip_src;
+ uint8_t *ad = (uint8_t *) &ip;
+ uint16_t ai = ad[3];
+ ai <<= 8;
+ ai &= as[3];
+
+ s = grp_local[g].sid_loaddist[ai];
+ if (!s)
+ {
+ s = grpsession[g].smin;
+ grp_local[g].sid_loaddist[ai] = s;
+ }
+
+ if (g != grp_groupbysession(s))
+ {
+ // This session does not belong to this group
+ LOG(2, s, session[s].tunnel, "Warning, the session does not belong to group %d\n", g);
+ s = 0;
+ grp_local[g].sid_loaddist[ai] = 0;
+ }
+ else if (s == grpsession[g].smax)
+ {
+ s = grpsession[g].smin;
+ grp_local[g].sid_loaddist[ai] = s;
+ grpsession[g].smax = 0;
+ }
+ else if ( (session[s].ppp.phase > Establish) &&
+ (time_now - session[s].last_packet <= (config->echo_timeout + 1)) )
+ {
+ return s;
+ }
+ else
+ {
+ s = 0;
+ grp_local[g].sid_loaddist[ai] = 0;
+ }