Four French soldiers have been killed in northern Afghanistan after a serviceman from the Afghan National Army opened fire, officials say.