]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/plugins/radius/ip_util.c
Header file reorganization and cleaning up the public API for pppd version 2.5.0...
[ppp.git] / pppd / plugins / radius / ip_util.c
index cd59e7b5213cbe2ef9c71c9511741c335cf69999..f443185c79edfbb24d80be49cd9eee24f0cc7875 100644 (file)
@@ -26,7 +26,7 @@
  * Returns: 0 on failure
  */
 
-UINT4 rc_get_ipaddr (char *host)
+UINT4 rc_get_ipaddr (const char *host)
 {
        struct hostent *hp;
 
@@ -51,7 +51,7 @@ UINT4 rc_get_ipaddr (char *host)
  *
  */
 
-int rc_good_ipaddr (char *addr)
+int rc_good_ipaddr (const char *addr)
 {
        int             dot_count;
        int             digit_count;
@@ -127,7 +127,7 @@ UINT4 rc_own_ipaddress(void)
        static UINT4 this_host_ipaddr = 0;
 
        if (!this_host_ipaddr) {
-               if ((this_host_ipaddr = rc_get_ipaddr (hostname)) == 0) {
+               if ((this_host_ipaddr = rc_get_ipaddr (ppp_hostname())) == 0) {
                        error("rc_own_ipaddress: couldn't get own IP address");
                        return 0;
                }
@@ -135,3 +135,31 @@ UINT4 rc_own_ipaddress(void)
 
        return this_host_ipaddr;
 }
+
+/*
+ * Function: rc_own_bind_ipaddress
+ *
+ * Purpose: get the IP address to be used as a source address
+ *          for sending requests in host order
+ *
+ * Returns: IP address
+ *
+ */
+
+UINT4 rc_own_bind_ipaddress(void)
+{
+       char *bindaddr;
+       UINT4 rval = 0;
+
+       if ((bindaddr = rc_conf_str("bindaddr")) == NULL ||
+           strcmp(rc_conf_str("bindaddr"), "*") == 0) {
+               rval = INADDR_ANY;
+       } else {
+               if ((rval = rc_get_ipaddr(bindaddr)) == 0) {
+                       error("rc_own_bind_ipaddress: couldn't get IP address from bindaddr");
+                       rval = INADDR_ANY;
+               }
+       }
+
+       return rval;
+}