NULL-check before free()
Delete send_magicpkt()

It wasn't serving any purpose and defining it would apply too much abstraction in main(), enough to hide the high-level overview implementation details which are important to show in main()
Refactor code