You won't be able to find an algorithm that is created just for this specific problem. What you are looking is a search algorithm, for example BFS and modify it to use in this game.
In BFS, you start with a cell and add valid neighbor cells into a queue and iterate through this queue until you reach to destination or queue is empty (you didn't reach the destination).
For this game, first you have to define which neighbors are valid. There are 7 types of cells
empty cells : never valid
destination : always valid, end algorithm here
source: never valid, you don't want to move source square back
vertical tunnel: only valid if previous cell is also a vertical tunnel or one of modem, router, source
horizontal tunnel: only valid if previous cell is also a horizontal tunnel or one of modem, router, source
modem and router cells will be a little trickier, while iterating through queue, you also need to push type of current path. Current path will be initially "source", if you pass through a modem it will be "modem" and if you pass through router it will be "router". With this in mind, rules for router and modem are
modem: only valid if current path is source or modem
router: only valid if current path is modem or router