Is it legal to lay off a worker on maternity leave?

I have been on maternity leave for about a year. Two weeks before my scheduled return to work, I was informed that, because of some restructuring within the organization, my role is changing and that I have the option to return or take a severance package.
The details of the package were e-mailed to me and the package will be equivalent to around four months of my salary (which I think is generous considering I only joined the company in May, 2011). In terms of the changes to the job should I choose to return, I will require more “technical” skills, but the rest of the requirements are pretty much the same.
Is this legal?