saravana815 / dhtest

A DHCP client simulation on linux. It can simulates multiple DHCP clients behind a network device. It can help in testing the DHCP servers or in testing switch/router by loading the device with multiple DHCP clients.
GNU General Public License v2.0
294 stars 102 forks source link

Incorrect Next Server IP data in case of JSON format #41

Open vitalii-kondratiuk opened 1 month ago

vitalii-kondratiuk commented 1 month ago

The Next Server IP address in OFFER & ACK is displayed correctly only for the basic output format, in the case of using -j json option it refers to incorrect data.


Basic output mode, CORRECT: image JSON output mode, INCORRECT: image

Here is the tcpdump capture: image

vitalii-kondratiuk commented 1 month ago

The possible solution in DHCP_MSGOFFER

            fprintf(stdout, "{\"msg\":\"DHCP offer details\","
                "\"result\":\"info\","
                "\"result-type\":\"offer\","
                "\"result-ip\":\"%s\",",
                get_ip_str(dhcph_g->dhcp_yip));
            fprintf(stdout, "\"result-next-srv\":\"%s\"",
                get_ip_str(dhcph_g->dhcp_sip));

For the DHCP_MSGACK

                        fprintf(stdout, "{\"msg\":\"DHCP ack details\","
                                "\"result\":\"info\","
                                "\"result-type\":\"offer\","
                                "\"result-ip\":\"%s\",",
                                get_ip_str(dhcph_g->dhcp_yip));
                        fprintf(stdout, "\"result-next-srv\":\"%s\"",
                                get_ip_str(dhcph_g->dhcp_sip));