sec_switch.c from aries