These are tunnels or "galleries" that have been built behind the counterscarp wall inside the moat or ditch. Each gallery is pierced with loopholes for musketry, so that attacking forces which enter the moat can be directly fired upon. Counterscarp galleries were usually built into the angles of the ditch to give the widest field of fire. Occasionally, casemated artillery batteries were built into the counterscarp, but they were more commonly designed for infantry weapons only. The galleries were usually connected to the main body of the fort by a tunnel which passed under the ditch, or by a caponier, a gallery built across the floor of the ditch.3
Clonmel: Its Monastery, and Siege by Cromwell From Duffy's Hibernian Magazine, Vol. III, No. 14, August 1861 http://www.libraryireland.com/articles/clonmelmonastery/index.php ↩
The term "scarp" is from the same origin as a "scarp slope", the leading edge of escarpment, and in this case the escarpment is the ditch and wall of a fortress. If a defensive ditch is dug on the inner side of a wall then there can be a counterscarp on both sides of the wall. /wiki/Escarpment ↩
Pasley, Charles William, Sir (1817) A Course of Military Instruction Originally Composed for the Use of the Royal Engineers: Volume 3 John Murray, London (p.380) https://books.google.com/books?id=uyI6AQAAMAAJ&dq=counterscarp+gallery&pg=PA379 ↩