MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sppp_ipcp_RCR

Function sppp_ipcp_RCR

freebsd/net/if_spppsubr.c:2916–3119  ·  view source on GitHub ↗

* Analyze a configure request. Return true if it was agreeable, and * caused action sca, false if it has been rejected or nak'ed, and * caused action scn. (The return value is used to make the state * transition decision in the state automaton.) */

Source from the content-addressed store, hash-verified

2914 * transition decision in the state automaton.)
2915 */
2916static int
2917sppp_ipcp_RCR(struct sppp *sp, struct lcp_header *h, int len)
2918{
2919 u_char *buf, *r, *p;
2920 struct ifnet *ifp = SP2IFP(sp);
2921 int rlen, origlen, debug = ifp->if_flags & IFF_DEBUG;
2922 u_long hisaddr, desiredaddr;
2923 int gotmyaddr = 0;
2924 int desiredcomp;
2925
2926 len -= 4;
2927 origlen = len;
2928 /*
2929 * Make sure to allocate a buf that can at least hold a
2930 * conf-nak with an `address' option. We might need it below.
2931 */
2932 buf = r = malloc ((len < 6? 6: len), M_TEMP, M_NOWAIT);
2933 if (! buf)
2934 return (0);
2935
2936 /* pass 1: see if we can recognize them */
2937 if (debug)
2938 log(LOG_DEBUG, SPP_FMT "ipcp parse opts: ",
2939 SPP_ARGS(ifp));
2940 p = (void*) (h+1);
2941 for (rlen=0; len >= 2 && p[1] >= 2 && len >= p[1];
2942 len-=p[1], p+=p[1]) {
2943 if (debug)
2944 log(-1, " %s ", sppp_ipcp_opt_name(*p));
2945 switch (*p) {
2946 case IPCP_OPT_COMPRESSION:
2947 if (!(sp->confflags & CONF_ENABLE_VJ)) {
2948 /* VJ compression administratively disabled */
2949 if (debug)
2950 log(-1, "[locally disabled] ");
2951 break;
2952 }
2953 /*
2954 * In theory, we should only conf-rej an
2955 * option that is shorter than RFC 1618
2956 * requires (i.e. < 4), and should conf-nak
2957 * anything else that is not VJ. However,
2958 * since our algorithm always uses the
2959 * original option to NAK it with new values,
2960 * things would become more complicated. In
2961 * practice, the only commonly implemented IP
2962 * compression option is VJ anyway, so the
2963 * difference is negligible.
2964 */
2965 if (len >= 6 && p[1] == 6) {
2966 /*
2967 * correctly formed compression option
2968 * that could be VJ compression
2969 */
2970 continue;
2971 }
2972 if (debug)
2973 log(-1,

Callers

nothing calls this directly

Calls 8

mallocFunction · 0.85
sppp_ipcp_opt_nameFunction · 0.85
sppp_cp_sendFunction · 0.85
sppp_get_ip_addrsFunction · 0.85
sl_compress_initFunction · 0.85
sppp_dotted_quadFunction · 0.85
logFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected