~tritone-team/tritone/eucalyptus

« back to all changes in this revision

Viewing changes to net/vnetwork.c

  • Committer: Bazaar Package Importer
  • Author(s): Dustin Kirkland
  • Date: 2009-12-01 21:09:28 UTC
  • mto: This revision was merged to the branch mainline in revision 75.
  • Revision ID: james.westby@ubuntu.com-20091201210928-o2dvg0ubljhb0ft6
Tags: upstream-1.6.1~bzr1083
ImportĀ upstreamĀ versionĀ 1.6.1~bzr1083

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
    if (path) strncpy(vnetconfig->path, path, 1024);
97
97
    if (eucahome) strncpy(vnetconfig->eucahome, eucahome, 1024);
98
98
    if (pubInterface) strncpy(vnetconfig->pubInterface, pubInterface, 32);
99
 
    if (privInterface) strncpy(vnetconfig->privInterface, privInterface, 32);
100
 
    if (mode) strncpy(vnetconfig->mode, mode, 32);
 
99
    if (mode) {
 
100
       strncpy(vnetconfig->mode, mode, 32);
 
101
    } else {
 
102
       logprintfl(EUCAERROR, "vnetInit: NULL mode!\n");
 
103
       return;
 
104
    }
101
105
    if (bridgedev) strncpy(vnetconfig->bridgedev, bridgedev, 32);
102
106
    if (daemon) strncpy(vnetconfig->dhcpdaemon, daemon, 1024);
 
107
    if (privInterface) strncpy(vnetconfig->privInterface, privInterface, 32);
103
108
    if (dhcpuser) strncpy(vnetconfig->dhcpuser, dhcpuser, 32);
104
109
    if (localIp) {
105
110
      char *ipbuf=NULL;
353
358
      vnetconfig->networks[vlan].addrs[found].ip = dot2hex(ip);
354
359
    } else {
355
360
      newip = hex2dot(vnetconfig->networks[vlan].nw + found);
356
 
      vnetconfig->networks[vlan].addrs[found].ip = dot2hex(newip);
357
 
      if (newip) free(newip);
 
361
      if (!newip) {
 
362
         logprintfl(EUCAWARN,"Out of memory\n");
 
363
      } else {
 
364
         vnetconfig->networks[vlan].addrs[found].ip = dot2hex(newip);
 
365
         free(newip);
 
366
      }
358
367
    }
359
368
    vnetconfig->networks[vlan].numhosts++;
360
369
  } else {
590
599
  FH = fdopen(fd, "w");
591
600
  if (!FH) {
592
601
    close(fd);
593
 
    free(file);
594
602
    unlink(file);
 
603
    free(file);
595
604
    return(1);
596
605
  }
597
606
  
1076
1085
  
1077
1086
  snprintf (buf, 512, "%s/euca-dhcp.leases", vnetconfig->path);
1078
1087
  rc = open(buf, O_WRONLY | O_CREAT, 0644);
1079
 
  close(rc);
 
1088
  if (rc != -1) {
 
1089
    close(rc);
 
1090
  } else {
 
1091
    logprintfl(EUCAWARN, "Fail to create/open euca-dhcp.leases\n");
 
1092
  }
1080
1093
  //  snprintf (buf, 512, "touch %s/euca-dhcp.leases", vnetconfig->path);
1081
1094
  //  logprintfl(EUCADEBUG, "executing: %s\n", buf);
1082
1095
  //  rc = system (buf);
1083
1096
  
1084
 
  if (strncmp(vnetconfig->dhcpuser, "root", 32) && vnetconfig->path && strncmp(vnetconfig->path, "/", 1024) && strstr(vnetconfig->path, "eucalyptus/net")) {
 
1097
  if (strncmp(vnetconfig->dhcpuser, "root", 32) && strncmp(vnetconfig->path, "/", 1024) && strstr(vnetconfig->path, "eucalyptus/net")) {
1085
1098
    snprintf(buf, 512, "%s/usr/lib/eucalyptus/euca_rootwrap chgrp -R %s %s", vnetconfig->eucahome, vnetconfig->dhcpuser, vnetconfig->path);
1086
1099
    logprintfl(EUCADEBUG, "executing: %s\n", buf);
1087
1100
    rc = system(buf);
1735
1748
      } else {
1736
1749
        *outbrname = strdup(vnetconfig->privInterface);
1737
1750
      }
 
1751
      if (*outbrname == NULL) {
 
1752
         logprintfl(EUCAERROR, "vnetStartNetwork: out of memory!\n");
 
1753
      }
 
1754
    } else {
 
1755
         logprintfl(EUCADEBUG, "vnetStartNetwork: outbrname is NULL\n");
1738
1756
    }
1739
1757
    rc = 0;
1740
1758
  } else {
1741
1759
    rc = vnetStartNetworkManaged(vnetconfig, vlan, userName, netName, outbrname);
1742
1760
  }
1743
1761
  
1744
 
  if (vnetconfig->role != NC && *outbrname) {
 
1762
  if (vnetconfig->role != NC && outbrname && *outbrname) {
1745
1763
    vnetAddDev(vnetconfig, *outbrname);
1746
1764
  }
1747
1765
  return(rc);
1993
2011
  dst[0] = '\0';
1994
2012
  
1995
2013
  p = strstr(instId, "i-");
 
2014
  if (p == NULL) {
 
2015
    logprintfl(EUCAWARN, "invalid instId passed to instId2mac()\n");
 
2016
    return(1);
 
2017
  }
1996
2018
  p += 2;
1997
2019
  if (strlen(p) == 8) {
1998
2020
    strncat(dst, "d0:0d", 5);