[PATCH 3/6] dhcrelay: Use network byte order for the interface id value

Bjørn Mork bjorn at mork.no
Sun Sep 25 12:59:46 UTC 2011


The byte order does not matter for relay operation, but keeping
integer values in network byte order makes the output consistent
independent of the relay endianness.  I.e. configuring an
interface id of 1234 will always give the same system independent
option value.

This makes debugging easier.

Signed-off-by: Bjørn Mork <bjorn at mork.no>
---
 relay/dhcrelay.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c
index 96839cd..6e50753 100644
--- a/relay/dhcrelay.c
+++ b/relay/dhcrelay.c
@@ -1211,7 +1211,7 @@ parse_downstream(char *arg) {
 		log_fatal("No memory for downstream.");
 	dp->ifp = ifp;
 	if (iid != NULL) {
-		dp->id = atoi(iid);
+		dp->id = htonl(atoi(iid));
 	} else {
 		dp->id = -1;
 	}
@@ -1334,7 +1334,7 @@ setup_streams(void) {
 
 		/* Set interface-id. */
 		if (dp->id == -1)
-			dp->id = dp->ifp->index;
+			dp->id = htonl(dp->ifp->index);
 	}
 
 	for (up = upstreams; up; up = up->next) {
-- 
1.7.2.5




More information about the dhcp-users mailing list