Skip to content

Commit

Permalink
Allow virtual attrs in switch. Fixes #1240
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed Sep 16, 2015
1 parent c83c3ae commit cb99c01
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/modcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -3927,6 +3927,14 @@ bool modcall_pass2(modcallable *mc)
goto do_children;
}

/*
* Convert virtual &Attr-Foo to "%{Attr-Foo}"
*/
if ((g->vpt->type == TMPL_TYPE_ATTR) && g->vpt->tmpl_da->flags.virtual) {
g->vpt->tmpl_xlat = xlat_from_tmpl_attr(g->vpt, g->vpt);
g->vpt->type = TMPL_TYPE_XLAT_STRUCT;
}

/*
* We may have: switch Foo-Bar {
*
Expand Down
23 changes: 23 additions & 0 deletions src/tests/keywords/switch-virtual
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# PRE: update switch
#
update control {
Cleartext-Password := 'hello'
}

#
# Virtual attribute references get mashed to xlats
#
switch &Packet-Type {
case Access-Request {
update reply {
Filter-Id := "filter"
}
}

case {
update reply {
Filter-Id := "fail"
}
}
}

1 comment on commit cb99c01

@jpereira
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @alandekok

Please sign in to comment.