Russ Dill | 61fb489 | 2002-10-14 21:41:28 +0000 | [diff] [blame] | 1 | /* libbb_udhcp.h - busybox compatability wrapper */ |
| 2 | |
Russ Dill | 4e864a3 | 2003-12-18 22:25:38 +0000 | [diff] [blame] | 3 | /* bit of a hack, do this no matter what the order of the includes. |
| 4 | * (for busybox) */ |
| 5 | |
| 6 | #ifdef CONFIG_INSTALL_NO_USR |
Glenn L McGrath | 0226596 | 2004-03-05 14:23:16 +0000 | [diff] [blame] | 7 | #undef DEFAULT_SCRIPT |
Russ Dill | 4e864a3 | 2003-12-18 22:25:38 +0000 | [diff] [blame] | 8 | #define DEFAULT_SCRIPT "/share/udhcpc/default.script" |
| 9 | #endif |
| 10 | |
Russ Dill | 61fb489 | 2002-10-14 21:41:28 +0000 | [diff] [blame] | 11 | #ifndef _LIBBB_UDHCP_H |
| 12 | #define _LIBBB_UDHCP_H |
| 13 | |
Russ Dill | 54fde9e | 2002-12-11 22:43:37 +0000 | [diff] [blame] | 14 | #ifdef IN_BUSYBOX |
Russ Dill | 4b77aca | 2003-12-16 02:28:20 +0000 | [diff] [blame] | 15 | #include "busybox.h" |
Russ Dill | 61fb489 | 2002-10-14 21:41:28 +0000 | [diff] [blame] | 16 | |
| 17 | #ifdef CONFIG_FEATURE_UDHCP_SYSLOG |
Russ Dill | 4e864a3 | 2003-12-18 22:25:38 +0000 | [diff] [blame] | 18 | #define UDHCP_SYSLOG |
Russ Dill | 61fb489 | 2002-10-14 21:41:28 +0000 | [diff] [blame] | 19 | #endif |
| 20 | |
| 21 | #ifdef CONFIG_FEATURE_UDHCP_DEBUG |
Russ Dill | 4e864a3 | 2003-12-18 22:25:38 +0000 | [diff] [blame] | 22 | #define UDHCP_DEBUG |
Russ Dill | 61fb489 | 2002-10-14 21:41:28 +0000 | [diff] [blame] | 23 | #endif |
| 24 | |
| 25 | #define COMBINED_BINARY |
Russ Dill | da97085 | 2002-11-05 20:10:21 +0000 | [diff] [blame] | 26 | #include "version.h" |
Russ Dill | 61fb489 | 2002-10-14 21:41:28 +0000 | [diff] [blame] | 27 | |
Russ Dill | 4b77aca | 2003-12-16 02:28:20 +0000 | [diff] [blame] | 28 | #define xfopen bb_xfopen |
| 29 | |
"Vladimir N. Oleynik" | b628409 | 2005-09-23 11:25:29 +0000 | [diff] [blame] | 30 | /* make safe the exported namespace */ |
| 31 | /* from common.h */ |
Tim Riker | c1ef7bd | 2006-01-25 00:08:53 +0000 | [diff] [blame] | 32 | #define background udhcp_background |
| 33 | #define start_log_and_pid udhcp_start_log_and_pid |
"Vladimir N. Oleynik" | b628409 | 2005-09-23 11:25:29 +0000 | [diff] [blame] | 34 | /* from script.h */ |
Tim Riker | c1ef7bd | 2006-01-25 00:08:53 +0000 | [diff] [blame] | 35 | #define run_script udhcp_run_script |
"Vladimir N. Oleynik" | b628409 | 2005-09-23 11:25:29 +0000 | [diff] [blame] | 36 | /* from packet.h */ |
Tim Riker | c1ef7bd | 2006-01-25 00:08:53 +0000 | [diff] [blame] | 37 | #define init_header udhcp_init_header |
| 38 | #define get_packet udhcp_get_packet |
| 39 | #define checksum udhcp_checksum |
| 40 | #define raw_packet udhcp_raw_packet |
| 41 | #define kernel_packet udhcp_kernel_packet |
"Vladimir N. Oleynik" | b628409 | 2005-09-23 11:25:29 +0000 | [diff] [blame] | 42 | /* from pidfile.h */ |
Tim Riker | c1ef7bd | 2006-01-25 00:08:53 +0000 | [diff] [blame] | 43 | #define pidfile_acquire udhcp_pidfile_acquire |
| 44 | #define pidfile_write_release udhcp_pidfile_write_release |
"Vladimir N. Oleynik" | b628409 | 2005-09-23 11:25:29 +0000 | [diff] [blame] | 45 | /* from options.h */ |
| 46 | #define get_option udhcp_get_option |
| 47 | #define end_option udhcp_end_option |
| 48 | #define add_option_string udhcp_add_option_string |
| 49 | #define add_simple_option udhcp_add_simple_option |
| 50 | #define option_lengths udhcp_option_lengths |
| 51 | /* from socket.h */ |
| 52 | #define listen_socket udhcp_listen_socket |
| 53 | #define read_interface udhcp_read_interface |
| 54 | /* from dhcpc.h */ |
| 55 | #define client_config udhcp_client_config |
| 56 | /* from dhcpd.h */ |
| 57 | #define server_config udhcp_server_config |
| 58 | |
Russ Dill | 61fb489 | 2002-10-14 21:41:28 +0000 | [diff] [blame] | 59 | #else /* ! BB_VER */ |
| 60 | |
Russ Dill | 4b77aca | 2003-12-16 02:28:20 +0000 | [diff] [blame] | 61 | #include <stdlib.h> |
| 62 | #include <stdio.h> |
Russ Dill | 5c9323f | 2004-05-19 09:18:04 +0000 | [diff] [blame] | 63 | #include <sys/sysinfo.h> |
Russ Dill | 4b77aca | 2003-12-16 02:28:20 +0000 | [diff] [blame] | 64 | |
Russ Dill | 61fb489 | 2002-10-14 21:41:28 +0000 | [diff] [blame] | 65 | #define TRUE 1 |
| 66 | #define FALSE 0 |
| 67 | |
| 68 | #define xmalloc malloc |
Russ Dill | 4b77aca | 2003-12-16 02:28:20 +0000 | [diff] [blame] | 69 | #define xcalloc calloc |
| 70 | |
Russ Dill | 4b77aca | 2003-12-16 02:28:20 +0000 | [diff] [blame] | 71 | static inline FILE *xfopen(const char *file, const char *mode) |
| 72 | { |
| 73 | FILE *fp; |
| 74 | if (!(fp = fopen(file, mode))) { |
| 75 | perror("could not open input file"); |
| 76 | exit(0); |
| 77 | } |
| 78 | return fp; |
| 79 | } |
Russ Dill | 61fb489 | 2002-10-14 21:41:28 +0000 | [diff] [blame] | 80 | |
| 81 | #endif /* BB_VER */ |
| 82 | |
| 83 | #endif /* _LIBBB_UDHCP_H */ |