Diff for /embedaddon/miniupnpd/upnpdescgen.c between versions 1.1.1.2 and 1.1.1.3

version 1.1.1.2, 2012/05/29 12:55:57 version 1.1.1.3, 2013/07/22 00:32:35
Line 1 Line 1
 /* $Id$ */  /* $Id$ */
 /* MiniUPnP project  /* MiniUPnP project
  * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/   * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
 * (c) 2006-2011 Thomas Bernard  * (c) 2006-2012 Thomas Bernard
  * This software is subject to the conditions detailed   * This software is subject to the conditions detailed
  * in the LICENCE file provided within the distribution */   * in the LICENCE file provided within the distribution */
   
Line 118  static const char * magicargname[] = { Line 118  static const char * magicargname[] = {
         "IsWorking"          "IsWorking"
 };  };
   
static const char xmlver[] = static const char xmlver[] =
         "<?xml version=\"1.0\"?>\r\n";          "<?xml version=\"1.0\"?>\r\n";
 static const char root_service[] =  static const char root_service[] =
         "scpd xmlns=\"urn:schemas-upnp-org:service-1-0\"";          "scpd xmlns=\"urn:schemas-upnp-org:service-1-0\"";
static const char root_device[] = static const char root_device[] =
         "root xmlns=\"urn:schemas-upnp-org:device-1-0\"";          "root xmlns=\"urn:schemas-upnp-org:device-1-0\"";
   
/* root Description of the UPnP Device /* root Description of the UPnP Device
 * fixed to match UPnP_IGD_InternetGatewayDevice 1.0.pdf  * fixed to match UPnP_IGD_InternetGatewayDevice 1.0.pdf
  * Needs to be checked with UPnP-gw-InternetGatewayDevice-v2-Device.pdf   * Needs to be checked with UPnP-gw-InternetGatewayDevice-v2-Device.pdf
  * presentationURL is only "recommended" but the router doesn't appears   * presentationURL is only "recommended" but the router doesn't appears
  * in "Network connections" in Windows XP if it is not present. */   * in "Network connections" in Windows XP if it is not present. */
Line 145  static const struct XMLElt rootDesc[] = Line 145  static const struct XMLElt rootDesc[] =
 /* 5 */  /* 5 */
         {"/deviceType", DEVICE_TYPE_IGD},          {"/deviceType", DEVICE_TYPE_IGD},
                 /* urn:schemas-upnp-org:device:InternetGatewayDevice:1 or 2 */                  /* urn:schemas-upnp-org:device:InternetGatewayDevice:1 or 2 */
        {"/friendlyName", ROOTDEV_FRIENDLYNAME},      /* required */        {"/friendlyName", friendly_name/*ROOTDEV_FRIENDLYNAME*/},      /* required */
         {"/manufacturer", ROOTDEV_MANUFACTURER},                /* required */          {"/manufacturer", ROOTDEV_MANUFACTURER},                /* required */
 /* 8 */  /* 8 */
         {"/manufacturerURL", ROOTDEV_MANUFACTURERURL},  /* optional */          {"/manufacturerURL", ROOTDEV_MANUFACTURERURL},  /* optional */
Line 202  static const struct XMLElt rootDesc[] = Line 202  static const struct XMLElt rootDesc[] =
         {"/modelURL", WANDEV_MODELURL},          {"/modelURL", WANDEV_MODELURL},
         {"/serialNumber", serialnumber},          {"/serialNumber", serialnumber},
         {"/UDN", uuidvalue},          {"/UDN", uuidvalue},
        {"/UPC", WANDEV_UPC},        {"/UPC", WANDEV_UPC},   /* UPC (=12 digit barcode) is optional */
 /* 30 */  /* 30 */
         {"serviceList", INITHELPER(32,1)},          {"serviceList", INITHELPER(32,1)},
         {"deviceList", INITHELPER(38,1)},          {"deviceList", INITHELPER(38,1)},
Line 230  static const struct XMLElt rootDesc[] = Line 230  static const struct XMLElt rootDesc[] =
         {"/modelURL", WANCDEV_MODELURL},          {"/modelURL", WANCDEV_MODELURL},
         {"/serialNumber", serialnumber},          {"/serialNumber", serialnumber},
         {"/UDN", uuidvalue},          {"/UDN", uuidvalue},
        {"/UPC", WANCDEV_UPC},        {"/UPC", WANCDEV_UPC},  /* UPC (=12 digit Barcode) is optional */
 #ifdef ENABLE_6FC_SERVICE  #ifdef ENABLE_6FC_SERVICE
         {"serviceList", INITHELPER(51,2)},          {"serviceList", INITHELPER(51,2)},
 #else  #else
Line 277  static const struct XMLElt rootDesc[] = Line 277  static const struct XMLElt rootDesc[] =
         {"/SCPDURL", L3F_PATH},          {"/SCPDURL", L3F_PATH},
 #endif  #endif
 #ifdef ENABLE_DP_SERVICE  #ifdef ENABLE_DP_SERVICE
/* InternetGatewayDevice v2 : /* InternetGatewayDevice v2 :
  * it is RECOMMEDED that DeviceProtection service is implemented and applied.   * it is RECOMMEDED that DeviceProtection service is implemented and applied.
  * If DeviceProtection is not implemented and applied, it is RECOMMENDED   * If DeviceProtection is not implemented and applied, it is RECOMMENDED
  * that control points are able to access only actions and parameters defined   * that control points are able to access only actions and parameters defined
Line 355  static const struct argument GetExternalIPAddressArgs[ Line 355  static const struct argument GetExternalIPAddressArgs[
         {0, 0}          {0, 0}
 };  };
   
static const struct argument DeletePortMappingArgs[] = static const struct argument DeletePortMappingArgs[] =
 {  {
         {1, 11},          {1, 11},
         {1, 12},          {1, 12},
Line 423  static const struct action WANIPCnActions[] = Line 423  static const struct action WANIPCnActions[] =
         {"SetConnectionType", SetConnectionTypeArgs}, /* R */          {"SetConnectionType", SetConnectionTypeArgs}, /* R */
         {"GetConnectionTypeInfo", GetConnectionTypeInfoArgs}, /* R */          {"GetConnectionTypeInfo", GetConnectionTypeInfoArgs}, /* R */
         {"RequestConnection", 0}, /* R */          {"RequestConnection", 0}, /* R */
        {"RequestTermination", 0}, /* O */        /*{"RequestTermination", 0},*/ /* O */
         {"ForceTermination", 0}, /* R */          {"ForceTermination", 0}, /* R */
         /*{"SetAutoDisconnectTime", 0},*/ /* O */          /*{"SetAutoDisconnectTime", 0},*/ /* O */
         /*{"SetIdleDisconnectTime", 0},*/ /* O */          /*{"SetIdleDisconnectTime", 0},*/ /* O */
         /*{"SetWarnDisconnectDelay", 0}, */ /* O */          /*{"SetWarnDisconnectDelay", 0}, */ /* O */
         {"GetStatusInfo", GetStatusInfoArgs}, /* R */          {"GetStatusInfo", GetStatusInfoArgs}, /* R */
        /*GetAutoDisconnectTime*/        /*GetAutoDisconnectTime*/ /* O */
        /*GetIdleDisconnectTime*/        /*GetIdleDisconnectTime*/ /* O */
        /*GetWarnDisconnectDelay*/        /*GetWarnDisconnectDelay*/ /* O */
         {"GetNATRSIPStatus", GetNATRSIPStatusArgs}, /* R */          {"GetNATRSIPStatus", GetNATRSIPStatusArgs}, /* R */
         {"GetGenericPortMappingEntry", GetGenericPortMappingEntryArgs}, /* R */          {"GetGenericPortMappingEntry", GetGenericPortMappingEntryArgs}, /* R */
         {"GetSpecificPortMappingEntry", GetSpecificPortMappingEntryArgs}, /* R */          {"GetSpecificPortMappingEntry", GetSpecificPortMappingEntryArgs}, /* R */
Line 466  static const struct action WANIPCnActions[] = Line 466  static const struct action WANIPCnActions[] =
 };  };
 /* R=Required, O=Optional */  /* R=Required, O=Optional */
   
   /* ignore "warning: missing initializer" */
   #pragma GCC diagnostic ignored "-Wmissing-field-initializers"
   
 static const struct stateVar WANIPCnVars[] =  static const struct stateVar WANIPCnVars[] =
 {  {
 /* 0 */  /* 0 */
Line 502  static const struct stateVar WANIPCnVars[] = Line 505  static const struct stateVar WANIPCnVars[] =
         {"PortMappingEnabled", 1, 0}, /* Required */          {"PortMappingEnabled", 1, 0}, /* Required */
 /* 10 */  /* 10 */
         {"PortMappingLeaseDuration", 3, 2, 1}, /* required */          {"PortMappingLeaseDuration", 3, 2, 1}, /* required */
        /* TODO : for IGD v2 :         /* TODO : for IGD v2 :
          * <stateVariable sendEvents="no">           * <stateVariable sendEvents="no">
          *   <name>PortMappingLeaseDuration</name>           *   <name>PortMappingLeaseDuration</name>
          *   <dataType>ui4</dataType>           *   <dataType>ui4</dataType>
Line 580  static const struct action WANCfgActions[] = Line 583  static const struct action WANCfgActions[] =
 static const struct stateVar WANCfgVars[] =  static const struct stateVar WANCfgVars[] =
 {  {
         {"WANAccessType", 0, 0, 1},          {"WANAccessType", 0, 0, 1},
        /* Allowed Values : DSL / POTS / Cable / Ethernet         /* Allowed Values : DSL / POTS / Cable / Ethernet
          * Default value : empty string */           * Default value : empty string */
         {"Layer1UpstreamMaxBitRate", 3, 0},          {"Layer1UpstreamMaxBitRate", 3, 0},
         {"Layer1DownstreamMaxBitRate", 3, 0},          {"Layer1DownstreamMaxBitRate", 3, 0},
         {"PhysicalLinkStatus", 0|0x80, 0, 6, 6},          {"PhysicalLinkStatus", 0|0x80, 0, 6, 6},
        /*  allowed values :         /*  allowed values :
          *      Up / Down / Initializing (optional) / Unavailable (optionnal)           *      Up / Down / Initializing (optional) / Unavailable (optionnal)
         *  no Default value          *  no Default value
          *  Evented */           *  Evented */
         {"TotalBytesSent", 3, 0},          /* Optional */          {"TotalBytesSent", 3, 0},          /* Optional */
         {"TotalBytesReceived", 3, 0},  /* Optional */          {"TotalBytesReceived", 3, 0},  /* Optional */
Line 824  strcat_int(char * str, int * len, int * tmplen, int i) Line 827  strcat_int(char * str, int * len, int * tmplen, int i)
                 return str;                  return str;
         }          }
         j = 0;          j = 0;
        while(i && j < sizeof(buf)) {        while(i && j < (int)sizeof(buf)) {
                 buf[j++] = '0' + (i % 10);                  buf[j++] = '0' + (i % 10);
                 i = i / 10;                  i = i / 10;
         }          }
Line 914  genXML(char * str, int * len, int * tmplen, Line 917  genXML(char * str, int * len, int * tmplen,
 /* genRootDesc() :  /* genRootDesc() :
  * - Generate the root description of the UPnP device.   * - Generate the root description of the UPnP device.
  * - the len argument is used to return the length of   * - the len argument is used to return the length of
 *   the returned string.  *   the returned string.
  * - tmp_uuid argument is used to build the uuid string */   * - tmp_uuid argument is used to build the uuid string */
 char *  char *
 genRootDesc(int * len)  genRootDesc(int * len)
Line 934  genRootDesc(int * len) Line 937  genRootDesc(int * len)
 }  }
   
 /* genServiceDesc() :  /* genServiceDesc() :
 * Generate service description with allowed methods and  * Generate service description with allowed methods and
  * related variables. */   * related variables. */
 static char *  static char *
 genServiceDesc(int * len, const struct serviceDesc * s)  genServiceDesc(int * len, const struct serviceDesc * s)
Line 953  genServiceDesc(int * len, const struct serviceDesc * s Line 956  genServiceDesc(int * len, const struct serviceDesc * s
         /*strcpy(str, xmlver); */          /*strcpy(str, xmlver); */
         *len = strlen(xmlver);          *len = strlen(xmlver);
         memcpy(str, xmlver, *len + 1);          memcpy(str, xmlver, *len + 1);
        
         acts = s->actionList;          acts = s->actionList;
         vars = s->serviceStateTable;          vars = s->serviceStateTable;
   
Line 1151  genEventVars(int * len, const struct serviceDesc * s,  Line 1154  genEventVars(int * len, const struct serviceDesc * s, 
                         str = strcat_str(str, len, &tmplen, "<e:property><s:");                          str = strcat_str(str, len, &tmplen, "<e:property><s:");
                         str = strcat_str(str, len, &tmplen, v->name);                          str = strcat_str(str, len, &tmplen, v->name);
                         str = strcat_str(str, len, &tmplen, ">");                          str = strcat_str(str, len, &tmplen, ">");
                        //printf("<e:property><s:%s>", v->name);                        /*printf("<e:property><s:%s>", v->name);*/
                         switch(v->ieventvalue) {                          switch(v->ieventvalue) {
                         case 0:                          case 0:
                                 break;                                  break;
Line 1205  genEventVars(int * len, const struct serviceDesc * s,  Line 1208  genEventVars(int * len, const struct serviceDesc * s, 
                         case DEFAULTCONNECTIONSERVICE_MAGICALVALUE:                          case DEFAULTCONNECTIONSERVICE_MAGICALVALUE:
                                 /* DefaultConnectionService magical value */                                  /* DefaultConnectionService magical value */
                                 str = strcat_str(str, len, &tmplen, uuidvalue);                                  str = strcat_str(str, len, &tmplen, uuidvalue);
   #ifdef IGD_V2
                                   str = strcat_str(str, len, &tmplen, ":WANConnectionDevice:2,urn:upnp-org:serviceId:WANIPConn1");
   #else
                                 str = strcat_str(str, len, &tmplen, ":WANConnectionDevice:1,urn:upnp-org:serviceId:WANIPConn1");                                  str = strcat_str(str, len, &tmplen, ":WANConnectionDevice:1,urn:upnp-org:serviceId:WANIPConn1");
   #endif
                                 break;                                  break;
                         default:                          default:
                                 str = strcat_str(str, len, &tmplen, upnpallowedvalues[v->ieventvalue]);                                  str = strcat_str(str, len, &tmplen, upnpallowedvalues[v->ieventvalue]);
Line 1213  genEventVars(int * len, const struct serviceDesc * s,  Line 1220  genEventVars(int * len, const struct serviceDesc * s, 
                         str = strcat_str(str, len, &tmplen, "</s:");                          str = strcat_str(str, len, &tmplen, "</s:");
                         str = strcat_str(str, len, &tmplen, v->name);                          str = strcat_str(str, len, &tmplen, v->name);
                         str = strcat_str(str, len, &tmplen, "></e:property>");                          str = strcat_str(str, len, &tmplen, "></e:property>");
                        //printf("</s:%s></e:property>\n", v->name);                        /*printf("</s:%s></e:property>\n", v->name);*/
                 }                  }
                 v++;                  v++;
         }          }
         str = strcat_str(str, len, &tmplen, "</e:propertyset>");          str = strcat_str(str, len, &tmplen, "</e:propertyset>");
        //printf("</e:propertyset>\n");#if 0
        //printf("\n");        printf("</e:propertyset>\n");
        //printf("%d\n", tmplen);        printf("\n");
         printf("%d\n", tmplen);
 #endif
         str[*len] = '\0';          str[*len] = '\0';
         return str;          return str;
 }  }

Removed from v.1.1.1.2  
changed lines
  Added in v.1.1.1.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>