+ bundleidt bid = 0;
+ if (session[s].bundle && bundle[session[s].bundle].num_of_links > 1)
+ {
+ bid = session[s].bundle;
+ s = bundle[bid].members[bundle[bid].current_ses = ++bundle[bid].current_ses % bundle[bid].num_of_links];
+ LOG(4, s, t, "MPPP: (1)Session number becomes: %u\n", s);
+ if (len > 256)
+ {
+ // Partition the packet to 2 fragments
+ uint32_t frag1len = len / 2;
+ uint32_t frag2len = len - frag1len;
+ uint8_t *p = makeppp(b1, sizeof(b1), buf, frag1len, s, t, PPPIP, 0, bid, MP_BEGIN);
+ uint8_t *q;
+
+ if (!p) return;
+ tunnelsend(b1, frag1len + (p-b1), t); // send it...
+ s = bundle[bid].members[bundle[bid].current_ses = ++bundle[bid].current_ses % bundle[bid].num_of_links];
+ LOG(4, s, t, "MPPP: (2)Session number becomes: %u\n", s);
+ q = makeppp(b2, sizeof(b2), buf+frag1len, frag2len, s, t, PPPIP, 0, bid, MP_END);
+ if (!q) return;
+ tunnelsend(b2, frag2len + (q-b2), t); // send it...
+ }
+ else {
+ // Send it as one frame
+ uint8_t *p = makeppp(b1, sizeof(b1), buf, len, s, t, PPPIP, 0, bid, MP_BOTH_BITS);
+ if (!p) return;
+ tunnelsend(b1, len + (p-b1), t); // send it...
+ }
+ }
+ else
+ {
+ uint8_t *p = makeppp(b1, sizeof(b1), buf, len, s, t, PPPIP, 0, 0, 0);
+ if (!p) return;
+ tunnelsend(b1, len + (p-b1), t); // send it...
+ }