rewrite protocol check with switch-case in daemon