- s->s.k = reg_off_linkhdr;
- return s;
- } else {
- /*
- * That offset isn't variable, there's no variable part,
- * so we don't need to generate any code.
- */
- return NULL;
- }
-}
-
-/*
- * Generate code to compute the previous link-layer header length, if necessary,
- * putting it into the X register, and to return either a pointer to a
- * "struct slist" for the list of statements in that code, or NULL if
- * no code is necessary.
- */
-static struct slist *
-gen_prevlinkhdrprefixlen(void)
-{
- struct slist *s;
-
- if (off_prevlinkhdr_is_variable) {
- if (reg_off_prevlinkhdr == -1) {
- /*
- * We haven't yet assigned a register for the
- * variable part of the offset of the link-layer
- * header; allocate one.
- */
- reg_off_prevlinkhdr = alloc_reg();
- }
-
- /*
- * Load the register containing the variable part of the
- * offset of the link-layer header into the X register.
- */
- s = new_stmt(BPF_LDX|BPF_MEM);
- s->s.k = reg_off_prevlinkhdr;
- return s;
- } else {
- /*
- * That offset isn't variable, there's no variable part,
- * so we don't need to generate any code.
- */
- return NULL;
- }
-}
-
-/*
- * Generate code to load the register containing the variable part of
- * the offset of the link-layer payload into the X register; if no
- * register for that offset has been allocated, allocate it first.
- * (The code to set that register will be generated later, but will
- * be placed earlier in the code sequence.)
- */
-static struct slist *
-gen_off_linkpl(void)
-{
- struct slist *s;
-
- if (off_linkpl_is_variable) {
- if (reg_off_linkpl == -1) {
- /*
- * We haven't yet assigned a register for the
- * variable part of the offset of the link-layer
- * payload; allocate one.
- */
- reg_off_linkpl = alloc_reg();
- }
-
- /*
- * Load the register containing the variable part of the
- * offset of the link-layer payload into the X register.
- */
- s = new_stmt(BPF_LDX|BPF_MEM);
- s->s.k = reg_off_linkpl;