The officer was undertaking "routine duties" when he was fired at by "a member of the public", police say.