+static void ppp_code_rej(sessionidt s, tunnelidt t, uint16_t proto,
+ char *pname, uint8_t *p, uint16_t l, uint8_t *buf, size_t size)
+{
+ uint8_t *q;
+ int mru = session[s].mru;
+
+ if (!mru) mru = MAXMRU;
+ if (mru > size) mru = size;
+
+ l += 4;
+ if (l > mru) l = mru;
+
+ q = makeppp(buf, size, 0, 0, s, t, proto);
+ if (!q) return;
+
+ *q = CodeRej;
+ *(q + 1) = ++sess_local[s].lcp_ident;
+ *(uint16_t *)(q + 2) = l;
+ memcpy(q + 4, p, l - 4);
+
+ LOG(2, s, t, "Unexpected %s code %s\n", pname, ppp_code(*p));
+ LOG(3, s, t, "%s: send %s\n", pname, ppp_code(*q));
+ if (config->debug > 3) dumplcp(q, l);
+
+ tunnelsend(buf, l + (q - buf), t);
+}
+