Note that any metric with unique infinite geodesics on $\mathbb R^2$ has this property. 
In particular, hyperbolic plane as noted by Heather Macbeth.
It also includes Minkowski plane with smooth ball and all complete negatively curved Riemannian metrics on $\mathbb R^2$. 

So it is better to ask: 

 - Is it true that the function $p$ is the only possible? ($p(a,b,c)=0,1,$ or $2$ when the triangle inequality for a,b,c, correspondingly, fails, turns into equality, or is strict.)

 - Is it true that space has to be homeomorphic to $\mathbb R^2$?