In this paper, we propose a formal security model to detect attacks on the Optimized Link State Routing protocol (OLSR). We make use of a combination of deontic and temporal logic to specify the correct behaviour of a node and also to express complex security properties such as obligations, roles and deadlines within specific contexts. We investigate different attacks targeting the link sensing mechanism of the protocol and describe security policies to prevent them. We argue that our approach allows to detect complex threats on OLSR.