dhcpd.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. --- relay/dhcrelay.c-orig Sat Apr 27 05:34:20 2002
  2. +++ relay/dhcrelay.c Wed Feb 19 12:44:19 2003
  3. @@ -88,6 +88,7 @@
  4. did not match any known circuit ID. */
  5. int missing_circuit_id = 0; /* Circuit ID option in matching RAI option
  6. was missing. */
  7. +int max_hop_count = 4; /* Maximum hop count */
  8. /* Maximum size of a packet with agent options added. */
  9. int dhcp_max_agent_option_packet_length = 576;
  10. @@ -182,6 +183,15 @@
  11. quiet_interface_discovery = 1;
  12. } else if (!strcmp (argv [i], "-a")) {
  13. add_agent_options = 1;
  14. + } else if (!strcmp (argv [i], "-c")) {
  15. + int hcount;
  16. + if (++i == argc)
  17. + usage ();
  18. + hcount = atoi(argv[i]);
  19. + if (hcount <= 16)
  20. + max_hop_count = hcount;
  21. + else
  22. + usage ();
  23. } else if (!strcmp (argv [i], "-A")) {
  24. if (++i == argc)
  25. usage ();
  26. @@ -425,6 +435,17 @@
  27. packet -> giaddr = ip -> primary_address;
  28. if (packet -> hops != 255)
  29. packet -> hops = packet -> hops + 1;
  30. +
  31. + /* ftp://ftp.rfc-editor.org/in-notes/rfc1542.txt
  32. + * 4.1.1 BOOTREQUEST Messages
  33. + * The relay agent MUST silently discard BOOTREQUEST messages whose
  34. + * 'hops' field exceeds the value 16. A configuration option SHOULD be
  35. + * provided to set this threshold to a smaller value if desired by the
  36. + * network manager. The default setting for a configurable threshold
  37. + * SHOULD be 4.
  38. + */
  39. + if (packet -> hops >= max_hop_count)
  40. + return;
  41. /* Otherwise, it's a BOOTREQUEST, so forward it to all the
  42. servers. */
  43. @@ -470,7 +470,7 @@
  44. static void usage ()
  45. {
  46. log_fatal ("Usage: dhcrelay [-p <port>] [-d] [-D] [-i %s%s%s",
  47. - "interface]\n ",
  48. + "interface] [-c max_hop_count]\n ",
  49. "[-q] [-a] [-A length] [-m append|replace|forward|discard]\n",
  50. " [server1 [... serverN]]");
  51. }