PX4 set flight mode

Is there any kind of authoritative developer information how to request a specific Px4 flight mode? I have checked the source-code of QGroundControl (PX4FirmwarePlugin.cc) but I cannot see the link between what is used in code, and what is described in Mavlink messages definition in Mavlink.org.

For example:
*base_mode = MAV_MODE_FLAG_CUSTOM_MODE_ENABLED;
*custom_mode = px4_mode.data;

MAV_MODE_FLAG_CUSTOM_MODE_ENABLED is defined in MAV_MODE_FLAG, but MAV_MODE_FLAG is not used neither in MAV_CMD_DO_SET_MODE nor in SET_MODE.

PX4-Autopilot/Commander.cpp at master ยท PX4/PX4-Autopilot (github.com)

Maybe you can create send_vehicle_command in here.