Routing protocols are essentially Application Layer protocols, used by routers to exchange topology information.
Routers in turn use the topology information that they have gathered from other routers (by utilizing Routing protocols) to route Routed protocols.
OSPF does not use a TCP/IP transport protocol (UDP, TCP), but is encapsulated directly in IP datagrams with protocol number 89. OSPF could conceivably use TCP, but for reasons unbeknownst to me, OSPF's designers chose not to use TCP. Since most OSPF traffic is point-to-point over a direct link between two routers, a whole connection does not have to be established. Yet, TCP's reliable transfer feature is desirable, so OSPF doesn't use UDP or TCP.
I had similar questions when i first bumped into this. What i understood is that The OSI 7 layer concept is an aceademic and purely theoretical construct. It has never been implemented. Noone cares enough to implement it. The closer a structure came to the OSI 7-layer structure is the Internet Protocol Suite. (http://en.wikipedia.org/wiki/Internet_Protocol_Suite
The IP Suite calls L2 = Link Layer, L3 = Internet Layer, L4 = Transport Layer, L5,6,7 = Application Layer.
Still, people in networking use the OSI layers to understand at what point in a network a service/protocol operates.
You should know what each layer in the OSI model refers to, but you will never see the OSI Layer be implemented somewhere.
btw, the Protocol field in the IP datagram defines the protocol used in the data portion of the IP datagram. The Internet Assigned Numbers Authority maintains a list of IP protocol numbers which was originally defined in RFC 790. There seems to be no limit as to what kind of data can be encapsulated. Some numbers:
1 - ICMP (the ping tool uses ICMP)
4 - IP in IP (encapsulation)
8 - EGP
9 - IGP
88 - EIGRP
89 - OSPF
All these protocols are not Transport (Layer 4) protocols. So there is no limit as to what layer the encapsulated protocol has to be.
Actually even Layer 2 protocols can be encapsulated in IP datagrams:
97 - Ethernet-within-IP Encapsulation (RFC 3378)http://en.wikipedia.org/wiki/List_of_IP ... ol_numbers