bundle.c (39395) | bundle.c (40561) |
---|---|
1/*- 2 * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $Id: bundle.c,v 1.34 1998/08/26 17:39:36 brian Exp $ | 26 * $Id: bundle.c,v 1.35 1998/09/17 00:45:25 brian Exp $ |
27 */ 28 29#include <sys/param.h> 30#include <sys/socket.h> 31#include <netinet/in.h> 32#include <net/if.h> 33#include <arpa/inet.h> 34#include <net/route.h> --- 49 unchanged lines hidden (view full) --- 84#include "lcpproto.h" 85#include "chap.h" 86#include "tun.h" 87#include "prompt.h" 88#include "chat.h" 89#include "cbcp.h" 90#include "datalink.h" 91#include "ip.h" | 27 */ 28 29#include <sys/param.h> 30#include <sys/socket.h> 31#include <netinet/in.h> 32#include <net/if.h> 33#include <arpa/inet.h> 34#include <net/route.h> --- 49 unchanged lines hidden (view full) --- 84#include "lcpproto.h" 85#include "chap.h" 86#include "tun.h" 87#include "prompt.h" 88#include "chat.h" 89#include "cbcp.h" 90#include "datalink.h" 91#include "ip.h" |
92#include "iface.h" |
|
92 93#define SCATTER_SEGMENTS 4 /* version, datalink, name, physical */ 94#define SOCKET_OVERHEAD 100 /* additional buffer space for large */ 95 /* {recv,send}msg() calls */ 96 97static int bundle_RemainingIdleTime(struct bundle *); 98static int bundle_RemainingAutoLoadTime(struct bundle *); 99 --- 43 unchanged lines hidden (view full) --- 143 case PHASE_TERMINATE: 144 bundle->phase = new; 145 mp_Down(&bundle->ncp.mp); 146 log_DisplayPrompts(); 147 break; 148 } 149} 150 | 93 94#define SCATTER_SEGMENTS 4 /* version, datalink, name, physical */ 95#define SOCKET_OVERHEAD 100 /* additional buffer space for large */ 96 /* {recv,send}msg() calls */ 97 98static int bundle_RemainingIdleTime(struct bundle *); 99static int bundle_RemainingAutoLoadTime(struct bundle *); 100 --- 43 unchanged lines hidden (view full) --- 144 case PHASE_TERMINATE: 145 bundle->phase = new; 146 mp_Down(&bundle->ncp.mp); 147 log_DisplayPrompts(); 148 break; 149 } 150} 151 |
151static int 152bundle_CleanInterface(const struct bundle *bundle) 153{ 154 int s; 155 struct ifreq ifrq; 156 struct ifaliasreq ifra; 157 158 s = ID0socket(AF_INET, SOCK_DGRAM, 0); 159 if (s < 0) { 160 log_Printf(LogERROR, "bundle_CleanInterface: socket(): %s\n", 161 strerror(errno)); 162 return (-1); 163 } 164 strncpy(ifrq.ifr_name, bundle->ifp.Name, sizeof ifrq.ifr_name - 1); 165 ifrq.ifr_name[sizeof ifrq.ifr_name - 1] = '\0'; 166 while (ID0ioctl(s, SIOCGIFADDR, &ifrq) == 0) { 167 memset(&ifra.ifra_mask, '\0', sizeof ifra.ifra_mask); 168 strncpy(ifra.ifra_name, bundle->ifp.Name, sizeof ifra.ifra_name - 1); 169 ifra.ifra_name[sizeof ifra.ifra_name - 1] = '\0'; 170 ifra.ifra_addr = ifrq.ifr_addr; 171 if (ID0ioctl(s, SIOCGIFDSTADDR, &ifrq) < 0) { 172 if (ifra.ifra_addr.sa_family == AF_INET) 173 log_Printf(LogERROR, "Can't get dst for %s on %s !\n", 174 inet_ntoa(((struct sockaddr_in *)&ifra.ifra_addr)->sin_addr), 175 bundle->ifp.Name); 176 close(s); 177 return 0; 178 } 179 ifra.ifra_broadaddr = ifrq.ifr_dstaddr; 180 if (ID0ioctl(s, SIOCDIFADDR, &ifra) < 0) { 181 if (ifra.ifra_addr.sa_family == AF_INET) 182 log_Printf(LogERROR, "Can't delete %s address on %s !\n", 183 inet_ntoa(((struct sockaddr_in *)&ifra.ifra_addr)->sin_addr), 184 bundle->ifp.Name); 185 close(s); 186 return 0; 187 } 188 } 189 close(s); 190 191 return 1; 192} 193 | |
194static void 195bundle_LayerStart(void *v, struct fsm *fp) 196{ 197 /* The given FSM is about to start up ! */ 198} 199 200 201static void --- 180 unchanged lines hidden (view full) --- 382 383 if (fp->proto == PROTO_LCP) { 384 struct physical *p = link2physical(fp->link); 385 386 bundle_LinkAdded(bundle, p->dl); 387 if (bundle->ncp.mp.active) { 388 struct datalink *dl; 389 | 152static void 153bundle_LayerStart(void *v, struct fsm *fp) 154{ 155 /* The given FSM is about to start up ! */ 156} 157 158 159static void --- 180 unchanged lines hidden (view full) --- 340 341 if (fp->proto == PROTO_LCP) { 342 struct physical *p = link2physical(fp->link); 343 344 bundle_LinkAdded(bundle, p->dl); 345 if (bundle->ncp.mp.active) { 346 struct datalink *dl; 347 |
390 bundle->ifp.Speed = 0; | 348 bundle->ifSpeed = 0; |
391 for (dl = bundle->links; dl; dl = dl->next) 392 if (dl->state == DATALINK_OPEN) | 349 for (dl = bundle->links; dl; dl = dl->next) 350 if (dl->state == DATALINK_OPEN) |
393 bundle->ifp.Speed += modem_Speed(dl->physical); | 351 bundle->ifSpeed += modem_Speed(dl->physical); |
394 tun_configure(bundle, bundle->ncp.mp.peer_mrru); 395 bundle->autoload.running = 1; 396 } else { | 352 tun_configure(bundle, bundle->ncp.mp.peer_mrru); 353 bundle->autoload.running = 1; 354 } else { |
397 bundle->ifp.Speed = modem_Speed(p); | 355 bundle->ifSpeed = modem_Speed(p); |
398 tun_configure(bundle, fsm2lcp(fp)->his_mru); 399 } 400 } else if (fp->proto == PROTO_IPCP) { 401 bundle_StartIdleTimer(bundle); 402 bundle_Notify(bundle, EX_NORMAL); 403 } 404} 405 --- 13 unchanged lines hidden (view full) --- 419 if (fp->proto == PROTO_IPCP) 420 bundle_StopIdleTimer(bundle); 421 else if (fp->proto == PROTO_LCP) { 422 bundle_LinksRemoved(bundle); /* adjust timers & phys_type values */ 423 if (bundle->ncp.mp.active) { 424 struct datalink *dl; 425 struct datalink *lost; 426 | 356 tun_configure(bundle, fsm2lcp(fp)->his_mru); 357 } 358 } else if (fp->proto == PROTO_IPCP) { 359 bundle_StartIdleTimer(bundle); 360 bundle_Notify(bundle, EX_NORMAL); 361 } 362} 363 --- 13 unchanged lines hidden (view full) --- 377 if (fp->proto == PROTO_IPCP) 378 bundle_StopIdleTimer(bundle); 379 else if (fp->proto == PROTO_LCP) { 380 bundle_LinksRemoved(bundle); /* adjust timers & phys_type values */ 381 if (bundle->ncp.mp.active) { 382 struct datalink *dl; 383 struct datalink *lost; 384 |
427 bundle->ifp.Speed = 0; | 385 bundle->ifSpeed = 0; |
428 lost = NULL; 429 for (dl = bundle->links; dl; dl = dl->next) 430 if (fp == &dl->physical->link.lcp.fsm) 431 lost = dl; 432 else if (dl->state == DATALINK_OPEN) | 386 lost = NULL; 387 for (dl = bundle->links; dl; dl = dl->next) 388 if (fp == &dl->physical->link.lcp.fsm) 389 lost = dl; 390 else if (dl->state == DATALINK_OPEN) |
433 bundle->ifp.Speed += modem_Speed(dl->physical); | 391 bundle->ifSpeed += modem_Speed(dl->physical); |
434 | 392 |
435 if (bundle->ifp.Speed) | 393 if (bundle->ifSpeed) |
436 /* Don't configure down to a speed of 0 */ 437 tun_configure(bundle, bundle->ncp.mp.link.lcp.his_mru); 438 439 if (lost) 440 mp_LinkLost(&bundle->ncp.mp, lost); 441 else 442 log_Printf(LogALERT, "Oops, lost an unrecognised datalink (%s) !\n", 443 fp->link->name); --- 320 unchanged lines hidden (view full) --- 764 snprintf(pidfile, sizeof pidfile, "%stun%d.pid", _PATH_VARRUN, bundle->unit); 765 ID0unlink(pidfile); 766} 767 768struct bundle * 769bundle_Create(const char *prefix, int type, const char **argv) 770{ 771 int s, enoentcount, err; | 394 /* Don't configure down to a speed of 0 */ 395 tun_configure(bundle, bundle->ncp.mp.link.lcp.his_mru); 396 397 if (lost) 398 mp_LinkLost(&bundle->ncp.mp, lost); 399 else 400 log_Printf(LogALERT, "Oops, lost an unrecognised datalink (%s) !\n", 401 fp->link->name); --- 320 unchanged lines hidden (view full) --- 722 snprintf(pidfile, sizeof pidfile, "%stun%d.pid", _PATH_VARRUN, bundle->unit); 723 ID0unlink(pidfile); 724} 725 726struct bundle * 727bundle_Create(const char *prefix, int type, const char **argv) 728{ 729 int s, enoentcount, err; |
730 const char *ifname; |
|
772 struct ifreq ifrq; 773 static struct bundle bundle; /* there can be only one */ 774 | 731 struct ifreq ifrq; 732 static struct bundle bundle; /* there can be only one */ 733 |
775 if (bundle.ifp.Name != NULL) { /* Already allocated ! */ | 734 if (bundle.iface != NULL) { /* Already allocated ! */ |
776 log_Printf(LogALERT, "bundle_Create: There's only one BUNDLE !\n"); 777 return NULL; 778 } 779 780 err = ENOENT; 781 enoentcount = 0; 782 for (bundle.unit = 0; ; bundle.unit++) { 783 snprintf(bundle.dev.Name, sizeof bundle.dev.Name, "%s%d", --- 22 unchanged lines hidden (view full) --- 806 807 s = socket(AF_INET, SOCK_DGRAM, 0); 808 if (s < 0) { 809 log_Printf(LogERROR, "bundle_Create: socket(): %s\n", strerror(errno)); 810 close(bundle.dev.fd); 811 return NULL; 812 } 813 | 735 log_Printf(LogALERT, "bundle_Create: There's only one BUNDLE !\n"); 736 return NULL; 737 } 738 739 err = ENOENT; 740 enoentcount = 0; 741 for (bundle.unit = 0; ; bundle.unit++) { 742 snprintf(bundle.dev.Name, sizeof bundle.dev.Name, "%s%d", --- 22 unchanged lines hidden (view full) --- 765 766 s = socket(AF_INET, SOCK_DGRAM, 0); 767 if (s < 0) { 768 log_Printf(LogERROR, "bundle_Create: socket(): %s\n", strerror(errno)); 769 close(bundle.dev.fd); 770 return NULL; 771 } 772 |
814 bundle.ifp.Name = strrchr(bundle.dev.Name, '/'); 815 if (bundle.ifp.Name == NULL) 816 bundle.ifp.Name = bundle.dev.Name; | 773 ifname = strrchr(bundle.dev.Name, '/'); 774 if (ifname == NULL) 775 ifname = bundle.dev.Name; |
817 else | 776 else |
818 bundle.ifp.Name++; | 777 ifname++; |
819 | 778 |
779 bundle.iface = iface_Create(ifname); 780 if (bundle.iface == NULL) { 781 close(s); 782 close(bundle.dev.fd); 783 return NULL; 784 } 785 |
|
820 /* 821 * Now, bring up the interface. 822 */ 823 memset(&ifrq, '\0', sizeof ifrq); | 786 /* 787 * Now, bring up the interface. 788 */ 789 memset(&ifrq, '\0', sizeof ifrq); |
824 strncpy(ifrq.ifr_name, bundle.ifp.Name, sizeof ifrq.ifr_name - 1); | 790 strncpy(ifrq.ifr_name, ifname, sizeof ifrq.ifr_name - 1); |
825 ifrq.ifr_name[sizeof ifrq.ifr_name - 1] = '\0'; 826 if (ID0ioctl(s, SIOCGIFFLAGS, &ifrq) < 0) { 827 log_Printf(LogERROR, "bundle_Create: ioctl(SIOCGIFFLAGS): %s\n", 828 strerror(errno)); 829 close(s); | 791 ifrq.ifr_name[sizeof ifrq.ifr_name - 1] = '\0'; 792 if (ID0ioctl(s, SIOCGIFFLAGS, &ifrq) < 0) { 793 log_Printf(LogERROR, "bundle_Create: ioctl(SIOCGIFFLAGS): %s\n", 794 strerror(errno)); 795 close(s); |
796 iface_Destroy(bundle.iface); 797 bundle.iface = NULL; |
|
830 close(bundle.dev.fd); | 798 close(bundle.dev.fd); |
831 bundle.ifp.Name = NULL; | |
832 return NULL; 833 } 834 ifrq.ifr_flags |= IFF_UP; 835 if (ID0ioctl(s, SIOCSIFFLAGS, &ifrq) < 0) { 836 log_Printf(LogERROR, "bundle_Create: ioctl(SIOCSIFFLAGS): %s\n", 837 strerror(errno)); 838 close(s); | 799 return NULL; 800 } 801 ifrq.ifr_flags |= IFF_UP; 802 if (ID0ioctl(s, SIOCSIFFLAGS, &ifrq) < 0) { 803 log_Printf(LogERROR, "bundle_Create: ioctl(SIOCSIFFLAGS): %s\n", 804 strerror(errno)); 805 close(s); |
806 iface_Destroy(bundle.iface); 807 bundle.iface = NULL; |
|
839 close(bundle.dev.fd); | 808 close(bundle.dev.fd); |
840 bundle.ifp.Name = NULL; | |
841 return NULL; 842 } 843 844 close(s); 845 | 809 return NULL; 810 } 811 812 close(s); 813 |
846 if ((bundle.ifp.Index = GetIfIndex(bundle.ifp.Name)) < 0) { 847 log_Printf(LogERROR, "Can't find interface index.\n"); 848 close(bundle.dev.fd); 849 bundle.ifp.Name = NULL; 850 return NULL; 851 } 852 log_Printf(LogPHASE, "Using interface: %s\n", bundle.ifp.Name); | 814 log_Printf(LogPHASE, "Using interface: %s\n", ifname); |
853 | 815 |
854 bundle.ifp.Speed = 0; | 816 bundle.ifSpeed = 0; |
855 856 bundle.routing_seq = 0; 857 bundle.phase = PHASE_DEAD; 858 bundle.CleaningUp = 0; 859 bundle.AliasEnabled = 0; 860 861 bundle.fsm.LayerStart = bundle_LayerStart; 862 bundle.fsm.LayerUp = bundle_LayerUp; --- 14 unchanged lines hidden (view full) --- 877 bundle.cfg.autoload.min.timeout = 0; 878 bundle.cfg.choked.timeout = CHOKED_TIMEOUT; 879 bundle.phys_type.all = type; 880 bundle.phys_type.open = 0; 881 882 bundle.links = datalink_Create("deflink", &bundle, type); 883 if (bundle.links == NULL) { 884 log_Printf(LogALERT, "Cannot create data link: %s\n", strerror(errno)); | 817 818 bundle.routing_seq = 0; 819 bundle.phase = PHASE_DEAD; 820 bundle.CleaningUp = 0; 821 bundle.AliasEnabled = 0; 822 823 bundle.fsm.LayerStart = bundle_LayerStart; 824 bundle.fsm.LayerUp = bundle_LayerUp; --- 14 unchanged lines hidden (view full) --- 839 bundle.cfg.autoload.min.timeout = 0; 840 bundle.cfg.choked.timeout = CHOKED_TIMEOUT; 841 bundle.phys_type.all = type; 842 bundle.phys_type.open = 0; 843 844 bundle.links = datalink_Create("deflink", &bundle, type); 845 if (bundle.links == NULL) { 846 log_Printf(LogALERT, "Cannot create data link: %s\n", strerror(errno)); |
847 iface_Destroy(bundle.iface); 848 bundle.iface = NULL; |
|
885 close(bundle.dev.fd); | 849 close(bundle.dev.fd); |
886 bundle.ifp.Name = NULL; | |
887 return NULL; 888 } 889 890 bundle.desc.type = BUNDLE_DESCRIPTOR; 891 bundle.desc.UpdateSet = bundle_UpdateSet; 892 bundle.desc.IsSet = bundle_IsSet; 893 bundle.desc.Read = bundle_DescriptorRead; 894 bundle.desc.Write = bundle_DescriptorWrite; --- 17 unchanged lines hidden (view full) --- 912 bundle.idle.done = 0; 913 bundle.notify.fd = -1; 914 memset(&bundle.autoload.timer, '\0', sizeof bundle.autoload.timer); 915 bundle.autoload.done = 0; 916 bundle.autoload.running = 0; 917 memset(&bundle.choked.timer, '\0', sizeof bundle.choked.timer); 918 919 /* Clean out any leftover crud */ | 850 return NULL; 851 } 852 853 bundle.desc.type = BUNDLE_DESCRIPTOR; 854 bundle.desc.UpdateSet = bundle_UpdateSet; 855 bundle.desc.IsSet = bundle_IsSet; 856 bundle.desc.Read = bundle_DescriptorRead; 857 bundle.desc.Write = bundle_DescriptorWrite; --- 17 unchanged lines hidden (view full) --- 875 bundle.idle.done = 0; 876 bundle.notify.fd = -1; 877 memset(&bundle.autoload.timer, '\0', sizeof bundle.autoload.timer); 878 bundle.autoload.done = 0; 879 bundle.autoload.running = 0; 880 memset(&bundle.choked.timer, '\0', sizeof bundle.choked.timer); 881 882 /* Clean out any leftover crud */ |
920 bundle_CleanInterface(&bundle); | 883 iface_Clear(bundle.iface, IFACE_CLEAR_ALL); |
921 922 bundle_LockTun(&bundle); 923 924 return &bundle; 925} 926 927static void 928bundle_DownInterface(struct bundle *bundle) --- 5 unchanged lines hidden (view full) --- 934 935 s = ID0socket(AF_INET, SOCK_DGRAM, 0); 936 if (s < 0) { 937 log_Printf(LogERROR, "bundle_DownInterface: socket: %s\n", strerror(errno)); 938 return; 939 } 940 941 memset(&ifrq, '\0', sizeof ifrq); | 884 885 bundle_LockTun(&bundle); 886 887 return &bundle; 888} 889 890static void 891bundle_DownInterface(struct bundle *bundle) --- 5 unchanged lines hidden (view full) --- 897 898 s = ID0socket(AF_INET, SOCK_DGRAM, 0); 899 if (s < 0) { 900 log_Printf(LogERROR, "bundle_DownInterface: socket: %s\n", strerror(errno)); 901 return; 902 } 903 904 memset(&ifrq, '\0', sizeof ifrq); |
942 strncpy(ifrq.ifr_name, bundle->ifp.Name, sizeof ifrq.ifr_name - 1); | 905 strncpy(ifrq.ifr_name, bundle->iface->name, sizeof ifrq.ifr_name - 1); |
943 ifrq.ifr_name[sizeof ifrq.ifr_name - 1] = '\0'; 944 if (ID0ioctl(s, SIOCGIFFLAGS, &ifrq) < 0) { 945 log_Printf(LogERROR, "bundle_DownInterface: ioctl(SIOCGIFFLAGS): %s\n", 946 strerror(errno)); 947 close(s); 948 return; 949 } 950 ifrq.ifr_flags &= ~IFF_UP; --- 29 unchanged lines hidden (view full) --- 980 dl = datalink_Destroy(dl); 981 982 close(bundle->dev.fd); 983 bundle_UnlockTun(bundle); 984 985 /* In case we never made PHASE_NETWORK */ 986 bundle_Notify(bundle, EX_ERRDEAD); 987 | 906 ifrq.ifr_name[sizeof ifrq.ifr_name - 1] = '\0'; 907 if (ID0ioctl(s, SIOCGIFFLAGS, &ifrq) < 0) { 908 log_Printf(LogERROR, "bundle_DownInterface: ioctl(SIOCGIFFLAGS): %s\n", 909 strerror(errno)); 910 close(s); 911 return; 912 } 913 ifrq.ifr_flags &= ~IFF_UP; --- 29 unchanged lines hidden (view full) --- 943 dl = datalink_Destroy(dl); 944 945 close(bundle->dev.fd); 946 bundle_UnlockTun(bundle); 947 948 /* In case we never made PHASE_NETWORK */ 949 bundle_Notify(bundle, EX_ERRDEAD); 950 |
988 bundle->ifp.Name = NULL; | 951 iface_Destroy(bundle->iface); 952 bundle->iface = NULL; |
989} 990 991struct rtmsg { 992 struct rt_msghdr m_rtm; 993 char m_space[64]; 994}; 995 996int --- 30 unchanged lines hidden (view full) --- 1027 rtdata.sin_port = 0; 1028 rtdata.sin_addr = dst; 1029 1030 cp = rtmes.m_space; 1031 memcpy(cp, &rtdata, rtdata.sin_len); 1032 cp += rtdata.sin_len; 1033 if (cmd == RTM_ADD) { 1034 if (gateway.s_addr == INADDR_ANY) { | 953} 954 955struct rtmsg { 956 struct rt_msghdr m_rtm; 957 char m_space[64]; 958}; 959 960int --- 30 unchanged lines hidden (view full) --- 991 rtdata.sin_port = 0; 992 rtdata.sin_addr = dst; 993 994 cp = rtmes.m_space; 995 memcpy(cp, &rtdata, rtdata.sin_len); 996 cp += rtdata.sin_len; 997 if (cmd == RTM_ADD) { 998 if (gateway.s_addr == INADDR_ANY) { |
1035 /* Add a route through the interface */ 1036 struct sockaddr_dl dl; 1037 const char *iname; 1038 int ilen; 1039 1040 iname = Index2Nam(bundle->ifp.Index); 1041 ilen = strlen(iname); 1042 dl.sdl_len = sizeof dl - sizeof dl.sdl_data + ilen; 1043 dl.sdl_family = AF_LINK; 1044 dl.sdl_index = bundle->ifp.Index; 1045 dl.sdl_type = 0; 1046 dl.sdl_nlen = ilen; 1047 dl.sdl_alen = 0; 1048 dl.sdl_slen = 0; 1049 strncpy(dl.sdl_data, iname, sizeof dl.sdl_data); 1050 memcpy(cp, &dl, dl.sdl_len); 1051 cp += dl.sdl_len; 1052 rtmes.m_rtm.rtm_addrs |= RTA_GATEWAY; | 999 log_Printf(LogERROR, "bundle_SetRoute: Cannot add a route with" 1000 " destination 0.0.0.0\n"); 1001 close(s); 1002 return result; |
1053 } else { 1054 rtdata.sin_addr = gateway; 1055 memcpy(cp, &rtdata, rtdata.sin_len); 1056 cp += rtdata.sin_len; 1057 rtmes.m_rtm.rtm_addrs |= RTA_GATEWAY; 1058 } 1059 } 1060 --- 175 unchanged lines hidden (view full) --- 1236int 1237bundle_ShowStatus(struct cmdargs const *arg) 1238{ 1239 int remaining; 1240 1241 prompt_Printf(arg->prompt, "Phase %s\n", bundle_PhaseName(arg->bundle)); 1242 prompt_Printf(arg->prompt, " Device: %s\n", arg->bundle->dev.Name); 1243 prompt_Printf(arg->prompt, " Interface: %s @ %lubps\n", | 1003 } else { 1004 rtdata.sin_addr = gateway; 1005 memcpy(cp, &rtdata, rtdata.sin_len); 1006 cp += rtdata.sin_len; 1007 rtmes.m_rtm.rtm_addrs |= RTA_GATEWAY; 1008 } 1009 } 1010 --- 175 unchanged lines hidden (view full) --- 1186int 1187bundle_ShowStatus(struct cmdargs const *arg) 1188{ 1189 int remaining; 1190 1191 prompt_Printf(arg->prompt, "Phase %s\n", bundle_PhaseName(arg->bundle)); 1192 prompt_Printf(arg->prompt, " Device: %s\n", arg->bundle->dev.Name); 1193 prompt_Printf(arg->prompt, " Interface: %s @ %lubps\n", |
1244 arg->bundle->ifp.Name, arg->bundle->ifp.Speed); | 1194 arg->bundle->iface->name, arg->bundle->ifSpeed); |
1245 1246 prompt_Printf(arg->prompt, "\nDefaults:\n"); 1247 prompt_Printf(arg->prompt, " Label: %s\n", arg->bundle->cfg.label); 1248 prompt_Printf(arg->prompt, " Auth name: %s\n", 1249 arg->bundle->cfg.auth.name); 1250 prompt_Printf(arg->prompt, " Auto Load: Up after %ds of >= %d packets\n", 1251 arg->bundle->cfg.autoload.max.timeout, 1252 arg->bundle->cfg.autoload.max.packets); --- 36 unchanged lines hidden (view full) --- 1289 prompt_Printf(arg->prompt, " PasswdAuth: %s\n", 1290 optval(arg->bundle, OPT_PASSWDAUTH)); 1291 prompt_Printf(arg->prompt, " Proxy: %s\n", 1292 optval(arg->bundle, OPT_PROXY)); 1293 prompt_Printf(arg->prompt, " Throughput: %s\n", 1294 optval(arg->bundle, OPT_THROUGHPUT)); 1295 prompt_Printf(arg->prompt, " Utmp Logging: %s\n", 1296 optval(arg->bundle, OPT_UTMP)); | 1195 1196 prompt_Printf(arg->prompt, "\nDefaults:\n"); 1197 prompt_Printf(arg->prompt, " Label: %s\n", arg->bundle->cfg.label); 1198 prompt_Printf(arg->prompt, " Auth name: %s\n", 1199 arg->bundle->cfg.auth.name); 1200 prompt_Printf(arg->prompt, " Auto Load: Up after %ds of >= %d packets\n", 1201 arg->bundle->cfg.autoload.max.timeout, 1202 arg->bundle->cfg.autoload.max.packets); --- 36 unchanged lines hidden (view full) --- 1239 prompt_Printf(arg->prompt, " PasswdAuth: %s\n", 1240 optval(arg->bundle, OPT_PASSWDAUTH)); 1241 prompt_Printf(arg->prompt, " Proxy: %s\n", 1242 optval(arg->bundle, OPT_PROXY)); 1243 prompt_Printf(arg->prompt, " Throughput: %s\n", 1244 optval(arg->bundle, OPT_THROUGHPUT)); 1245 prompt_Printf(arg->prompt, " Utmp Logging: %s\n", 1246 optval(arg->bundle, OPT_UTMP)); |
1247 prompt_Printf(arg->prompt, " Iface-Alias: %s\n", 1248 optval(arg->bundle, OPT_IFACEALIAS)); |
|
1297 1298 return 0; 1299} 1300 1301static void 1302bundle_IdleTimeout(void *v) 1303{ 1304 struct bundle *bundle = (struct bundle *)v; --- 326 unchanged lines hidden (view full) --- 1631 if (mode == PHYS_AUTO && !(bundle->phys_type.all & PHYS_AUTO) && 1632 bundle->phase != PHASE_NETWORK) 1633 /* First auto link, we need an interface */ 1634 ipcp_InterfaceUp(&bundle->ncp.ipcp); 1635 1636 /* Regenerate phys_type and adjust autoload & idle timers */ 1637 bundle_LinksRemoved(bundle); 1638 | 1249 1250 return 0; 1251} 1252 1253static void 1254bundle_IdleTimeout(void *v) 1255{ 1256 struct bundle *bundle = (struct bundle *)v; --- 326 unchanged lines hidden (view full) --- 1583 if (mode == PHYS_AUTO && !(bundle->phys_type.all & PHYS_AUTO) && 1584 bundle->phase != PHASE_NETWORK) 1585 /* First auto link, we need an interface */ 1586 ipcp_InterfaceUp(&bundle->ncp.ipcp); 1587 1588 /* Regenerate phys_type and adjust autoload & idle timers */ 1589 bundle_LinksRemoved(bundle); 1590 |
1639 if (omode == PHYS_AUTO && !(bundle->phys_type.all & PHYS_AUTO) && 1640 bundle->phase != PHASE_NETWORK) 1641 /* No auto links left */ 1642 ipcp_CleanInterface(&bundle->ncp.ipcp); 1643 | |
1644 return 1; 1645} 1646 1647void 1648bundle_setsid(struct bundle *bundle, int holdsession) 1649{ 1650 /* 1651 * Lose the current session. This means getting rid of our pid --- 99 unchanged lines hidden --- | 1591 return 1; 1592} 1593 1594void 1595bundle_setsid(struct bundle *bundle, int holdsession) 1596{ 1597 /* 1598 * Lose the current session. This means getting rid of our pid --- 99 unchanged lines hidden --- |