4 #include <dos/dostags.h>
6 #include <kern/amiga_gui.h>
8 #include <net/if_sana.h>
10 #include <stdio.h> // for sprintf
12 extern UBYTE dhclient_path
[];
13 extern struct ifnet
*ifnet
;
14 extern struct Library
*logDOSBase
;
16 #define DOSBase logDOSBase
18 static const TEXT dhclient_proc_name
[] = "AROSTCP DHCP client";
19 static const TEXT dhclient_cmd_name
[] = "dhclient";
21 void run_dhclient(struct ifnet
*ifp
)
25 if (!ifp
->if_data
.ifi_aros_dhcp_pid
) {
26 DDHCP(KPrintF("Starting DHCP client for %s%u\n", ifp
->if_name
, ifp
->if_unit
);)
27 snprintf(ifp
->if_data
.ifi_aros_dhcp_args
, sizeof(ifp
->if_data
.ifi_aros_dhcp_args
), "-q %s%u", ifp
->if_name
,
29 ifp
->if_data
.ifi_aros_dhcp_args
[sizeof(ifp
->if_data
.ifi_aros_dhcp_args
)-1] = 0;
30 seglist
= LoadSeg(dhclient_path
);
31 DDHCP(KPrintF("seglist = 0x%08lx\n", seglist
);)
33 ifp
->if_data
.ifi_aros_dhcp_pid
=
34 (pid_t
)CreateNewProcTags(NP_Seglist
, seglist
,
35 NP_Arguments
, ifp
->if_data
.ifi_aros_dhcp_args
,
37 NP_Name
, dhclient_proc_name
,
38 NP_CommandName
, dhclient_cmd_name
,
41 DDHCP(KPrintF("dhclient pid = 0x%08lx\n", ifp
->if_data
.ifi_aros_dhcp_pid
);)
42 if (!ifp
->if_data
.ifi_aros_dhcp_pid
) {
48 error_request("Unable to start DHCP client for the interface %s%u",
49 (IPTR
)ifp
->if_name
, (IPTR
)ifp
->if_unit
);
53 void kill_dhclient(struct ifnet
*ifp
)
55 if (ifp
->if_data
.ifi_aros_dhcp_pid
) {
56 Signal((APTR
)ifp
->if_data
.ifi_aros_dhcp_pid
, SIGBREAKF_CTRL_C
);
57 ifp
->if_data
.ifi_aros_dhcp_pid
= (pid_t
)NULL
;
65 for (ifp
= ifnet
; ifp
; ifp
= ifp
->if_next
) {
66 if (ifp
->if_flags
& IFF_DELAYUP
) {
67 DDHCP(KPrintF("Executing delayed DHCP start for %s%u\n", ifp
->if_name
, ifp
->if_unit
);)
68 ifp
->if_flags
&= ~IFF_DELAYUP
;