1. This code is heavily based on, even stolen from Dug Song's excellent fragroute
  2. utility. I've taken a perfectly good application and converted it into a
  3. packet editing library for my own needs. Any bugs are my fault. Any praises
  4. really should go to Dug.
  5. Please consider all files here under the original fragroute LICENSE, with the
  6. added caveat that any changes are:
  7. Copyright 2008-2010, Aaron Turner
  8. Copyright 2013, Fred Klassen - AppNeta
  9. Notes:
  10. Fragroute runs as a daemon which intercepts packets by modifying the host
  11. operating systems routing table, redirecting packets destined to the target
  12. IP over the loopback interface. Packets reaching the loopback interface
  13. are then read using libpcap/BPF filter processed according to the fragroute
  14. rule set and then resent out the configured interface.
  15. libfragroute works differently. First, we do away with any changes to the
  16. host routing table. Secondly, packets are not sent out any interface, but
  17. are read back by the caller. The API should look something like this:
  18. ctx = fragroute_init(mtu, <rules>); // init library
  19. // process a packet
  20. fragroute_process(ctx, char *pktbuff, int pktsize)
  21. // read resulting fragments
  22. while ((ret = fragroute_read(ctx, char **fragment)) > 0) {
  23. // do something with fragment
  24. } else {
  25. // no more fragments
  26. }