Very grateful for your observations, due to which you have found two new interesting and non-trivial solutions of the problem. But still, the problem remains open ...
At the present time I have found the general solution of the problem under additional assumption, that the function f is differentiable in zero. The solution is in attached pdf-file. So, I am interested, whether this solution is represented in scientific literature. Because, it seems to me, that the solution of this problem must be known.
Your solution of the problem is more laconic and beautiful than what was proposed by me in a previous comment. In addition in your solution the condition about differentiability of function in zero can be weakened.