When fighting defensively and using a shield, you do not take the standard fighting defensively penalties on attacks of opportunity. When using the total defense action and a shield, you still threaten the area around you as normal. You can make attacks of opportunity with a -4 penalty.
You take a -4 penalty on all attacks while fighting defensively. You cannot attack while using the total defense action.