[dev] [sdhcp] Part 2/3 Feature request

From: Sean MacLennan <seanm_AT_seanm.ca>
Date: Mon, 12 Nov 2018 19:08:21 -0500

It would really help the world... ok, me... if the script was given the
reason it was being called. Mainly I want to know if it is a renewal.

diff --git a/sdhcp.c b/sdhcp.c
index e2a641e..b6cbfe7 100644
--- a/sdhcp.c
+++ b/sdhcp.c
_AT_@ -322,7 +339,7 @@ dhcprecv(void)
 }

 static void
-acceptlease(void)
+acceptlease(const char *reason)
 {
        char buf[128];

_AT_@ -341,6 +358,7 @@ acceptlease(void)
                setenv("ROUTER", buf, 1);
                snprintf(buf, sizeof(buf), "%d.%d.%d.%d", dns[0], dns[1], dns[2], dns[3]);
                setenv("DNS", buf, 1);
+ setenv("REASON", reason, 1);
                system(program);
        }
        alarm(t1);
_AT_@ -378,7 +396,7 @@ Requesting:
        case DHCPoffer:
                goto Requesting; /* ignore other offers. */
        case DHCPack:
- acceptlease();
+ acceptlease("BOUND");
                goto Bound;
        }
 Bound:
_AT_@ -400,7 +418,7 @@ Bound:
 Renewing:
        switch(dhcprecv()) {
        case DHCPack:
- acceptlease();
+ acceptlease("RENEW");
                goto Bound;
        case DHCPnak:
                goto Init;
_AT_@ -413,7 +431,7 @@ Rebinding:
        case DHCPnak: /* lease expired */
                goto Init;
        case DHCPack:
- acceptlease();
+ acceptlease("REBIND");
                goto Bound;
        }
 }
Received on Tue Nov 13 2018 - 01:08:21 CET

This archive was generated by hypermail 2.3.0 : Tue Nov 13 2018 - 01:12:07 CET