- switch (ctrl_msg_type) {
- case PPTP_CTRL_MSG_TYPE_SCCRP:
- switch (*result_code) {
- case 1:
- ND_PRINT((ndo, ":Successful channel establishment"));
- break;
- case 2:
- ND_PRINT((ndo, ":General error"));
- break;
- case 3:
- ND_PRINT((ndo, ":Command channel already exists"));
- break;
- case 4:
- ND_PRINT((ndo, ":Requester is not authorized to establish a command channel"));
- break;
- case 5:
- ND_PRINT((ndo, ":The protocol version of the requester is not supported"));
- break;
- default:
- ND_PRINT((ndo, ":?"));
- break;
- }
- break;
- case PPTP_CTRL_MSG_TYPE_StopCCRP:
- case PPTP_CTRL_MSG_TYPE_ECHORP:
- switch (*result_code) {
- case 1:
- ND_PRINT((ndo, ":OK"));
- break;
- case 2:
- ND_PRINT((ndo, ":General Error"));
- break;
- default:
- ND_PRINT((ndo, ":?"));
- break;
- }
- break;
- case PPTP_CTRL_MSG_TYPE_OCRP:
- switch (*result_code) {
- case 1:
- ND_PRINT((ndo, ":Connected"));
- break;
- case 2:
- ND_PRINT((ndo, ":General Error"));
- break;
- case 3:
- ND_PRINT((ndo, ":No Carrier"));
- break;
- case 4:
- ND_PRINT((ndo, ":Busy"));
- break;
- case 5:
- ND_PRINT((ndo, ":No Dial Tone"));
- break;
- case 6:
- ND_PRINT((ndo, ":Time-out"));
- break;
- case 7:
- ND_PRINT((ndo, ":Do Not Accept"));
- break;
- default:
- ND_PRINT((ndo, ":?"));
- break;
- }
- break;
- case PPTP_CTRL_MSG_TYPE_ICRP:
- switch (*result_code) {
- case 1:
- ND_PRINT((ndo, ":Connect"));
- break;
- case 2:
- ND_PRINT((ndo, ":General Error"));
- break;
- case 3:
- ND_PRINT((ndo, ":Do Not Accept"));
- break;
- default:
- ND_PRINT((ndo, ":?"));
- break;
- }
- break;
- case PPTP_CTRL_MSG_TYPE_CDN:
- switch (*result_code) {
- case 1:
- ND_PRINT((ndo, ":Lost Carrier"));
- break;
- case 2:
- ND_PRINT((ndo, ":General Error"));
- break;
- case 3:
- ND_PRINT((ndo, ":Admin Shutdown"));
- break;
- case 4:
- ND_PRINT((ndo, ":Request"));
- break;
- default:
- ND_PRINT((ndo, ":?"));
- break;
- }
- break;
- default:
- /* assertion error */
- break;
- }
+ const struct tok *dict =
+ ctrl_msg_type == PPTP_CTRL_MSG_TYPE_SCCRP ? pptp_scrrp_str :
+ ctrl_msg_type == PPTP_CTRL_MSG_TYPE_StopCCRP ? pptp_echorp_str :
+ ctrl_msg_type == PPTP_CTRL_MSG_TYPE_ECHORP ? pptp_echorp_str :
+ ctrl_msg_type == PPTP_CTRL_MSG_TYPE_OCRP ? pptp_ocrp_str :
+ ctrl_msg_type == PPTP_CTRL_MSG_TYPE_ICRP ? pptp_icrp_str :
+ ctrl_msg_type == PPTP_CTRL_MSG_TYPE_CDN ? pptp_cdn_str :
+ NULL; /* assertion error */
+ if (dict != NULL)
+ ND_PRINT((ndo, ":%s", tok2str(dict, "?", *result_code)));