Linkedlist swapping

Given a Singly linked list we need to swap the first 2 nodes with the last 2 nodes, 3rd,4th nodes with 4th-last,
3rd-last nodes and so on.
e.g.
Input :1->2->3->4->5->6
Output: 5->6->3->4->1->2
Input2:1->2->3->4->5->6->7
Output: 6->7->5->3->4->1->2

Can anyone please explain the approach along with code.