Refactor DNSMasq plugin for easier transition to the upcoming transactional changes.

Other backends to follow, this was just the smallest Backend to trial.

Change-Id: I154bdacdee3d74a0d5d32e311e0cf88f99f07f48