Re: Using libbsd dhcpcd options
This stored as "/etc/dhcpcd.conf" might not be completely correct but it works. In the call-back hook you'll get a "new_root_path=" entry with what is set on the DHCP host. Thanks! static const char* dhcpcd_conf_text = \ "debug\n" "clientid\n" "nodhcp6\n" "ipv4only\n" "timeout 0\n" "interface ffec0\n" "option bootfile_name\n" "option root_path\n" "\n"; Peter - Peter Dufault HD Associates, Inc. Software and System Engineering signature.asc Description: Message signed with OpenPGP ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: Using libbsd dhcpcd options
> On Aug 19, 2021, at 20:02 , Chris Johns wrote: > > On 20/8/21 1:45 am, junkes wrote: >> Hallo Peter, >> I do not know if this is best practice but I run the following code: >> >> static void >> default_network_dhcpcd(void) >> { >> static const char default_cfg[] = "clientid test client\n"; >> rtems_status_code sc; >> int fd; >> int rv; >> ssize_t n; >> struct stat statbuf; >> >> if (ENOENT == stat("/etc/dhcpcd.conf", )) { >> fd = open("/etc/dhcpcd.conf", O_CREAT | O_WRONLY, >> S_IRWXU | S_IRWXG | S_IRWXO); >> assert(fd >= 0); >> >> n = write(fd, default_cfg, sizeof(default_cfg) - 1); >> assert(n == (ssize_t) sizeof(default_cfg) - 1); >> >> static const char fhi_cfg[] = >> "nodhcp6\n" >> "ipv4only\n" >> "option ntp_servers\n" >> "option rtems_cmdline\n" >> "option tftp_server_name\n" >> "option bootfile_name\n" >> "define 129 string rtems_cmdline\n" >> "timeout 0"; >> >> n = write(fd, fhi_cfg, sizeof(fhi_cfg) - 1); >> assert(n == (ssize_t) sizeof(fhi_cfg) - 1); >> >> rv = close(fd); >> assert(rv == 0); >> } >> >> sc = rtems_dhcpcd_start(NULL); >> assert(sc == RTEMS_SUCCESSFUL); >> } > Hienz, this is a good solution and using a file best solution. > > Chris I see online that DHCP option 129 has three definitions: "PXE - undefined (vendor specific)", "Kernel options Variable length string", and "Call Server IP address". Above does "option rtems_cmdline" and "define 129 string rtems_cmdline" set option 129 to correspond to "Kernel options"? There's no "DHO_" define for 129 in dhcp.h so I assume that's why you need the "define 129". Option 17 is defined in dhcp.h ("#define DHO_ROOT_PATH 17") so I assume I just add "option root_path". I'll try it later today. Peter - Peter Dufault HD Associates, Inc. Software and System Engineering signature.asc Description: Message signed with OpenPGP ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: Using libbsd dhcpcd options
On 20/8/21 1:45 am, junkes wrote: > Hallo Peter, > I do not know if this is best practice but I run the following code: > > static void > default_network_dhcpcd(void) > { > static const char default_cfg[] = "clientid test client\n"; > rtems_status_code sc; > int fd; > int rv; > ssize_t n; > struct stat statbuf; > > if (ENOENT == stat("/etc/dhcpcd.conf", )) { > fd = open("/etc/dhcpcd.conf", O_CREAT | O_WRONLY, > S_IRWXU | S_IRWXG | S_IRWXO); > assert(fd >= 0); > > n = write(fd, default_cfg, sizeof(default_cfg) - 1); > assert(n == (ssize_t) sizeof(default_cfg) - 1); > > static const char fhi_cfg[] = > "nodhcp6\n" > "ipv4only\n" > "option ntp_servers\n" > "option rtems_cmdline\n" > "option tftp_server_name\n" > "option bootfile_name\n" > "define 129 string rtems_cmdline\n" > "timeout 0"; > > n = write(fd, fhi_cfg, sizeof(fhi_cfg) - 1); > assert(n == (ssize_t) sizeof(fhi_cfg) - 1); > > rv = close(fd); > assert(rv == 0); > } > > sc = rtems_dhcpcd_start(NULL); > assert(sc == RTEMS_SUCCESSFUL); > } Hienz, this is a good solution and using a file best solution. Chris ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: Using libbsd dhcpcd options
Hallo Peter, I do not know if this is best practice but I run the following code: static void default_network_dhcpcd(void) { static const char default_cfg[] = "clientid test client\n"; rtems_status_code sc; int fd; int rv; ssize_t n; struct stat statbuf; if (ENOENT == stat("/etc/dhcpcd.conf", )) { fd = open("/etc/dhcpcd.conf", O_CREAT | O_WRONLY, S_IRWXU | S_IRWXG | S_IRWXO); assert(fd >= 0); n = write(fd, default_cfg, sizeof(default_cfg) - 1); assert(n == (ssize_t) sizeof(default_cfg) - 1); static const char fhi_cfg[] = "nodhcp6\n" "ipv4only\n" "option ntp_servers\n" "option rtems_cmdline\n" "option tftp_server_name\n" "option bootfile_name\n" "define 129 string rtems_cmdline\n" "timeout 0"; n = write(fd, fhi_cfg, sizeof(fhi_cfg) - 1); assert(n == (ssize_t) sizeof(fhi_cfg) - 1); rv = close(fd); assert(rv == 0); } sc = rtems_dhcpcd_start(NULL); assert(sc == RTEMS_SUCCESSFUL); } Heinz On 2021-08-19 12:16, Peter Dufault wrote: I'd like to use the DHCP option 17 (Root Path) to get a mount point for NFS from the DHCP server. I'm starting dhcp with "rtems_dhcpcd_start(NULL)" so it's starting with only the argv array of {"dhcpcd", NULL }. I *think* I need to start it with a customized rtems_dhcpcd_config that would maybe include a "--option" argument, and retrieve it in a run hook (I'm using the run hook already to wait for an IP address to be assigned). The FreeBSD "--option" documentation is: -o, --option "option" Request the DHCP "option" variable for use in "/usr/local/libexec/dhcpcd-run-hooks". which would be an argv of {"dhcpcd", "--option", "17", NULL }. Or is best practice to do something with "rtems-bsd-rc-conf-net.c"? Peter - Peter Dufault HD Associates, Inc. Software and System Engineering ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Using libbsd dhcpcd options
I'd like to use the DHCP option 17 (Root Path) to get a mount point for NFS from the DHCP server. I'm starting dhcp with "rtems_dhcpcd_start(NULL)" so it's starting with only the argv array of {"dhcpcd", NULL }. I *think* I need to start it with a customized rtems_dhcpcd_config that would maybe include a "--option" argument, and retrieve it in a run hook (I'm using the run hook already to wait for an IP address to be assigned). The FreeBSD "--option" documentation is: -o, --option "option" Request the DHCP "option" variable for use in "/usr/local/libexec/dhcpcd-run-hooks". which would be an argv of {"dhcpcd", "--option", "17", NULL }. Or is best practice to do something with "rtems-bsd-rc-conf-net.c"? Peter - Peter Dufault HD Associates, Inc. Software and System Engineering signature.asc Description: Message signed with OpenPGP ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel