finally move buildroot-ng to trunk
[openwrt.git] / package / busybox / patches / 150-udhcp-release.patch
1 diff -ruN busybox-1.2.0-old/include/usage.h busybox-1.2.0-new/include/usage.h
2 --- busybox-1.2.0-old/include/usage.h   2006-07-31 10:47:56.000000000 +0200
3 +++ busybox-1.2.0-new/include/usage.h   2006-07-31 11:08:49.000000000 +0200
4 @@ -3190,6 +3190,7 @@
5         "\t-n,\t--now\tExit with failure if lease cannot be immediately negotiated\n" \
6         "\t-p,\t--pidfile=file\tStore process ID of daemon in file\n" \
7         "\t-q,\t--quit\tQuit after obtaining lease\n" \
8 +       "\t-R,\t--release\tRelease IP on quit\n" \
9         "\t-r,\t--request=IP\tIP address to request (default: none)\n" \
10         "\t-s,\t--script=file\tRun file at dhcp events (default: /usr/share/udhcpc/default.script)\n" \
11         "\t-t,\t--retries=NUM\tSend up to NUM request packets\n"\
12 diff -ruN busybox-1.2.0-old/networking/udhcp/dhcpc.c busybox-1.2.0-new/networking/udhcp/dhcpc.c
13 --- busybox-1.2.0-old/networking/udhcp/dhcpc.c  2006-07-01 00:42:02.000000000 +0200
14 +++ busybox-1.2.0-new/networking/udhcp/dhcpc.c  2006-07-31 11:08:49.000000000 +0200
15 @@ -47,6 +47,7 @@
16         .abort_if_no_lease = 0,
17         .foreground = 0,
18         .quit_after_lease = 0,
19 +       .release_on_quit = 0,
20         .background_if_no_lease = 0,
21         .interface = "eth0",
22         .pidfile = NULL,
23 @@ -163,6 +164,7 @@
24                 {"now",         no_argument,            0, 'n'},
25                 {"pidfile",     required_argument,      0, 'p'},
26                 {"quit",        no_argument,            0, 'q'},
27 +               {"release",     no_argument,            0, 'R'},
28                 {"request",     required_argument,      0, 'r'},
29                 {"script",      required_argument,      0, 's'},
30                 {"timeout",     required_argument,      0, 'T'},
31 @@ -174,7 +176,7 @@
32         /* get options */
33         while (1) {
34                 int option_index = 0;
35 -               c = getopt_long(argc, argv, "c:CV:fbH:h:F:i:np:qr:s:T:t:v", arg_options, &option_index);
36 +               c = getopt_long(argc, argv, "c:CV:fbH:h:F:i:np:qRr:s:T:t:v", arg_options, &option_index);
37                 if (c == -1) break;
38  
39                 switch (c) {
40 @@ -244,6 +246,9 @@
41                 case 'q':
42                         client_config.quit_after_lease = 1;
43                         break;
44 +               case 'R':
45 +                       client_config.release_on_quit = 1;
46 +                       break;
47                 case 'r':
48                         requested_ip = inet_addr(optarg);
49                         break;
50 @@ -488,8 +493,11 @@
51  
52                                         state = BOUND;
53                                         change_mode(LISTEN_NONE);
54 -                                       if (client_config.quit_after_lease)
55 +                                       if (client_config.quit_after_lease) {
56 +                                               if (client_config.release_on_quit)
57 +                                                       perform_release();
58                                                 return 0;
59 +                                       }
60                                         if (!client_config.foreground)
61                                                 client_background();
62  
63 @@ -514,12 +522,13 @@
64                         case SIGUSR1:
65                                 perform_renew();
66                                 break;
67 -                       case SIGUSR2:
68 -                               perform_release();
69 -                               break;
70                         case SIGTERM:
71                                 LOG(LOG_INFO, "Received SIGTERM");
72 +                               if (!client_config.release_on_quit)
73                                 return 0;
74 +                       case SIGUSR2:
75 +                               perform_release();
76 +                               break;
77                         }
78                 } else if (retval == -1 && errno == EINTR) {
79                         /* a signal was caught */
80 diff -ruN busybox-1.2.0-old/networking/udhcp/dhcpc.h busybox-1.2.0-new/networking/udhcp/dhcpc.h
81 --- busybox-1.2.0-old/networking/udhcp/dhcpc.h  2006-07-01 00:42:02.000000000 +0200
82 +++ busybox-1.2.0-new/networking/udhcp/dhcpc.h  2006-07-31 11:08:49.000000000 +0200
83 @@ -18,6 +18,7 @@
84  struct client_config_t {
85         char foreground;                /* Do not fork */
86         char quit_after_lease;          /* Quit after obtaining lease */
87 +       char release_on_quit;           /* perform release on quit */
88         char abort_if_no_lease;         /* Abort if no lease */
89         char background_if_no_lease;    /* Fork to background if no lease */
90         char *interface;                /* The name of the interface to use */