The man who ambushed Baton Rouge police officers reportedly claimed that he had post-traumatic stress disorder.

>> 5 things to know about the Baton Rouge police shooting

CNN reports that Gavin Long, a Marine veteran, filled a prescription for an anti-anxiety drug as recently as last month, according to a source who asked not to be named. He also reportedly had prescriptions for two other drugs – one for anxiety and another for insomnia.

>> PHOTOS: 3 officers shot dead in Baton Rouge

Long joined the Marine Corps in 2005 as a data network specialist. He served in Iraq from June 2008 to January 2009 and was discharged at the rank of sergeant in 2010.

Three of the officers Long shot were killed.

>> What we know about Gavin Long, suspect in Baton Rouge police shooting

Officials say Long deliberately sought out officers.

“There is no doubt whatsoever that these officers were targeted and assassinated,” said Louisiana State Police Col. Michael D. Edmonson.

>> What we know about the slain Baton Rouge police officers

Long was killed by police during the shootout. He left a digital trail of his thoughts under the name “Cosmo.” In one video, he said he does not claim allegiance to any groups.

The shooting spree came after the recent police-involved killings of two black men, including one in Baton Rouge, and the slayings of five police officers in Dallas.

>> Read more trending stories

The shooter in the Dallas attack was also a former service member, raising questions about mental health care and access for veterans.