Some of the defensive tactics,
1] Anti-Elephant Spikes
The giants were used to fall apart the massive doors of forts, so they developed doors with spikes, popularly, Anti-Elephant Spikes, to protect against direct threat from elephants.
( Camel cushion : To avoid the loss of elephants to the elephant spikes, people in those times use to make a camel stand parallel to the door and the elephant was forced to ram the camel eventually breaking the door and in process killing the camel. Camels were much cheaper than elephants so they could afford the loss of a camel) (From comments)
2] Veil of the Gate
One of the gate of fortified city Jodhpur, Merti Gate, used to have an additional wall in front of gate to prevent elephants to fall apart the gate, as well as reduce the running distance for wooden logs used manually on gates.
3] Rims of Boiling Oil
See those small places over the passage, known as Rims of boiling oils, used by the guards as the standing point. ( Devgiri Fort, Daulatabad.)
Similar structures are found in almost every fort, like in Jaisalmer Fort, they had large boulder along with boiling water to be put on enemy trapped between the two ring of ramparts.
4] A dark Passage
Those who cross the fortification has to pass through a pitch dark zig-zag cave passage known as Andhari, carved through the rock. It is connected to several caves inside , which lead back to the moat. The army hiding inside the dark enclosure used to kill the stuck enemy soldiers using spears.
The opening gate of this passage was covered by a heavy iron lid, which could be closed just by rolling, and poisonous gases could be ejected into trap.
5]Narrow passages with sharp angular turns
Most of the forts used to have sharp angular turns in paths, slowing down the enemy advancement.
(Mehrangarh Fort)