-static char (*request_name[]) = {
- "ID", "METAKEY", "CHALLENGE", "CHAL_REPLY", "ACK",
- "STATUS", "ERROR", "TERMREQ",
- "PING", "PONG",
- "ADD_SUBNET", "DEL_SUBNET",
- "ADD_EDGE", "DEL_EDGE", "KEY_CHANGED", "REQ_KEY", "ANS_KEY", "PACKET", "CONTROL",
- "REQ_PUBKEY", "ANS_PUBKEY", "SPTPS_PACKET", "UDP_INFO", "MTU_INFO",
-};
+ // Prevent user from accessing the table directly to always have bound checks
+ static const request_entry_t request_entries[] = {
+ [ID] = {id_h, "ID"},
+ [METAKEY] = {metakey_h, "METAKEY"},
+ [CHALLENGE] = {challenge_h, "CHALLENGE"},
+ [CHAL_REPLY] = {chal_reply_h, "CHAL_REPLY"},
+ [ACK] = {ack_h, "ACK"},
+ [STATUS] = {NULL, "STATUS"},
+ [ERROR] = {NULL, "ERROR"},
+ [TERMREQ] = {termreq_h, "TERMREQ"},
+ [PING] = {ping_h, "PING"},
+ [PONG] = {pong_h, "PONG"},
+ [ADD_SUBNET] = {add_subnet_h, "ADD_SUBNET"},
+ [DEL_SUBNET] = {del_subnet_h, "DEL_SUBNET"},
+ [ADD_EDGE] = {add_edge_h, "ADD_EDGE"},
+ [DEL_EDGE] = {del_edge_h, "DEL_EDGE"},
+ [KEY_CHANGED] = {key_changed_h, "KEY_CHANGED"},
+ [REQ_KEY] = {req_key_h, "REQ_KEY"},
+ [ANS_KEY] = {ans_key_h, "ANS_KEY"},
+ [PACKET] = {tcppacket_h, "PACKET"},
+ [CONTROL] = {control_h, "CONTROL"},
+ /* Not "real" requests yet */
+ [REQ_PUBKEY] = {NULL, "REQ_PUBKEY"},
+ [ANS_PUBKEY] = {NULL, "ANS_PUBKEY"},
+ [SPTPS_PACKET] = {sptps_tcppacket_h, "SPTPS_PACKET"},
+ [UDP_INFO] = {udp_info_h, "UDP_INFO"},
+ [MTU_INFO] = {mtu_info_h, "MTU_INFO"},
+ };
+ return &request_entries[req];
+}