Move the King two squares towards the Rook.
You CANNOT castle if:
1) the King or Rook has already moved (even if they later return to their starting position).
2) The King is currently in check. Earlier checks do not prevent castling.
3) The King would be castling into check.
4) The King would have to cross a square where he would be in check.
An attack on the Rook does not prevent castling.
dumb question, how do you castle?