datalink.c (36314) | datalink.c (36345) |
---|---|
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: datalink.c,v 1.3 1998/05/23 13:38:06 brian Exp $ | 26 * $Id: datalink.c,v 1.4 1998/05/23 22:24:33 brian Exp $ |
27 */ 28 29#include <sys/types.h> 30#include <netinet/in.h> 31#include <netinet/in_systm.h> 32#include <netinet/ip.h> 33#include <sys/un.h> 34 --- 486 unchanged lines hidden (view full) --- 521 522static void 523datalink_LayerFinish(void *v, struct fsm *fp) 524{ 525 /* The given fsm is now down */ 526 struct datalink *dl = (struct datalink *)v; 527 528 if (fp->proto == PROTO_LCP) { | 27 */ 28 29#include <sys/types.h> 30#include <netinet/in.h> 31#include <netinet/in_systm.h> 32#include <netinet/ip.h> 33#include <sys/un.h> 34 --- 486 unchanged lines hidden (view full) --- 521 522static void 523datalink_LayerFinish(void *v, struct fsm *fp) 524{ 525 /* The given fsm is now down */ 526 struct datalink *dl = (struct datalink *)v; 527 528 if (fp->proto == PROTO_LCP) { |
529 fsm_Down(fp); /* Bring us to INITIAL or STARTING */ | 529 if (fp->state == ST_STOPPED) 530 fsm_Close(fp); /* back to CLOSED */ 531 fsm_Down(fp); /* Bring us to INITIAL or STARTING */ |
530 (*dl->parent->LayerFinish)(dl->parent->object, fp); 531 datalink_ComeDown(dl, 0); 532 } else if (fp->state == ST_CLOSED && fp->open_mode == OPEN_PASSIVE) 533 fsm_Open(fp); /* CCP goes to ST_STOPPED */ 534} 535 536struct datalink * 537datalink_Create(const char *name, struct bundle *bundle, int type) --- 218 unchanged lines hidden (view full) --- 756 case DATALINK_OPEN: 757 peerid_Init(&dl->peer); 758 fsm_Down(&dl->physical->link.ccp.fsm); 759 fsm_Close(&dl->physical->link.ccp.fsm); 760 /* fall through */ 761 762 case DATALINK_AUTH: 763 case DATALINK_LCP: | 532 (*dl->parent->LayerFinish)(dl->parent->object, fp); 533 datalink_ComeDown(dl, 0); 534 } else if (fp->state == ST_CLOSED && fp->open_mode == OPEN_PASSIVE) 535 fsm_Open(fp); /* CCP goes to ST_STOPPED */ 536} 537 538struct datalink * 539datalink_Create(const char *name, struct bundle *bundle, int type) --- 218 unchanged lines hidden (view full) --- 758 case DATALINK_OPEN: 759 peerid_Init(&dl->peer); 760 fsm_Down(&dl->physical->link.ccp.fsm); 761 fsm_Close(&dl->physical->link.ccp.fsm); 762 /* fall through */ 763 764 case DATALINK_AUTH: 765 case DATALINK_LCP: |
766 if (dl->physical->link.lcp.fsm.state == ST_STOPPED) 767 fsm_Close(&dl->physical->link.lcp.fsm); /* back to CLOSED */ |
|
764 fsm_Down(&dl->physical->link.lcp.fsm); 765 if (stay) 766 fsm_Close(&dl->physical->link.lcp.fsm); 767 else 768 fsm_Open(&dl->physical->link.ccp.fsm); 769 /* fall through */ 770 771 default: --- 188 unchanged lines hidden (view full) --- 960 } 961 } while (cdl); 962 963 if (oname) { 964 log_Printf(LogPHASE, "Rename link %s to %s\n", oname, dl->name); 965 free(oname); 966 } else { 967 dl->name = strdup(dl->name); | 768 fsm_Down(&dl->physical->link.lcp.fsm); 769 if (stay) 770 fsm_Close(&dl->physical->link.lcp.fsm); 771 else 772 fsm_Open(&dl->physical->link.ccp.fsm); 773 /* fall through */ 774 775 default: --- 188 unchanged lines hidden (view full) --- 964 } 965 } while (cdl); 966 967 if (oname) { 968 log_Printf(LogPHASE, "Rename link %s to %s\n", oname, dl->name); 969 free(oname); 970 } else { 971 dl->name = strdup(dl->name); |
968 dl->physical->link.name = dl->name; | |
969 free(iov[*niov].iov_base); 970 } 971 (*niov)++; 972 973 dl->desc.type = DATALINK_DESCRIPTOR; 974 dl->desc.UpdateSet = datalink_UpdateSet; 975 dl->desc.IsSet = datalink_IsSet; 976 dl->desc.Read = datalink_Read; --- 94 unchanged lines hidden (view full) --- 1071 n = strlen(dl->name); 1072 name = (char *)malloc(n+3); 1073 for (f = n - 1; f >= 0; f--) 1074 if (!isdigit(dl->name[f])) 1075 break; 1076 n = sprintf(name, "%.*s-", dl->name[f] == '-' ? f : f + 1, dl->name); 1077 sprintf(name + n, "%d", atoi(dl->name + f + 1) + 1); 1078 oname = dl->name; | 972 free(iov[*niov].iov_base); 973 } 974 (*niov)++; 975 976 dl->desc.type = DATALINK_DESCRIPTOR; 977 dl->desc.UpdateSet = datalink_UpdateSet; 978 dl->desc.IsSet = datalink_IsSet; 979 dl->desc.Read = datalink_Read; --- 94 unchanged lines hidden (view full) --- 1074 n = strlen(dl->name); 1075 name = (char *)malloc(n+3); 1076 for (f = n - 1; f >= 0; f--) 1077 if (!isdigit(dl->name[f])) 1078 break; 1079 n = sprintf(name, "%.*s-", dl->name[f] == '-' ? f : f + 1, dl->name); 1080 sprintf(name + n, "%d", atoi(dl->name + f + 1) + 1); 1081 oname = dl->name; |
1079 dl->physical->link.name = dl->name = name; | 1082 dl->name = name; 1083 /* our physical link name isn't updated (it probably isn't created yet) */ |
1080 return oname; 1081} 1082 1083int 1084datalink_SetMode(struct datalink *dl, int mode) 1085{ 1086 if (!physical_SetMode(dl->physical, mode)) 1087 return 0; 1088 if (dl->physical->type & (PHYS_DIRECT|PHYS_DEDICATED)) 1089 dl->script.run = 0; 1090 if (dl->physical->type == PHYS_DIRECT) 1091 dl->reconnect_tries = 0; 1092 if (mode & (PHYS_PERM|PHYS_1OFF) && dl->state <= DATALINK_READY) 1093 datalink_Up(dl, 1, 1); 1094 return 1; 1095} | 1084 return oname; 1085} 1086 1087int 1088datalink_SetMode(struct datalink *dl, int mode) 1089{ 1090 if (!physical_SetMode(dl->physical, mode)) 1091 return 0; 1092 if (dl->physical->type & (PHYS_DIRECT|PHYS_DEDICATED)) 1093 dl->script.run = 0; 1094 if (dl->physical->type == PHYS_DIRECT) 1095 dl->reconnect_tries = 0; 1096 if (mode & (PHYS_PERM|PHYS_1OFF) && dl->state <= DATALINK_READY) 1097 datalink_Up(dl, 1, 1); 1098 return 1; 1099} |