When an assault is committed against the person of a custodial officer as defined in Section 831 or 831.5, and the person committing the offense knows or reasonably should know that the victim is a custodial officer engaged in the performance of his or her duties, the offense shall be punished by imprisonment in the county jail not exceeding one year or by imprisonment pursuant to subdivision (h) of Section 1170.