client: interface name from argv

This commit is contained in:
Zack Buhman 2026-08-28 17:40:52 -05:00
parent 841ea0cec2
commit e02eeef2c2

View File

@ -28,14 +28,20 @@ void print_message(packet::packet const& p, dhcp4::options const& options)
printf("domain name server: %s\n", ip4::tostr(options.domain_name_server)); printf("domain name server: %s\n", ip4::tostr(options.domain_name_server));
} }
int main() int main(int argc, char * argv[])
{ {
if (argc != 2) {
fprintf(stderr, "usage: %s [interface-name]\n", argv[0]);
exit(EXIT_FAILURE);
}
char const * interface_name = argv[1];
printf("interface name: %s\n", interface_name);
srand(time(NULL)); srand(time(NULL));
uint32_t dhcp_transaction_id = rand(); uint32_t dhcp_transaction_id = rand();
int sock = sock::create(68); int sock = sock::create(68);
char const * interface_name = "wlp174s0";
int ifa_index = sock::interface_index(sock, interface_name); int ifa_index = sock::interface_index(sock, interface_name);
sock::bind_interface(sock, ifa_index); sock::bind_interface(sock, ifa_index);