Radar more or less detects a bogey, its more via transponder an IFF (Identify Friend of Foe) mechanism the bogey is classified as hostile or friendly. Some more on transponder https://en.wikipedia.org/wiki/Transponder_(aeronautics)