- // unmap red alias ????
-}
-
-
-void add_alias_interfaces(char *configtype,
- char *redtype,
- char *redif,
- int offset) //reserve room for ipsec0=red, ipsec1=green, ipsec2=orange,ipsec3=blue
-{
- FILE *file = NULL;
- char s[STRING_SIZE];
- int alias=0;
-
- /* Check for CONFIG_TYPE=2 or 3 i.e. RED ethernet present. If not,
- * exit gracefully. This is not an error... */
- if (!((strcmp(configtype, "1")==0) || (strcmp(configtype, "2")==0) || (strcmp(configtype, "3")==0) || (strcmp(configtype, "4")==0)))
- return;
-
- /* Now check the RED_TYPE - aliases only work with STATIC. */
- if (!(strcmp(redtype, "STATIC")==0))
- return;
-
- /* Now set up the new aliases from the config file */
- if (!(file = fopen(CONFIG_ROOT "/ethernet/aliases", "r")))
- {
- fprintf(stderr, "Unable to open aliases configuration file\n");
- return;
- }
- while (fgets(s, STRING_SIZE, file) != NULL && (offset+alias) < 16 )
- {
- if (s[strlen(s) - 1] == '\n')
- s[strlen(s) - 1] = '\0';
- int count = 0;
- char *aliasip=NULL;
- char *enabled=NULL;
- char *comment=NULL;
- char *sptr = strtok(s, ",");
- while (sptr)
- {
- if (count == 0)
- aliasip = sptr;
- if (count == 1)
- enabled = sptr;
- else
- comment = sptr;
- count++;
- sptr = strtok(NULL, ",");
- }
-
- if (!(aliasip && enabled))
- continue;
-
- if (!VALID_IP(aliasip))
- {
- fprintf(stderr, "Bad alias : %s\n", aliasip);
- return;
- }
-
- if (strcmp(enabled, "on") == 0)
- {
- memset(s, 0, STRING_SIZE);
- snprintf(s, STRING_SIZE-1, "/usr/sbin/ipsec tncfg --attach --virtual ipsec%d --physical %s:%d >/dev/null", offset+alias, redif, alias);
- safe_system(s);
- alias++;
- }
- }