1#include <stdio.h> 2#include <stdlib.h> 3#include <sys/types.h> 4#include <sys/stat.h> 5#include <fcntl.h> 6#include <string.h> 7#include <limits.h> 8#include <dirent.h> 9#include <errno.h> 10#include <sys/mount.h> 11 12#include "rc.h" 13#include "dongles.h" 14 15#ifdef RTCONFIG_BCMARM 16#include <bcmgpio.h> 17#endif 18#include <notify_rc.h> 19#include <usb_info.h> 20#include <disk_initial.h> 21 22#if defined(RTCONFIG_USB) && defined(RTCONFIG_NOTIFICATION_CENTER) 23#include <libnt.h> 24#endif 25 26#define MAX_RETRY_LOCK 1 27 28#ifdef RTCONFIG_USB_PRINTER 29#define MAX_WAIT_PRINTER_MODULE 20 30#define U2EC_FIFO "/var/u2ec_fifo" 31#endif 32 33#ifdef RTCONFIG_USB_MODEM 34#define MODEM_SCRIPTS_DIR "/etc" 35 36#define USB_MODESWITCH_CONF MODEM_SCRIPTS_DIR"/g3.conf" 37 38 39// The dongles which need to create wcdma.cfg for switching. 40int is_create_file_dongle(const unsigned int vid, const unsigned int pid) 41{ 42 if((vid == 0x0408 && pid == 0xf000) // Q110 43 || (vid == 0x07d1 && pid == 0xa800) // DWM-156 A3 44 ) 45 return 1; 46 47 return 0; 48} 49 50#ifdef RTCONFIG_USB_BECEEM 51int is_beceem_dongle(const int mode, const unsigned int vid, const unsigned int pid) 52{ 53 if(mode){ // modem mode. 54 if(vid == 0x198f // Yota 55 || (vid == 0x0b05 && (pid == 0x1780 || pid == 0x1781)) // GMC 56 || (vid == 0x19d2 && (pid == 0x0172 || pid == 0x0044)) // FreshTel or Giraffe 57 ) 58 return 1; 59 } 60 else{ // zero-cd mode. 61 if((vid == 0x198f) // Yota 62 || (vid == 0x0b05 && pid == 0xbccd) // GMC 63 || (vid == 0x19d2 && (pid == 0xbccd || pid == 0x0065)) // FreshTel or Giraffe 64 ) 65 return 1; 66 } 67 68 return 0; 69} 70 71int is_samsung_dongle(const int mode, const unsigned int vid, const unsigned int pid) 72{ 73 if(mode){ // modem mode. 74 if(vid == 0x04e8 && pid == 0x6761 75 ) 76 return 1; 77 } 78 else{ // zero-cd mode. 79 if(vid == 0x04e8 && pid == 0x6761 80 ) 81 return 1; 82 } 83 84 return 0; 85} 86 87int is_gct_dongle(const int mode, const unsigned int vid, const unsigned int pid) 88{ 89 if(mode){ // modem mode. 90 if(vid == 0x1076 && pid == 0x7f00 91 ) 92 return 1; 93 } 94 else{ // zero-cd mode. 95 if(vid == 0x1076 && pid == 0x7f40 96 ) 97 return 1; 98 } 99 100 return 0; 101} 102#endif 103 104// if the MTP mode of the phone will hang the DUT, need add the VID/PID in this function. 105int is_android_phone(const int mode, const unsigned int vid, const unsigned int pid) 106{ 107 if(nvram_match("modem_android", "1")) 108 return 1; 109 else if(mode){ // modem mode. 110 if(vid == 0x04e8 && pid == 0x6864) // Samsung S3 111 return 1; 112 } 113 else{ // MTP mode. 114 if(vid == 0x04e8 && pid == 0x6860) // Samsung S3 115 return 1; 116 } 117 118 return 0; 119} 120 121int is_storage_cd(const int mode, const unsigned int vid, const unsigned int pid) 122{ 123 if(vid == 0x0781 && pid == 0x540e) // SanDisk cruzer 124 return 1; 125 126 return 0; 127} 128 129int write_3g_conf(FILE *fp, int dno, int aut, const unsigned int vid, const unsigned int pid) 130{ 131 switch(dno){ 132 case SN_MU_Q101: 133 fprintf(fp, "DefaultVendor=0x%04x", 0x0408); 134 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1000); 135 fprintf(fp, "TargetVendor=0x%04x\n", 0x0408); 136 fprintf(fp, "TargetProduct=0x%04x\n", 0xea02); 137 fprintf(fp, "MessageEndpoint=0x%02x\n", 0x05); 138 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 139 break; 140 case SN_OPTION_ICON225: 141 fprintf(fp, "DefaultVendor=0x%04x", 0x0af0); 142 fprintf(fp, "DefaultProduct=0x%04x\n", 0x6971); 143 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 144 fprintf(fp, "MessageEndpoint=0x%02x\n", 0x05); 145 fprintf(fp, "MessageContent=%s\n", "555342431223456780100000080000601000000000000000000000000000000"); 146 break; 147 case SN_Option_GlobeSurfer_Icon: 148 fprintf(fp, "DefaultVendor=0x%04x\n", 0x05c6); 149 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1000); 150 fprintf(fp, "TargetVendor=0x%04x\n", 0x0af0); 151 fprintf(fp, "TargetProduct=0x%04x\n", 0x6600); 152 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000601000000000000000000000000000000"); 153 break; 154 case SN_Option_GlobeSurfer_Icon72: 155 fprintf(fp, "DefaultVendor=0x%04x\n", 0x05c6); 156 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1000); 157 fprintf(fp, "TargetVendor=0x%04x\n", 0x0af0); 158 fprintf(fp, "TargetProduct=0x%04x\n", 0x6901); 159 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000601000000000000000000000000000000"); 160 break; 161 case SN_Option_GlobeTrotter_GT_MAX36: 162 fprintf(fp, "DefaultVendor=0x%04x\n", 0x05c6); 163 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1000); 164 fprintf(fp, "TargetVendor=0x%04x\n", 0x0af0); 165 fprintf(fp, "TargetProduct=0x%04x\n", 0x6600); 166 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000601000000000000000000000000000000"); 167 /* fprintf(fp, "NeedResponse=1\n"); // was ResponseNeeded=1 */ 168 break; 169 case SN_Option_GlobeTrotter_GT_MAX72: 170 fprintf(fp, "DefaultVendor=0x%04x\n", 0x05c6); 171 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1000); 172 fprintf(fp, "TargetVendor=0x%04x\n", 0x0af0); 173 fprintf(fp, "TargetProduct=0x%04x\3", 0x6701); 174 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000601000000000000000000000000000000"); 175 break; 176 case SN_Option_GlobeTrotter_EXPRESS72: 177 fprintf(fp, "DefaultVendor=0x%04x\n", 0x05c6); 178 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1000); 179 fprintf(fp, "TargetVendor=0x%04x\n", 0x0af0); 180 fprintf(fp, "TargetProduct=0x%04x\n", 0x6701); 181 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000601000000000000000000000000000000"); 182 /* fprintf(fp, "NeedResponse=1\n"); // was ResponseNeeded=1 */ 183 break; 184 case SN_Option_iCON210: 185 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1e0e); 186 fprintf(fp, "DefaultProduct=0x%04x\n", 0xf000); 187 fprintf(fp, "TargetVendor=0x%04x\n", 0x1e0e); 188 fprintf(fp, "TargetProduct=0x%04x\n", 0x9000); 189 fprintf(fp, "MessageContent=%s\n", "555342431234567800000000000006bd000000020000000000000000000000"); 190 fprintf(fp, "NeedResponse=1\n"); 191 break; 192 case SN_Option_GlobeTrotter_HSUPA_Modem: 193 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0af0); 194 fprintf(fp, "DefaultProduct=0x%04x\n", 0x7011); 195 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 196 fprintf(fp, "MessageContent=%s\n", "55534243785634120100000080000601000000000000000000000000000000"); 197 break; 198 case SN_Option_iCON401: 199 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0af0); 200 fprintf(fp, "DefaultProduct=0x%04x\n", 0x7401); 201 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 202 fprintf(fp, "MessageContent=%s\n", "55534243785634120100000080000601000000000000000000000000000000"); 203 fprintf(fp, "NeedResponse=1\n"); 204 break; 205 case SN_Vodafone_K3760: 206 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0af0); 207 fprintf(fp, "DefaultProduct=0x%04x\n", 0x7501); 208 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 209 fprintf(fp, "MessageContent=%s\n", "55534243785634120100000080000601000000000000000000000000000000"); 210 break; 211 case SN_ATT_USBConnect_Quicksilver: 212 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0af0); 213 fprintf(fp, "DefaultProduct=0x%04x\n", 0xd033); 214 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 215 fprintf(fp, "MessageContent=%s\n", "55534243785634120100000080000601000000000000000000000000000000"); 216 break; 217 case SN_Huawei_EC156: 218 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 219 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1505); 220 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 221 fprintf(fp, "TargetProductList=%s\n", "140b,1506"); 222 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011062000000100000000000000000000"); 223 fprintf(fp, "CheckSuccess=%d\n", 20); 224 break; 225 case SN_Huawei_E169: 226 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 227 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1001); 228 fprintf(fp, "HuaweiMode=1\n"); 229 break; 230 case SN_Huawei_E220: 231 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 232 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1003); 233 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 234 fprintf(fp, "HuaweiMode=1\n"); 235 break; 236 case SN_Huawei_E180: 237 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 238 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1414); 239 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 240 fprintf(fp, "HuaweiMode=1\n"); 241 break; 242 case SN_Huawei_Exxx: 243 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 244 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1c0b); 245 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 246 fprintf(fp, "TargetProduct=0x%04x\n", 0x1c05); 247 fprintf(fp, "MessageEndpoint=0x%02x\n", 0x0f); 248 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011062000000100000000000000000000"); 249 break; 250 case SN_Huawei_E173: 251 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 252 fprintf(fp, "DefaultProduct=0x%04x\n", 0x14b5); 253 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 254 fprintf(fp, "TargetProduct=0x%04x\n", 0x14a8); 255 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011062000000100000000000000000000"); 256 break; 257 case SN_Huawei_E630: 258 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1033); 259 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0035); 260 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 261 fprintf(fp, "TargetProduct=0x%04x\n", 0x1003); 262 fprintf(fp, "HuaweiMode=1\n"); 263 break; 264 case SN_Huawei_E270: 265 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 266 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1446); 267 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 268 fprintf(fp, "TargetProduct=0x%04x\n", 0x14ac); 269 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011060000000000000000000000000000"); 270 break; 271 case SN_Huawei_E1550: 272 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 273 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1446); 274 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 275 fprintf(fp, "TargetProduct=0x%04x\n", 0x1001); 276 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011060000000000000000000000000000"); 277 break; 278 case SN_Huawei_E1612: 279 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 280 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1446); 281 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 282 fprintf(fp, "TargetProduct=0x%04x\n", 0x1406); 283 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011060000000000000000000000000000"); 284 break; 285 case SN_Huawei_E1690: 286 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 287 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1446); 288 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 289 fprintf(fp, "TargetProduct=0x%04x\n", 0x140c); 290 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011060000000000000000000000000000"); 291 break; 292 case SN_Huawei_K3765: 293 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 294 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1520); 295 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 296 fprintf(fp, "TargetProduct=0x%04x\n", 0x1465); 297 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011060000000000000000000000000000"); 298 break; 299 case SN_Huawei_K4505: 300 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 301 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1521); 302 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 303 fprintf(fp, "TargetProduct=0x%04x\n", 0x1464); 304 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011060000000000000000000000000000"); 305 break; 306 case SN_ZTE_MF626: 307 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 308 fprintf(fp, "DefaultProduct=0x%04x\n", 0x2000); 309 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 310 fprintf(fp, "TargetProductList=%s\n", "0001,0002,0015,0016,0017,0019,0031,0033,0037,0042,0052,0055,0061,0063,0064,0066,0091,0108,0117,0128,0151,0157,0177,1402,2002,2003"); 311 fprintf(fp, "StandardEject=1\n"); 312 fprintf(fp, "MessageContent=%s\n", "55534243123456702000000080000c85010101180101010101000000000000"); 313 break; 314 case SN_ZTE_AC8710: 315 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 316 fprintf(fp, "DefaultProduct=0x%04x\n", 0xfff5); 317 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 318 fprintf(fp, "TargetProduct=0x%04x\n", 0xffff); 319 fprintf(fp, "MessageContent=%s\n", "5553424312345678c00000008000069f030000000000000000000000000000"); 320 break; 321 case SN_ZTE_AC2710: 322 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 323 fprintf(fp, "DefaultProduct=0x%04x\n", 0xfff5); 324 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 325 fprintf(fp, "TargetProduct=0x%04x\n", 0xffff); 326 fprintf(fp, "MessageContent=%s\n", "5553424312345678c00000008000069f010000000000000000000000000000"); 327 break; 328 case SN_ZTE_MF110: 329 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 330 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0053); 331 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 332 fprintf(fp, "TargetProduct=0x%04x\n", 0x0031); 333 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 334 fprintf(fp, "MessageContent2=%s\n", "55534243876543212000000080000c85010101180101010101000000000000"); 335 fprintf(fp, "NeedResponse=1\n"); 336 break; 337 case SN_Novatel_Wireless_Ovation_MC950D: 338 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1410); 339 fprintf(fp, "DefaultProduct=0x%04x\n", 0x5010); 340 fprintf(fp, "TargetVendor=0x%04x\n", 0x1410); 341 fprintf(fp, "TargetProduct=0x%04x\n", 0x4400); 342 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 343 fprintf(fp, "NeedResponse=1\n"); 344 break; 345 case SN_Novatel_U727: 346 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1410); 347 fprintf(fp, "DefaultProduct=0x%04x\n", 0x5010); 348 fprintf(fp, "TargetVendor=0x%04x\n", 0x1410); 349 fprintf(fp, "TargetProduct=0x%04x\n", 0x4100); 350 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 351 fprintf(fp, "NeedResponse=1\n"); 352 break; 353 case SN_Novatel_MC990D: 354 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1410); 355 fprintf(fp, "DefaultProduct=0x%04x\n", 0x5020); 356 fprintf(fp, "Interface=%x\n", 5); 357 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 358 fprintf(fp, "NeedResponse=1\n"); 359 break; 360 case SN_Novatel_U760: 361 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1410); 362 fprintf(fp, "DefaultProduct=0x%04x\n", 0x5030); 363 fprintf(fp, "TargetVendor=0x%04x\n", 0x1410); 364 fprintf(fp, "TargetProduct=0x%04x\n", 0x6000); 365 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 366 fprintf(fp, "NeedResponse=1\n"); 367 break; 368 case SN_Alcatel_X020: 369 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1c9e); 370 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1001); 371 fprintf(fp, "TargetVendor=0x%04x\n", 0x1c9e); 372 fprintf(fp, "TargetProduct=0x%04x\n", 0x6061); 373 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000606f50402527000000000000000000000"); 374 break; 375 case SN_Alcatel_X200: 376 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1bbb); 377 fprintf(fp, "DefaultProduct=0x%04x\n", 0xf000); 378 fprintf(fp, "TargetVendor=0x%04x\n", 0x1bbb); 379 fprintf(fp, "TargetProduct=0x%04x\n", 0x0000); 380 fprintf(fp, "MessageContent=%s\n", "55534243123456788000000080000606f50402527000000000000000000000"); 381 break; 382 case SN_Alcatel_X220L: 383 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1bbb); 384 fprintf(fp, "DefaultProduct=0x%04x\n", 0xf000); 385 fprintf(fp, "TargetVendor=0x%04x\n", 0x1bbb); 386 fprintf(fp, "TargetProduct=0x%04x\n", 0x0017); 387 fprintf(fp, "MessageContent=%s\n", "55534243123456788000000080000606f50402527000000000000000000000"); 388 break; 389 case SN_AnyDATA_ADU_500A: 390 fprintf(fp, "DefaultVendor=0x%04x\n", 0x05c6); 391 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1000); 392 fprintf(fp, "TargetVendor=0x%04x\n", 0x16d5); 393 fprintf(fp, "TargetProduct=0x%04x\n", 0x6502); 394 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 395 break; 396 case SN_BandLuxe_C120: 397 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1a8d); 398 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1000); 399 fprintf(fp, "TargetVendor=0x%04x\n", 0x1a8d); 400 fprintf(fp, "TargetProduct=0x%04x\n", 0x1002); 401 fprintf(fp, "MessageContent=%s\n", "55534243123456781200000080000603000000020000000000000000000000"); 402 /* fprintf(fp, "NeedResponse=1\n"); // was ResponseNeeded=1 */ 403 break; 404 case SN_Solomon_S3Gm660: 405 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1dd6); 406 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1000); 407 fprintf(fp, "TargetVendor=0x%04x\n", 0x1dd6); 408 fprintf(fp, "TargetProduct=0x%04x\n", 0x1002); 409 fprintf(fp, "MessageContent=%s\n", "55534243123456781200000080000603000000020000000000000000000000"); 410 /* fprintf(fp, "NeedResponse=1\n"); // was ResponseNeeded=1 */ 411 break; 412 case SN_C_motechD50: 413 fprintf(fp, "DefaultVendor=0x%04x\n", 0x16d8); 414 fprintf(fp, "DefaultProduct=0x%04x\n", 0x6803); 415 fprintf(fp, "TargetVendor=0x%04x\n", 0x16d8); 416 fprintf(fp, "TargetProduct=0x%04x\n", 0x680a); 417 fprintf(fp, "MessageContent=%s\n", "555342431234567824000000800008ff524445564348470000000000000000"); 418 break; 419 case SN_C_motech_CGU628: 420 fprintf(fp, "DefaultVendor=0x%04x\n", 0x16d8); 421 fprintf(fp, "DefaultProduct=0x%04x\n", 0xf000); 422 fprintf(fp, "TargetVendor=0x%04x\n", 0x16d8); 423 fprintf(fp, "TargetProduct=0x%04x\n", 0x6006); 424 fprintf(fp, "MessageContent=%s\n", "55534243d85dd88524000000800008ff524445564348470000000000000000"); 425 break; 426 case SN_Toshiba_G450: 427 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0930); 428 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0d46); 429 fprintf(fp, "TargetVendor=0x%04x\n", 0x0930); 430 fprintf(fp, "TargetProduct=0x%04x\n", 0x0d45); 431 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 432 fprintf(fp, "NeedResponse=1\n"); 433 break; 434 case SN_UTStarcom_UM175: 435 fprintf(fp, "DefaultVendor=0x%04x\n", 0x106c); 436 fprintf(fp, "DefaultProduct=0x%04x\n", 0x3b03); 437 fprintf(fp, "TargetVendor=0x%04x\n", 0x106c); 438 fprintf(fp, "TargetProduct=0x%04x\n", 0x3715); 439 fprintf(fp, "MessageContent=%s\n", "555342431234567824000000800008ff024445564348470000000000000000"); 440 break; 441 case SN_Hummer_DTM5731: 442 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1ab7); 443 fprintf(fp, "DefaultProduct=0x%04x\n", 0x5700); 444 fprintf(fp, "TargetVendor=0x%04x\n", 0x1ab7); 445 fprintf(fp, "TargetProduct=0x%04x\n", 0x5731); 446 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 447 fprintf(fp, "NeedResponse=1\n"); 448 break; 449 case SN_A_Link_3GU: 450 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1e0e); 451 fprintf(fp, "DefaultProduct=0x%04x\n", 0xf000); 452 fprintf(fp, "TargetVendor=0x%04x\n", 0x1e0e); 453 fprintf(fp, "TargetProduct=0x%04x\n", 0x9200); 454 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 455 break; 456 case SN_Sierra_Wireless_Compass597: 457 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1199); 458 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0fff); 459 fprintf(fp, "TargetVendor=0x%04x\n", 0x1199); 460 fprintf(fp, "TargetProduct=0x%04x\n", 0x0023); 461 fprintf(fp, "SierraMode=1\n"); 462 break; 463 case SN_Sierra881U: 464 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1199); 465 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0fff); 466 fprintf(fp, "TargetVendor=0x%04x\n", 0x1199); 467 fprintf(fp, "TargetProduct=0x%04x\n", 0x6856); 468 fprintf(fp, "SierraMode=1\n"); 469 break; 470 case SN_Sony_Ericsson_MD400: 471 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0fce); 472 fprintf(fp, "DefaultProduct=0x%04x\n", 0xd0e1); 473 fprintf(fp, "TargetClass=0x%02x\n", 0x02); 474 fprintf(fp, "Configuration=%d\n", 2); 475 fprintf(fp, "SonyMode=1\n"); 476 break; 477 case SN_LG_LDU_1900D: 478 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1004); 479 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1000); 480 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000aff554d53434847000000000000000000"); 481 break; 482 case SN_Samsung_SGH_Z810: 483 fprintf(fp, "DefaultVendor=0x%04x\n", 0x05c6); 484 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1000); 485 fprintf(fp, "TargetVendor=0x%04x\n", 0x04e8); 486 fprintf(fp, "TargetProduct=0x%04x\n", 0x6601); 487 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000616000000000000000000000000000000"); 488 break; 489 case SN_MobiData_MBD_200HU: 490 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1c9e); 491 fprintf(fp, "DefaultProduct=0x%04x\n", 0xf000); 492 fprintf(fp, "TargetVendor=0x%04x\n", 0x1c9e); 493 fprintf(fp, "TargetProduct=0x%04x\n", 0x9000); 494 fprintf(fp, "MessageContent=%s\n", "55534243123456788000000080000606f50402527000000000000000000000"); 495 break; 496 case SN_BSNL_310G: 497 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1c9e); 498 fprintf(fp, "DefaultProduct=0x%04x\n", 0xf000); 499 fprintf(fp, "TargetVendor=0x%04x\n", 0x1c9e); 500 fprintf(fp, "TargetProduct=0x%04x\n", 0x9605); 501 fprintf(fp, "MessageContent=%s\n", "55534243123456788000000080000606f50402527000000000000000000000"); 502 break; 503 case SN_BSNL_LW272: 504 fprintf(fp, "DefaultVendor=0x%04x\n", 0x230d); 505 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0001); 506 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 507 fprintf(fp, "Configuration=%d\n", 3); 508 break; 509 case SN_ST_Mobile: 510 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1c9e); 511 fprintf(fp, "DefaultProduct=0x%04x\n", 0xf000); 512 fprintf(fp, "TargetVendor=0x%04x\n", 0x1c9e); 513 fprintf(fp, "TargetProduct=0x%04x\n", 0x9063); 514 fprintf(fp, "MessageContent=%s\n", "55534243123456788000000080000606f50402527000000000000000000000"); 515 break; 516 case SN_MyWave_SW006: 517 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1c9e); 518 fprintf(fp, "DefaultProduct=0x%04x\n", 0x9200); 519 fprintf(fp, "TargetVendor=0x%04x\n", 0x1c9e); 520 fprintf(fp, "TargetProduct=0x%04x\n", 0x9202); 521 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000606f50402527000000000000000000000"); 522 break; 523 case SN_Cricket_A600: 524 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1f28); 525 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0021); 526 fprintf(fp, "TargetVendor=0x%04x\n", 0x1f28); 527 fprintf(fp, "TargetProduct=0x%04x\n", 0x0020); 528 fprintf(fp, "MessageContent=%s\n", "555342431234567824000000800108df200000000000000000000000000000"); 529 break; 530 case SN_EpiValley_SEC7089: 531 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1b7d); 532 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0700); 533 fprintf(fp, "TargetVendor=0x%04x\n", 0x1b7d); 534 fprintf(fp, "TargetProduct=0x%04x\n", 0x0001); 535 fprintf(fp, "MessageContent=%s\n", "555342431234567824000000800008FF05B112AEE102000000000000000000"); 536 break; 537 case SN_Samsung_U209: 538 fprintf(fp, "DefaultVendor=0x%04x\n", 0x04e8); 539 fprintf(fp, "DefaultProduct=0x%04x\n", 0xf000); 540 fprintf(fp, "TargetVendor=0x%04x\n", 0x04e8); 541 fprintf(fp, "TargetProduct=0x%04x\n", 0x6601); 542 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000616000000000000000000000000000000"); 543 break; 544 case SN_D_Link_DWM162_U5: 545 fprintf(fp, "DefaultVendor=0x%04x\n", 0x05c6); 546 fprintf(fp, "DefaultProduct=0x%04x\n", 0x2001); 547 fprintf(fp, "TargetVendor=0x%04x\n", 0x1e0e); 548 fprintf(fp, "TargetProductList=%s\n", "ce16,cefe"); 549 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 550 fprintf(fp, "NeedResponse=1\n"); 551 break; 552 case SN_Novatel_MC760: 553 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1410); 554 fprintf(fp, "DefaultProduct=0x%04x\n", 0x5031); 555 fprintf(fp, "TargetVendor=0x%04x\n", 0x1410); 556 fprintf(fp, "TargetProduct=0x%04x\n", 0x6002); 557 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 558 fprintf(fp, "NeedResponse=1\n"); 559 break; 560 case SN_Philips_TalkTalk: 561 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0471); 562 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1237); 563 fprintf(fp, "TargetVendor=0x%04x\n", 0x0471); 564 fprintf(fp, "TargetProduct=0x%04x\n", 0x1234); 565 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000030000000000000000000000"); 566 fprintf(fp, "NeedResponse=1\n"); 567 break; 568 case SN_HuaXing_E600: 569 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0471); 570 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1237); 571 fprintf(fp, "TargetVendor=0x%04x\n", 0x0471); 572 fprintf(fp, "TargetProduct=0x%04x\n", 0x1206); 573 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 574 fprintf(fp, "Configuration=%d\n", 2); 575 fprintf(fp, "NeedResponse=1\n"); 576 break; 577 case SN_C_motech_CHU_629S: 578 fprintf(fp, "DefaultVendor=0x%04x\n", 0x16d8); 579 fprintf(fp, "DefaultProduct=0x%04x\n", 0x700a); 580 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 581 fprintf(fp, "MessageContent=%s\n", "55534243123456782400000080000dfe524445564348473d4e444953000000"); 582 break; 583 case SN_Sagem9520: 584 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1076); 585 fprintf(fp, "DefaultProduct=0x%04x\n", 0x7f40); 586 fprintf(fp, "TargetVendor=0x%04x\n", 0x1076); 587 fprintf(fp, "TargetProduct=0x%04x\n", 0x7f00); 588 fprintf(fp, "GCTMode=1\n"); 589 break; 590 case SN_Nokia_CS10: 591 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0421); 592 fprintf(fp, "DefaultProduct=0x%04x\n", 0x060c); 593 fprintf(fp, "TargetVendor=0x%04x\n", 0x0421); 594 fprintf(fp, "TargetProduct=0x%04x\n", 0x060e); 595 fprintf(fp, "CheckSuccess=%d\n", 20); 596 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 597 break; 598 case SN_Nokia_CS15: 599 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0421); 600 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0610); 601 fprintf(fp, "TargetVendor=0x%04x\n", 0x0421); 602 fprintf(fp, "TargetProduct=0x%04x\n", 0x0612); 603 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 604 fprintf(fp, "NeedResponse=1\n"); 605 break; 606 case SN_Nokia_CS17: 607 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0421); 608 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0622); 609 fprintf(fp, "TargetVendor=0x%04x\n", 0x0421); 610 fprintf(fp, "TargetProduct=0x%04x\n", 0x0623); 611 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 612 break; 613 case SN_Nokia_CS18: 614 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0421); 615 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0627); 616 fprintf(fp, "TargetVendor=0x%04x\n", 0x0421); 617 fprintf(fp, "TargetProduct=0x%04x\n", 0x0612); 618 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 619 break; 620 case SN_Vodafone_MD950: 621 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0471); 622 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1210); 623 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 624 fprintf(fp, "NeedResponse=1\n"); 625 break; 626 case SN_Siptune_LM75: 627 fprintf(fp, "DefaultVendor=0x%04x\n", 0x05c6); 628 fprintf(fp, "DefaultProduct=0x%04x\n", 0xf000); 629 fprintf(fp, "TargetVendor=0x%04x\n", 0x05c6); 630 fprintf(fp, "TargetProduct=0x%04x\n", 0x9000); 631 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 632 break; 633 /* 0715 add */ 634 case SN_SU9800: 635 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1c9e); 636 fprintf(fp, "DefaultProduct=0x%04x\n", 0x9800); 637 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 638 fprintf(fp, "MessageContent=%s\n", "55534243123456788000000080000606f50402527000000000000000000000"); 639 break; 640 case SN_OPTION_ICON_461: 641 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0af0); 642 fprintf(fp, "DefaultProduct=0x%04x\n", 0x7a05); 643 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 644 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000601000000000000000000000000000000"); 645 break; 646 case SN_Huawei_K3771: 647 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 648 fprintf(fp, "DefaultProduct=0x%04x\n", 0x14c4); 649 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 650 fprintf(fp, "TargetProduct=0x%04x\n", 0x14ca); 651 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011062000000100000000000000000000"); 652 break; 653 case SN_Huawei_K3770: 654 if(nvram_match("test_k3770", "1")){ // ACM mode 655 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 656 fprintf(fp, "DefaultProduct=0x%04x\n", 0x14d1); 657 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 658 fprintf(fp, "TargetProduct=0x%04x\n", 0x1c05); 659 fprintf(fp, "CheckSuccess=%d\n", 20); 660 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011060000000000000000000000000000"); 661 } 662 else{ 663 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 664 fprintf(fp, "DefaultProduct=0x%04x\n", 0x14d1); 665 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 666 fprintf(fp, "TargetProduct=0x%04x\n", 0x14c9); 667 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011062000000100000000000000000000"); 668 } 669 break; 670 case SN_Mobile_Action: 671 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0df7); 672 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0800); 673 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 674 fprintf(fp, "MobileActionMode=1\n"); 675 fprintf(fp, "NoDriverLoading=1\n"); 676 break; 677 case SN_HP_P1102: 678 fprintf(fp, "DefaultVendor=0x%04x\n", 0x03f0); 679 fprintf(fp, "DefaultProduct=0x%04x\n", 0x002a); 680 fprintf(fp, "TargetClass=0x%02x\n", 0x07); 681 fprintf(fp, "MessageContent=%s\n", "555342431234567800000000000006d0000000000000000000000000000000"); 682 fprintf(fp, "NeedResponse=1\n"); 683 break; 684 case SN_Visiontek_82GH: 685 fprintf(fp, "DefaultVendor=0x%04x\n", 0x230d); 686 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0007); 687 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 688 fprintf(fp, "Configuration=%d\n", 3); 689 break; 690 case SN_ZTE_MF190_var: 691 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 692 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0149); 693 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 694 fprintf(fp, "TargetProduct=0x%04x\n", 0x0124); 695 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061e000000000000000000000000000000"); 696 fprintf(fp, "MessageContent2=%s\n", "5553424312345679000000000000061b000000020000000000000000000000"); 697 fprintf(fp, "MessageContent3=%s\n", "55534243123456702000000080000c85010101180101010101000000000000"); 698 fprintf(fp, "NeedResponse=1\n"); 699 break; 700 case SN_ZTE_MF192: 701 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 702 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1216); 703 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 704 fprintf(fp, "TargetProduct=0x%04x\n", 0x1218); 705 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 706 break; 707 case SN_ZTE_MF691: 708 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 709 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1201); 710 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 711 fprintf(fp, "TargetProduct=0x%04x\n", 0x1203); 712 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 713 break; 714 case SN_CHU_629S: 715 fprintf(fp, "DefaultVendor=0x%04x\n", 0x16d8); 716 fprintf(fp, "DefaultProduct=0x%04x\n", 0x700b); 717 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 718 fprintf(fp, "MessageContent=%s\n", "55534243123456782400000080000dfe524445564348473d4e444953000000"); 719 break; 720 case SN_JOA_LM_700r: 721 fprintf(fp, "DefaultVendor=0x%04x\n", 0x198a); 722 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0003); 723 fprintf(fp, "TargetVendor=0x%04x\n", 0x198a); 724 fprintf(fp, "TargetProduct=0x%04x\n", 0x0002); 725 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 726 break; 727 case SN_ZTE_MF190: 728 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 729 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1224); 730 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 731 fprintf(fp, "TargetProduct=0x%04x\n", 0x0082); 732 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061e000000000000000000000000000000"); 733 fprintf(fp, "MessageContent2=%s\n", "5553424312345679000000000000061b000000020000000000000000000000"); 734 fprintf(fp, "NeedResponse=1\n"); 735 break; 736 case SN_ZTE_ffe: 737 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 738 fprintf(fp, "DefaultProduct=0x%04x\n", 0xffe6); 739 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 740 fprintf(fp, "TargetProduct=0x%04x\n", 0xffe5); 741 fprintf(fp, "MessageContent=%s\n", "5553424330f4cf8124000000800108df200000000000000000000000000000"); 742 break; 743 case SN_SE_MD400G: 744 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0fce); 745 fprintf(fp, "DefaultProduct=0x%04x\n", 0xd103); 746 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 747 fprintf(fp, "SonyMode=1\n"); 748 break; 749 case SN_DLINK_DWM_156_A1: 750 fprintf(fp, "DefaultVendor=0x%04x\n", 0x07d1); 751 fprintf(fp, "DefaultProduct=0x%04x\n", 0xa800); 752 fprintf(fp, "TargetVendor=0x%04x\n", 0x07d1); 753 fprintf(fp, "TargetProduct=0x%04x\n", 0x3e02); 754 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 755 break; 756 case SN_DLINK_DWM_156_A3: 757 fprintf(fp, "DefaultVendor=0x%04x\n", 0x07d1); 758 fprintf(fp, "DefaultProduct=0x%04x\n", 0xa804); 759 fprintf(fp, "TargetVendor=0x%04x\n", 0x07d1); 760 fprintf(fp, "TargetProduct=0x%04x\n", 0x7e11); 761 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 762 break; 763 case SN_DLINK_DWM_156_A7_1: 764 fprintf(fp, "DefaultVendor=0x%04x\n", 0x2001); 765 fprintf(fp, "DefaultProduct=0x%04x\n", 0xa706); 766 fprintf(fp, "TargetVendor=0x%04x\n", 0x2001); 767 fprintf(fp, "TargetProduct=0x%04x\n", 0x7d01); 768 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 769 break; 770 case SN_DLINK_DWM_156_A7_2: 771 fprintf(fp, "DefaultVendor=0x%04x\n", 0x2001); 772 fprintf(fp, "DefaultProduct=0x%04x\n", 0xa707); 773 fprintf(fp, "TargetVendor=0x%04x\n", 0x2001); 774 fprintf(fp, "TargetProduct=0x%04x\n", 0x7d02); 775 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 776 break; 777 case SN_DLINK_DWM_156_A7_3: 778 fprintf(fp, "DefaultVendor=0x%04x\n", 0x2001); 779 fprintf(fp, "DefaultProduct=0x%04x\n", 0xa708); 780 fprintf(fp, "TargetVendor=0x%04x\n", 0x2001); 781 fprintf(fp, "TargetProduct=0x%04x\n", 0x7d03); 782 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 783 break; 784 case SN_Huawei_U8220: 785 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 786 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1030); 787 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 788 fprintf(fp, "TargetProduct=0x%04x\n", 0x1034); 789 fprintf(fp, "MessageContent=%s\n", "55534243123456780600000080010a11060000000000000000000000000000"); 790 /* fprintf(fp, "NoDriverLoading=1\n");*/ 791 break; 792 case SN_Huawei_T_Mobile_NL: 793 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 794 fprintf(fp, "DefaultProduct=0x%04x\n", 0x14fe); 795 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 796 fprintf(fp, "TargetProduct=0x%04x\n", 0x1506); 797 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011062000000100000000000000000000"); 798 break; 799 case SN_Huawei_E3276S150: 800 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 801 fprintf(fp, "DefaultProduct=0x%04x\n", 0x157c); 802 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 803 fprintf(fp, "TargetProduct=0x%04x\n", 0x1506); 804 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011062000000100000000000000000000"); 805 break; 806 case SN_ZTE_K3806Z: 807 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 808 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0013); 809 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 810 fprintf(fp, "TargetProduct=0x%04x\n", 0x0015); 811 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 812 fprintf(fp, "NeedResponse=1\n"); 813 break; 814 case SN_Vibe_3G: 815 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1c9e); 816 fprintf(fp, "DefaultProduct=0x%04x\n", 0x6061); 817 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 818 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000606f50402527000000000000000000000"); 819 break; 820 case SN_ZTE_MF637: 821 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 822 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0110); 823 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 824 fprintf(fp, "TargetProduct=0x%04x\n", 0x0121); 825 fprintf(fp, "MessageContent=%s\n", "5553424302000000000000000000061b000000020000000000000000000000"); 826 fprintf(fp, "NeedResponse=1\n"); 827 break; 828 case SN_ONDA_MW836UP_K: 829 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1ee8); 830 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0040); 831 fprintf(fp, "TargetVendor=0x%04x\n", 0x1ee8); 832 fprintf(fp, "TargetProduct=0x%04x\n", 0x003e); 833 fprintf(fp, "MessageContent=%s\n", "555342431234567800000000000010ff000000000000000000000000000000"); 834 fprintf(fp, "NeedResponse=1\n"); 835 break; 836 case SN_Huawei_V725: 837 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 838 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1009); 839 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 840 fprintf(fp, "HuaweiMode=1\n"); 841 break; 842 case SN_Huawei_ET8282: 843 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 844 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1da1); 845 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 846 fprintf(fp, "TargetProduct=0x%04x\n", 0x1d09); 847 fprintf(fp, "HuaweiMode=1\n"); 848 break; 849 case SN_Huawei_E352: 850 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 851 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1449); 852 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 853 fprintf(fp, "TargetProduct=0x%04x\n", 0x1444); 854 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011062000000100000000000000000000"); 855 break; 856 case SN_Huawei_BM358: 857 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 858 fprintf(fp, "DefaultProduct=0x%04x\n", 0x380b); 859 fprintf(fp, "TargetClass=0x%02x\n", 0x02); 860 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061e000000000000000000000000000000"); 861 fprintf(fp, "MessageContent2=%s\n", "5553424312345679000000000000061b000000020000000000000000000000"); 862 fprintf(fp, "NeedResponse=1\n"); 863 break; 864 case SN_Haier_CE_100: 865 fprintf(fp, "DefaultVendor=0x%04x\n", 0x201e); 866 fprintf(fp, "DefaultProduct=0x%04x\n", 0x2009); 867 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 868 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061e000000000000000000000000000000"); 869 fprintf(fp, "MessageContent2=%s\n", "5553424312345679000000000000061b000000020000000000000000000000"); 870 fprintf(fp, "NeedResponse=1\n"); 871 break; 872 case SN_Franklin_Wireless_U210_var: 873 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1fac); 874 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0032); 875 fprintf(fp, "Configuration=%d\n", 2); 876 break; 877 case SN_Exiss_E_190: 878 fprintf(fp, "DefaultVendor=0x%04x\n", 0x8888); 879 fprintf(fp, "DefaultProduct=0x%04x\n", 0x6500); 880 fprintf(fp, "TargetVendor=0x%04x\n", 0x16d8); 881 fprintf(fp, "TargetProduct=0x%04x\n", 0x6533); 882 fprintf(fp, "MessageContent=%s\n", "5553424398e2c4812400000080000bff524445564348473d43440000000000"); 883 break; 884 case SN_dealextreme: 885 fprintf(fp, "DefaultVendor=0x%04x\n", 0x05c6); 886 fprintf(fp, "DefaultProduct=0x%04x\n", 0x2000); 887 fprintf(fp, "TargetVendor=0x%04x\n", 0x05c6); 888 fprintf(fp, "TargetProduct=0x%04x\n", 0x0015); 889 fprintf(fp, "MessageContent=%s\n", "5553424368032c882400000080000612000000240000000000000000000000"); 890 fprintf(fp, "CheckSuccess=%d\n", 40); 891 fprintf(fp, "NeedResponse=1\n"); 892 break; 893 case SN_CHU_628S: 894 fprintf(fp, "DefaultVendor=0x%04x\n", 0x16d8); 895 fprintf(fp, "DefaultProduct=0x%04x\n", 0x6281); 896 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 897 fprintf(fp, "MessageContent=%s\n", "555342431234567824000000800008ff524445564348470000000000000000"); 898 break; 899 case SN_MediaTek_Wimax_USB: 900 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0e8d); 901 fprintf(fp, "DefaultProduct=0x%04x\n", 0x7109); 902 fprintf(fp, "TargetVendor=0x%04x\n", 0x0e8d); 903 fprintf(fp, "TargetProduct=0x%04x\n", 0x7118); 904 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061e000000000000000000000000000000"); 905 fprintf(fp, "MessageContent2=%s\n", "5553424312345679000000000000061b000000020000000000000000000000"); 906 fprintf(fp, "NoDriverLoading=1\n"); 907 break; 908 case SN_AirPlus_MCD_800: 909 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1edf); 910 fprintf(fp, "DefaultProduct=0x%04x\n", 0x6003); 911 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 912 fprintf(fp, "Configuration=%d\n", 3); 913 break; 914 case SN_UMW190: 915 fprintf(fp, "DefaultVendor=0x%04x\n", 0x106c); 916 fprintf(fp, "DefaultProduct=0x%04x\n", 0x3b05); 917 fprintf(fp, "TargetVendor=0x%04x\n", 0x106c); 918 fprintf(fp, "TargetProduct=0x%04x\n", 0x3716); 919 fprintf(fp, "MessageContent=%s\n", "555342431234567824000000800008ff020000000000000000000000000000"); 920 break; 921 case SN_LG_AD600: 922 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1004); 923 fprintf(fp, "DefaultProduct=0x%04x\n", 0x6190); 924 fprintf(fp, "TargetVendor=0x%04x\n", 0x1004); 925 fprintf(fp, "TargetProduct=0x%04x\n", 0x61a7); 926 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 927 break; 928 case SN_GW_D301: 929 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0fd1); 930 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1000); 931 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 932 fprintf(fp, "Configuration=%d\n", 3); 933 break; 934 case SN_Qtronix_EVDO_3G: 935 fprintf(fp, "DefaultVendor=0x%04x\n", 0x05c7); 936 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1000); 937 fprintf(fp, "TargetVendor=0x%04x\n", 0x05c7); 938 fprintf(fp, "TargetProduct=0x%04x\n", 0x6000); 939 fprintf(fp, "MessageContent=%s\n", "5553424312345678c00000008000069f140000000000000000000000000000"); 940 break; 941 case SN_Huawei_EC168C: 942 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 943 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1446); 944 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 945 fprintf(fp, "TargetProduct=0x%04x\n", 0x1412); 946 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011060000000000000000000000000000"); 947 break; 948 case SN_Olicard_145: 949 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0b3c); 950 fprintf(fp, "DefaultProduct=0x%04x\n", 0xf000); 951 fprintf(fp, "TargetVendor=0x%04x\n", 0x0b3c); 952 fprintf(fp, "TargetProduct=0x%04x\n", 0xc003); 953 fprintf(fp, "MessageContent=%s\n", "5553424312345678c000000080010606f50402527000000000000000000000"); 954 fprintf(fp, "NeedResponse=1\n"); 955 break; 956 case SN_ONDA_MW833UP: 957 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1ee8); 958 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0009); 959 fprintf(fp, "TargetVendor=0x%04x\n", 0x1ee8); 960 fprintf(fp, "TargetProduct=0x%04x\n", 0x000b); 961 fprintf(fp, "MessageContent=%s\n", "555342431234567800000000000010ff000000000000000000000000000000"); 962 fprintf(fp, "NeedResponse=1\n"); 963 break; 964 case SN_Kobil_mIdentity_3G_2: 965 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0d46); 966 fprintf(fp, "DefaultProduct=0x%04x\n", 0x45a5); 967 fprintf(fp, "TargetVendor=0x%04x\n", 0x0d46); 968 fprintf(fp, "TargetProduct=0x%04x\n", 0x45ad); 969 fprintf(fp, "KobilMode=1\n"); 970 break; 971 case SN_Kobil_mIdentity_3G_1: 972 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0d46); 973 fprintf(fp, "DefaultProduct=0x%04x\n", 0x45a1); 974 fprintf(fp, "TargetVendor=0x%04x\n", 0x0d46); 975 fprintf(fp, "TargetProduct=0x%04x\n", 0x45a9); 976 fprintf(fp, "KobilMode=1\n"); 977 break; 978 case SN_Samsung_GT_B3730: 979 fprintf(fp, "DefaultVendor=0x%04x\n", 0x04e8); 980 fprintf(fp, "DefaultProduct=0x%04x\n", 0x689a); 981 fprintf(fp, "TargetVendor=0x%04x\n", 0x04e8); 982 fprintf(fp, "TargetProduct=0x%04x\n", 0x6889); 983 fprintf(fp, "MessageContent=%s\n", "55534243785634120100000080000601000000000000000000000000000000"); 984 break; 985 case SN_BSNL_Capitel: 986 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1c9e); 987 fprintf(fp, "DefaultProduct=0x%04x\n", 0x9e00); 988 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 989 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000606f50402527000000000000000000000"); 990 break; 991 case SN_Huawei_U8110: 992 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 993 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1031); 994 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 995 fprintf(fp, "TargetProduct=0x%04x\n", 0x1035); 996 fprintf(fp, "CheckSuccess=%d\n", 20); 997 fprintf(fp, "MessageContent=%s\n", "55534243123456780600000080010a11060000000000000000000000000000"); 998 fprintf(fp, "NoDriverLoading=1\n"); 999 break; 1000 case SN_ONDA_MW833UP_2: 1001 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1ee8); 1002 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0013); 1003 fprintf(fp, "TargetVendor=0x%04x\n", 0x1ee8); 1004 fprintf(fp, "TargetProduct=0x%04x\n", 0x0012); 1005 fprintf(fp, "CheckSuccess=%d\n", 20); 1006 fprintf(fp, "MessageContent=%s\n", "555342431234567800000000000010ff000000000000000000000000000000"); 1007 /* fprintf(fp, "NeedResponse=1\n"); // was ResponseNeeded=1 */ 1008 break; 1009 case SN_Netgear_WNDA3200: 1010 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0cf3); 1011 fprintf(fp, "DefaultProduct=0x%04x\n", 0x20ff); 1012 fprintf(fp, "TargetVendor=0x%04x\n", 0x0cf3); 1013 fprintf(fp, "TargetProduct=0x%04x\n", 0x7010); 1014 fprintf(fp, "CheckSuccess=%d\n", 10); 1015 fprintf(fp, "NoDriverLoading=1\n"); 1016 fprintf(fp, "MessageContent=%s\n", "5553424329000000000000000000061b000000020000000000000000000000"); 1017 fprintf(fp, "NeedResponse=1\n"); 1018 break; 1019 case SN_Huawei_R201: 1020 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 1021 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1523); 1022 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 1023 fprintf(fp, "TargetProduct=0x%04x\n", 0x1491); 1024 fprintf(fp, "CheckSuccess=%d\n", 20); 1025 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011060000000000000000000000000000"); 1026 break; 1027 case SN_Huawei_K4605: 1028 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 1029 fprintf(fp, "DefaultProduct=0x%04x\n", 0x14c1); 1030 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 1031 fprintf(fp, "TargetProduct=0x%04x\n", 0x14c6); 1032 fprintf(fp, "CheckSuccess=%d\n", 20); 1033 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011060000000000000000000000000000"); 1034 break; 1035 case SN_LG_LUU_2100TI: 1036 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1004); 1037 fprintf(fp, "DefaultProduct=0x%04x\n", 0x613f); 1038 fprintf(fp, "TargetVendor=0x%04x\n", 0x1004); 1039 fprintf(fp, "TargetProduct=0x%04x\n", 0x6141); 1040 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1041 fprintf(fp, "NeedResponse=1\n"); 1042 break; 1043 case SN_LG_L_05A: 1044 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1004); 1045 fprintf(fp, "DefaultProduct=0x%04x\n", 0x613a); 1046 fprintf(fp, "TargetVendor=0x%04x\n", 0x1004); 1047 fprintf(fp, "TargetProduct=0x%04x\n", 0x6124); 1048 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1049 fprintf(fp, "NeedResponse=1\n"); 1050 break; 1051 case SN_ZTE_MU351: 1052 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 1053 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0003); 1054 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 1055 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1056 fprintf(fp, "NeedResponse=1\n"); 1057 break; 1058 case SN_ZTE_MF110_var: 1059 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 1060 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0083); 1061 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 1062 fprintf(fp, "TargetProduct=0x%04x\n", 0x0124); 1063 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1064 fprintf(fp, "NeedResponse=1\n"); 1065 break; 1066 case SN_Olicard_100: 1067 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0b3c); 1068 fprintf(fp, "DefaultProduct=0x%04x\n", 0xc700); 1069 fprintf(fp, "TargetVendor=0x%04x\n", 0x0b3c); 1070 fprintf(fp, "TargetProductList=%s\n", "c000,c001,c002"); 1071 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000030000000000000000000000"); 1072 fprintf(fp, "NeedResponse=1\n"); 1073 break; 1074 case SN_ZTE_MF112: 1075 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 1076 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0103); 1077 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 1078 fprintf(fp, "TargetProduct=0x%04x\n", 0x0031); 1079 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1080 fprintf(fp, "MessageContent2=%s\n", "55534243876543212000000080000c85010101180101010101000000000000"); 1081 fprintf(fp, "NeedResponse=1\n"); 1082 break; 1083 case SN_Franklin_Wireless_U210: 1084 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1fac); 1085 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0130); 1086 fprintf(fp, "TargetVendor=0x%04x\n", 0x1fac); 1087 fprintf(fp, "TargetProduct=0x%04x\n", 0x0131); 1088 fprintf(fp, "CheckSuccess=%d\n", 20); 1089 fprintf(fp, "MessageContent=%s\n", "555342431234567824000000800108df200000000000000000000000000000"); 1090 break; 1091 case SN_ZTE_K3805_Z: 1092 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 1093 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1001); 1094 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 1095 fprintf(fp, "TargetProduct=0x%04x\n", 0x1003); 1096 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1097 fprintf(fp, "NeedResponse=1\n"); 1098 break; 1099 case SN_SE_MD300: 1100 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0fce); 1101 fprintf(fp, "DefaultProduct=0x%04x\n", 0xd0cf); 1102 fprintf(fp, "TargetClass=0x%02x\n", 0x02); 1103 fprintf(fp, "Configuration=%d\n", 3); 1104 fprintf(fp, "DetachStorageOnly=1\n"); 1105 break; 1106 case SN_Digicom_8E4455: 1107 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1266); 1108 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1000); 1109 fprintf(fp, "TargetVendor=0x%04x\n", 0x1266); 1110 fprintf(fp, "TargetProduct=0x%04x\n", 0x1009); 1111 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061e000000000000000000000000000000"); 1112 fprintf(fp, "MessageContent2=%s\n", "5553424387654321000000000000061b000000020000000000000000000000"); 1113 fprintf(fp, "NeedResponse=1\n"); 1114 break; 1115 case SN_Kyocera_W06K: 1116 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0482); 1117 fprintf(fp, "DefaultProduct=0x%04x\n", 0x024d); 1118 fprintf(fp, "Configuration=%d\n", 2); 1119 break; 1120 case SN_LG_HDM_2100: 1121 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1004); 1122 fprintf(fp, "DefaultProduct=0x%04x\n", 0x607f); 1123 fprintf(fp, "TargetVendor=0x%04x\n", 0x1004); 1124 fprintf(fp, "TargetProduct=0x%04x\n", 0x6114); 1125 fprintf(fp, "MessageContent=%s\n", "1201100102000040041014610000010200018006000100001200"); 1126 break; 1127 case SN_Beceem_BCSM250: 1128 fprintf(fp, "DefaultVendor=0x%04x\n", 0x198f); 1129 fprintf(fp, "DefaultProduct=0x%04x\n", 0xbccd); 1130 fprintf(fp, "TargetVendor=0x%04x\n", 0x198f); 1131 fprintf(fp, "TargetProduct=0x%04x\n", 0x0220); 1132 fprintf(fp, "MessageContent=%s\n", "555342431234567824000000800006bc626563240000000000000000000000"); 1133 break; 1134 case SN_Beceem_BCSM250_ASUS: 1135 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0b05); 1136 fprintf(fp, "DefaultProduct=0x%04x\n", 0xbccd); 1137 fprintf(fp, "TargetVendor=0x%04x\n", 0x0b05); 1138 fprintf(fp, "TargetProduct=0x%04x\n", 0x1781); 1139 fprintf(fp, "MessageContent=%s\n", "555342431234567824000000800006bc626563240000000000000000000000"); 1140 break; 1141 case SN_ZTEAX226: 1142 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 1143 fprintf(fp, "DefaultProduct=0x%04x\n", 0xbccd); 1144 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 1145 fprintf(fp, "TargetProduct=0x%04x\n", 0x0172); 1146 fprintf(fp, "MessageContent=%s\n", "555342431234567824000000800006bc626563240000000000000000000000"); 1147 /* fprintf(fp, "NoDriverLoading=1\n");*/ 1148 break; 1149 case SN_Huawei_U7510: 1150 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 1151 fprintf(fp, "DefaultProduct=0x%04x\n", 0x101e); 1152 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 1153 fprintf(fp, "MessageContent=%s\n", "55534243123456780600000080000601000000000000000000000000000000"); 1154 break; 1155 case SN_ZTE_AC581: 1156 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 1157 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0026); 1158 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 1159 fprintf(fp, "TargetProduct=0x%04x\n", 0x0094); 1160 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061e000000000000000000000000000000"); 1161 fprintf(fp, "MessageContent2=%s\n", "5553424312345679000000000000061b000000020000000000000000000000"); 1162 fprintf(fp, "NeedResponse=1\n"); 1163 break; 1164 case SN_UTStarcom_UM185E: 1165 fprintf(fp, "DefaultVendor=0x%04x\n", 0x106c); 1166 fprintf(fp, "DefaultProduct=0x%04x\n", 0x3b06); 1167 fprintf(fp, "TargetVendor=0x%04x\n", 0x106c); 1168 fprintf(fp, "TargetProduct=0x%04x\n", 0x3717); 1169 fprintf(fp, "MessageContent=%s\n", "555342431234567824000000800008ff020000000000000000000000000000"); 1170 break; 1171 case SN_AVM_Fritz: 1172 fprintf(fp, "DefaultVendor=0x%04x\n", 0x057c); 1173 fprintf(fp, "DefaultProduct=0x%04x\n", 0x84ff); 1174 fprintf(fp, "TargetVendor=0x%04x\n", 0x057c); 1175 fprintf(fp, "TargetProduct=0x%04x\n", 0x8401); 1176 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000ff0000000000000000000000"); 1177 break; 1178 /* 0818 add */ 1179 case SN_SU_8000U: 1180 fprintf(fp, "DefaultVendor=0x%04x\n", 0x2020); 1181 fprintf(fp, "DefaultProduct=0x%04x\n", 0xf00e); 1182 fprintf(fp, "TargetVendor=0x%04x\n", 0x2020); 1183 fprintf(fp, "TargetProduct=0x%04x\n", 0x1005); 1184 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1185 break; 1186 case SN_Cisco_AM10: 1187 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1307); 1188 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1169); 1189 fprintf(fp, "TargetVendor=0x%04x\n", 0x13b1); 1190 fprintf(fp, "TargetProduct=0x%04x\n", 0x0031); 1191 fprintf(fp, "CiscoMode=1\n"); 1192 break; 1193 case SN_Huawei_EC122: 1194 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 1195 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1446); 1196 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 1197 fprintf(fp, "TargetProduct=0x%04x\n", 0x140c); 1198 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011060000000000000000000000000000"); 1199 break; 1200 case SN_Huawei_EC1262: 1201 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 1202 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1446); 1203 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 1204 fprintf(fp, "TargetProduct= \"1001,1406,140b,140c,1412,141b,14ac\"\n"); 1205 fprintf(fp, "CheckSuccess=%d\n", 20); 1206 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011062000000100000000000000000000"); 1207 break; 1208 case SN_Huawei_EC306: 1209 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 1210 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1505); 1211 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 1212 fprintf(fp, "TargetProduct=0x%04x\n", 0x1506); 1213 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011062000000100000000000000000000"); 1214 break; 1215 case SN_Sierra_U598: 1216 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1199); 1217 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0fff); 1218 fprintf(fp, "TargetVendor=0x%04x\n", 0x1199); 1219 fprintf(fp, "TargetProduct=0x%04x\n", 0x0025); 1220 fprintf(fp, "SierraMode=1\n"); 1221 break; 1222 case SN_NovatelU720: 1223 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1410); 1224 fprintf(fp, "DefaultProduct=0x%04x\n", 0x2110); 1225 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1226 fprintf(fp, "CheckSuccess=%d\n", 20); // tmp test 1227 fprintf(fp, "NeedResponse=1\n"); 1228 break; 1229 case SN_Pantech_UM150: // tmp test 1230 fprintf(fp, "DefaultVendor=0x%04x\n", 0x106c); 1231 fprintf(fp, "DefaultProduct=0x%04x\n", 0x3711); 1232 fprintf(fp, "MessageContent=%s\n", "555342431234567824000000800008ff024445564348470000000000000000"); 1233 break; 1234 case SN_Pantech_UM175: // tmp test 1235 fprintf(fp, "DefaultVendor=0x%04x\n", 0x106c); 1236 fprintf(fp, "DefaultProduct=0x%04x\n", 0x3714); 1237 fprintf(fp, "MessageContent=%s\n", "555342431234567824000000800008ff024445564348470000000000000000"); 1238 break; 1239 case SN_Sierra_U595: 1240 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1199); 1241 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0120); 1242 fprintf(fp, "CheckSuccess=%d\n", 10); // tmp test 1243 fprintf(fp, "SierraMode=1\n"); 1244 fprintf(fp, "NoDriverLoading=1\n"); 1245 break; 1246 /* 120703 add */ 1247 case SN_Qisda_H21: 1248 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1da5); 1249 fprintf(fp, "DefaultProduct=0x%04x\n", 0xf000); 1250 fprintf(fp, "TargetVendor=0x%04x\n", 0x1da5); 1251 fprintf(fp, "TargetProduct=0x%04x\n", 0x4512); 1252 fprintf(fp, "QisdaMode=1\n"); 1253 break; 1254 case SN_StrongRising_Air_FlexiNet: 1255 fprintf(fp, "DefaultVendor=0x%04x\n", 0x21f5); 1256 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1000); 1257 fprintf(fp, "TargetVendor=0x%04x\n", 0x21f5); 1258 fprintf(fp, "TargetProduct=0x%04x\n", 0x2008); 1259 fprintf(fp, "MessageContent=%s\n", "5553424312345678c000000080000671010000000000000000000000000000"); 1260 break; 1261 case SN_BandLuxe_C339: 1262 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1a8d); 1263 fprintf(fp, "DefaultProduct=0x%04x\n", 0x2000); 1264 fprintf(fp, "TargetVendor=0x%04x\n", 0x1a8d); 1265 fprintf(fp, "TargetProduct=0x%04x\n", 0x2006); 1266 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061e000000000000000000000000000000"); 1267 fprintf(fp, "MessageContent2=%s\n", "5553424312345679000000000000061b000000020000000000000000000000"); 1268 fprintf(fp, "NeedResponse=1\n"); 1269 break; 1270 case SN_Celot_CT680: 1271 fprintf(fp, "DefaultVendor=0x%04x\n", 0x05c6); 1272 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1000); 1273 fprintf(fp, "TargetVendor=0x%04x\n", 0x211f); 1274 fprintf(fp, "TargetProduct=0x%04x\n", 0x6802); 1275 fprintf(fp, "MessageContent=%s\n", "5553424312345678c000000080000671010000000000000000000000000000"); 1276 break; 1277 case SN_Huawei_E353: 1278 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 1279 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1f01); 1280 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 1281 fprintf(fp, "TargetProduct=0x%04x\n", 0x14db); 1282 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000a11062000000000000100000000000000"); 1283 fprintf(fp, "NoDriverLoading=1\n"); 1284 break; 1285 case SN_Haier_CE682: 1286 fprintf(fp, "DefaultVendor=0x%04x\n", 0x201e); 1287 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1023); 1288 fprintf(fp, "TargetVendor=0x%04x\n", 0x201e); 1289 fprintf(fp, "TargetProduct=0x%04x\n", 0x1022); 1290 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000600000000000000000000000000000000"); 1291 fprintf(fp, "MessageContent2=%s\n", "5553424312345679c000000080000671030000000000000000000000000000"); 1292 fprintf(fp, "NeedResponse=1\n"); 1293 break; 1294 case SN_LG_L_02C_LTE: 1295 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1004); 1296 fprintf(fp, "DefaultProduct=0x%04x\n", 0x61dd); 1297 fprintf(fp, "TargetVendor=0x%04x\n", 0x1004); 1298 fprintf(fp, "TargetProduct=0x%04x\n", 0x618f); 1299 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1300 fprintf(fp, "NeedResponse=1\n"); 1301 break; 1302 case SN_LG_SD711: 1303 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1004); 1304 fprintf(fp, "DefaultProduct=0x%04x\n", 0x61e7); 1305 fprintf(fp, "TargetVendor=0x%04x\n", 0x1004); 1306 fprintf(fp, "TargetProduct=0x%04x\n", 0x61e6); 1307 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1308 break; 1309 case SN_LG_L_08C: 1310 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1004); 1311 fprintf(fp, "DefaultProduct=0x%04x\n", 0x61eb); 1312 fprintf(fp, "TargetVendor=0x%04x\n", 0x1004); 1313 fprintf(fp, "TargetProduct=0x%04x\n", 0x61ea); 1314 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1315 fprintf(fp, "NeedResponse=1\n"); 1316 break; 1317 case SN_IODATA_WMX2_U: 1318 fprintf(fp, "DefaultVendor=0x%04x\n", 0x04bb); 1319 fprintf(fp, "DefaultProduct=0x%04x\n", 0xbccd); 1320 fprintf(fp, "TargetVendor=0x%04x\n", 0x04bb); 1321 fprintf(fp, "TargetProduct=0x%04x\n", 0x0949); 1322 fprintf(fp, "MessageContent=%s\n", "55534243f0298d8124000000800006bc626563240000000000000000000000"); 1323 break; 1324 case SN_Option_GI1515: 1325 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0af0); 1326 fprintf(fp, "DefaultProduct=0x%04x\n", 0xd001); 1327 fprintf(fp, "TargetVendor=0x%04x\n", 0x0af0); 1328 fprintf(fp, "TargetProduct=0x%04x\n", 0xd157); 1329 fprintf(fp, "MessageContent=%s\n", "55534243785634120100000080000601000000000000000000000000000000"); 1330 break; 1331 case SN_LG_L_07A: 1332 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1004); 1333 fprintf(fp, "DefaultProduct=0x%04x\n", 0x614e); 1334 fprintf(fp, "TargetVendor=0x%04x\n", 0x1004); 1335 fprintf(fp, "TargetProduct=0x%04x\n", 0x6135); 1336 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061e000000000000000000000000000000"); 1337 fprintf(fp, "MessageContent2=%s\n", "5553424312345679000000000000061b000000020000000000000000000000"); 1338 fprintf(fp, "NeedResponse=1\n"); 1339 break; 1340 case SN_ZTE_A371B: 1341 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 1342 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0169); 1343 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 1344 fprintf(fp, "TargetProduct=0x%04x\n", 0x0170); 1345 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1346 fprintf(fp, "NeedResponse=1\n"); 1347 break; 1348 case SN_ZTE_MF652: 1349 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 1350 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1520); 1351 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 1352 fprintf(fp, "TargetProduct=0x%04x\n", 0x0142); 1353 fprintf(fp, "MessageContent=%s\n", "5553424312345679000000000000061b000000020000000000000000000000"); 1354 fprintf(fp, "NeedResponse=1\n"); 1355 break; 1356 case SN_ZTE_MF652_VAR: 1357 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 1358 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0146); 1359 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 1360 fprintf(fp, "TargetProduct=0x%04x\n", 0x0143); 1361 fprintf(fp, "MessageContent=%s\n", "5553424312345679000000000000061b000000020000000000000000000000"); 1362 fprintf(fp, "NeedResponse=1\n"); 1363 break; 1364 case SN_T_W_WU160: 1365 fprintf(fp, "DefaultVendor=0x%04x\n", 0x2077); 1366 fprintf(fp, "DefaultProduct=0x%04x\n", 0xf000); 1367 fprintf(fp, "TargetVendor=0x%04x\n", 0x2077); 1368 fprintf(fp, "TargetProduct=0x%04x\n", 0x9000); 1369 fprintf(fp, "MessageContent=%s\n", "5553424308902082000000000000061b000000020000000000000000000000"); 1370 break; 1371 case SN_Nokia_CS_21M_02: 1372 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0421); 1373 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0637); 1374 fprintf(fp, "TargetVendor=0x%04x\n", 0x0421); 1375 fprintf(fp, "TargetProduct=0x%04x\n", 0x0638); 1376 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1377 break; 1378 case SN_Telewell_TW_3G: 1379 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1c9e); 1380 fprintf(fp, "DefaultProduct=0x%04x\n", 0x98ff); 1381 fprintf(fp, "TargetVendor=0x%04x\n", 0x1c9e); 1382 fprintf(fp, "TargetProduct=0x%04x\n", 0x9801); 1383 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000080000606f50402527000000000000000000000"); 1384 break; 1385 case SN_ZTE_MF637_2: 1386 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 1387 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0031); 1388 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 1389 fprintf(fp, "TargetProduct=0x%04x\n", 0x0094); 1390 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1391 fprintf(fp, "NeedResponse=1\n"); 1392 break; 1393 case SN_Samsung_GT_B1110: 1394 fprintf(fp, "DefaultVendor=0x%04x\n", 0x04e8); 1395 fprintf(fp, "DefaultProduct=0x%04x\n", 0x680c); 1396 fprintf(fp, "TargetVendor=0x%04x\n", 0x04e8); 1397 fprintf(fp, "TargetProduct=0x%04x\n", 0x6792); 1398 fprintf(fp, "MessageContent=%s\n", "0902200001010080fa0904000002080650000705010200020007058102000200"); 1399 break; 1400 case SN_ZTE_MF192_VAR: 1401 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 1402 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1514); 1403 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 1404 fprintf(fp, "TargetProduct=0x%04x\n", 0x1515); 1405 fprintf(fp, "MessageContent=%s\n", "5553424348c4758600000000000010ff000000000000000000000000000000"); 1406 break; 1407 case SN_MediaTek_MT6276M: 1408 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0e8d); 1409 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0002); 1410 fprintf(fp, "TargetVendor=0x%04x\n", 0x0e8d); 1411 fprintf(fp, "TargetProductList=%s\n", "00a1,00a2"); 1412 fprintf(fp, "MessageContent=%s\n", "555342431234567800000000000006f0010300000000000000000000000000"); 1413 break; 1414 case SN_Tata_Photon_plus: 1415 fprintf(fp, "DefaultVendor=0x%04x\n", 0x22f4); 1416 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0021); 1417 fprintf(fp, "TargetClass=0x%02x\n", 0xff); 1418 fprintf(fp, "MessageContent=%s\n", "555342439f000000000000000000061b000000020000000000000000000000"); 1419 break; 1420 case SN_Option_Globetrotter: 1421 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0af0); 1422 fprintf(fp, "DefaultProduct=0x%04x\n", 0x8006); 1423 fprintf(fp, "TargetVendor=0x%04x\n", 0x0af0); 1424 fprintf(fp, "TargetProduct=0x%04x\n", 0x9100); 1425 fprintf(fp, "MessageContent=%s\n", "55534243785634120100000080000601000000000000000000000000000000"); 1426 break; 1427 case SN_Option_ICON_711: 1428 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0af0); 1429 fprintf(fp, "DefaultProduct=0x%04x\n", 0x4007); 1430 fprintf(fp, "TargetVendor=0x%04x\n", 0x0af0); 1431 fprintf(fp, "TargetProduct=0x%04x\n", 0x4005); 1432 fprintf(fp, "SierraMode=1\n"); 1433 break; 1434 case SN_Celot_K300: 1435 fprintf(fp, "DefaultVendor=0x%04x\n", 0x05c6); 1436 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1000); 1437 fprintf(fp, "TargetVendor=0x%04x\n", 0x211f); 1438 fprintf(fp, "TargetProduct=0x%04x\n", 0x6801); 1439 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1440 break; 1441 case SN_HISENSE_E910: 1442 fprintf(fp, "DefaultVendor=0x%04x\n", 0x109b); 1443 fprintf(fp, "DefaultProduct=0x%04x\n", 0xf009); 1444 fprintf(fp, "TargetVendor=0x%04x\n", 0x109b); 1445 fprintf(fp, "TargetProduct=0x%04x\n", 0x9114); 1446 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1447 fprintf(fp, "NeedResponse=1\n"); 1448 break; 1449 case SN_Huawei_K5005: 1450 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 1451 fprintf(fp, "DefaultProduct=0x%04x\n", 0x14c3); 1452 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 1453 fprintf(fp, "TargetProduct=0x%04x\n", 0x14c8); 1454 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011062000000100000000000000000000"); 1455 break; 1456 case SN_Huawei_E173_MoiveStar: 1457 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 1458 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1c24); 1459 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 1460 fprintf(fp, "TargetProduct=0x%04x\n", 0x1c12); 1461 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011062000000100000000000000000000"); 1462 break; 1463 case SN_Onda_MSA14_4: 1464 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1ee8); 1465 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0060); 1466 fprintf(fp, "TargetVendor=0x%04x\n", 0x1ee8); 1467 fprintf(fp, "TargetProduct=0x%04x\n", 0x005f); 1468 fprintf(fp, "MessageContent=%s\n", "555342431234567800000000000008ff00000000000003000000000000000"); 1469 break; 1470 case SN_WeTelecom_WMD300: 1471 fprintf(fp, "DefaultVendor=0x%04x\n", 0x22de); 1472 fprintf(fp, "DefaultProduct=0x%04x\n", 0x6803); 1473 fprintf(fp, "TargetVendor=0x%04x\n", 0x22de); 1474 fprintf(fp, "TargetProduct=0x%04x\n", 0x6801); 1475#if 0 1476 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061e000000000000000000000000000000"); 1477 fprintf(fp, "MessageContent2=%s\n", "5553424312345679000000000000061b000000020000000000000000000000"); 1478#else 1479 fprintf(fp, "StandardEject=1\n"); 1480#endif 1481 break; 1482 case SN_Huawei_K5150: 1483 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 1484 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1f16); 1485#if 1 1486 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 1487 fprintf(fp, "TargetProductList=%s\n", "14f8,1575"); 1488 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011062000000101000100000000000000"); 1489#else 1490 fprintf(fp, "Configuration=2\n"); 1491#endif 1492 break; 1493 case SN_ZTE_MF823: 1494 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 1495 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1225); 1496 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 1497 fprintf(fp, "TargetProduct=0x%04x\n", 0x1405); 1498 fprintf(fp, "StandardEject=1\n"); 1499 break; 1500 /* 141112 */ 1501 case SN_Alcatel_TL131: 1502 fprintf(fp, "DefaultVendor=0x%04x\n", 0x05c6); 1503 fprintf(fp, "DefaultProduct=0x%04x\n", 0x9024); 1504 fprintf(fp, "TargetVendor=0x%04x\n", 0x05c6); 1505 fprintf(fp, "TargetProduct=0x%04x\n", 0x9025); 1506 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1507 break; 1508 case SN_AVM_Fritz_V2: 1509 fprintf(fp, "DefaultVendor=0x%04x\n", 0x057c); 1510 fprintf(fp, "DefaultProduct=0x%04x\n", 0x62ff); 1511 fprintf(fp, "TargetVendor=0x%04x\n", 0x057c); 1512 fprintf(fp, "TargetProduct=0x%04x\n", 0x8501); 1513 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000ff0000000000000000000000"); 1514 break; 1515 case SN_Quanta_MobileGenie_4G_lte: 1516 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0408); 1517 fprintf(fp, "DefaultProduct=0x%04x\n", 0xea43); 1518 fprintf(fp, "TargetVendor=0x%04x\n", 0x0408); 1519 fprintf(fp, "TargetProduct=0x%04x\n", 0xea47); 1520 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1521 break; 1522 case SN_Pantech_LTE: 1523 fprintf(fp, "DefaultVendor=0x%04x\n", 0x10a9); 1524 fprintf(fp, "DefaultProduct=0x%04x\n", 0x6080); 1525 fprintf(fp, "TargetVendor=0x%04x\n", 0x10a9); 1526 fprintf(fp, "TargetProduct=0x%04x\n", 0x6085); 1527 fprintf(fp, "PantechMode=1\n"); 1528 break; 1529 case SN_BlackBerry_Q10: 1530 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0fca); 1531 fprintf(fp, "DefaultProduct=0x%04x\n", 0x8020); 1532 fprintf(fp, "TargetVendor=0x%04x\n", 0x0fca); 1533 fprintf(fp, "TargetProduct=0x%04x\n", 0x8012); 1534 fprintf(fp, "BlackberryMode=1\n"); 1535 break; 1536 case SN_Huawei_K4305: 1537 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 1538 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1f15); 1539 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 1540 fprintf(fp, "TargetProduct=0x%04x\n", 0x1400); 1541 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011062000000000000100000000000000"); 1542 break; 1543 case SN_Huawei_E3276s: 1544 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 1545 fprintf(fp, "DefaultProduct=0x%04x\n", 0x156a); 1546 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 1547 fprintf(fp, "TargetProductList=%s\n", "156b,156c"); 1548 fprintf(fp, "MessageContent=%s\n", "55534243123456780000000000000011062000000100000000000000000000"); 1549 break; 1550 case SN_Huawei_E3131: 1551 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 1552 fprintf(fp, "DefaultProduct=0x%04x\n", 0x155b); 1553 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 1554 fprintf(fp, "TargetProduct=0x%04x\n", 0x1506); 1555 fprintf(fp, "MessageContent=%s\n", "55534243000000000000000000000011060000000100000000000000000000"); 1556 break; 1557 case SN_Huawei_E3372: 1558 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 1559 fprintf(fp, "DefaultProduct=0x%04x\n", 0x157d); 1560 fprintf(fp, "TargetVendor=0x%04x\n", 0x12d1); 1561 fprintf(fp, "TargetProductList=%s\n", "14db,14dc"); 1562 fprintf(fp, "HuaweiNewMode=1\n"); 1563 break; 1564 case SN_Huawei_E303u: 1565 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 1566 fprintf(fp, "DefaultProduct=0x%04x\n", 0x15ca); 1567 fprintf(fp, "HuaweiNewMode=1\n"); 1568 break; 1569 case SN_Huawei_E3531s: 1570 fprintf(fp, "DefaultVendor=0x%04x\n", 0x12d1); 1571 fprintf(fp, "DefaultProduct=0x%04x\n", 0x15cd); 1572 fprintf(fp, "HuaweiNewMode=1\n"); 1573 break; 1574 case SN_Teracom_LW272: 1575 fprintf(fp, "DefaultVendor=0x%04x\n", 0x230d); 1576 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0103); 1577 fprintf(fp, "Configuration=2\n"); 1578 break; 1579 case SN_TP_Link_MA260: 1580 fprintf(fp, "DefaultVendor=0x%04x\n", 0x2357); 1581 fprintf(fp, "DefaultProduct=0x%04x\n", 0xf000); 1582 fprintf(fp, "TargetVendor=0x%04x\n", 0x2357); 1583 fprintf(fp, "TargetProduct=0x%04x\n", 0x9000); 1584 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1585 break; 1586 case SN_Quanta_1K3_LTE: 1587 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0408); 1588 fprintf(fp, "DefaultProduct=0x%04x\n", 0xea25); 1589 fprintf(fp, "TargetVendor=0x%04x\n", 0x0408); 1590 fprintf(fp, "TargetProduct=0x%04x\n", 0xea26); 1591 fprintf(fp, "QuantaMode=1\n"); 1592 break; 1593 case SN_WeTelecom_WMD200: 1594 fprintf(fp, "DefaultVendor=0x%04x\n", 0x22de); 1595 fprintf(fp, "DefaultProduct=0x%04x\n", 0x6801); 1596 fprintf(fp, "TargetClass=0x%04x\n", 0xff); 1597 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061e000000000000000000000000000000"); 1598 fprintf(fp, "MessageContent2=%s\n", "5553424312345679000000000000061b000000020000000000000000000000"); 1599 break; 1600 case SN_ZTE_MF680: 1601 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 1602 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1227); 1603 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 1604 fprintf(fp, "TargetProduct=0x%04x\n", 0x1252); 1605 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1606 fprintf(fp, "NeedResponse=1\n"); 1607 break; 1608 case SN_ZTE_MF656A: 1609 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 1610 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0150); 1611 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 1612 fprintf(fp, "TargetProduct=0x%04x\n", 0x0124); 1613 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1614 fprintf(fp, "NeedResponse=1\n"); 1615 break; 1616 case SN_ZTE_MF196: 1617 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 1618 fprintf(fp, "DefaultProduct=0x%04x\n", 0x1528); 1619 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 1620 fprintf(fp, "TargetProduct=0x%04x\n", 0x1527); 1621 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1622 fprintf(fp, "NeedResponse=1\n"); 1623 break; 1624 case SN_Mediatek_MT6229: 1625 fprintf(fp, "DefaultVendor=0x%04x\n", 0x2020); 1626 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0002); 1627 fprintf(fp, "TargetVendor=0x%04x\n", 0x2020); 1628 fprintf(fp, "TargetProduct=0x%04x\n", 0x2000); 1629 fprintf(fp, "MessageContent=%s\n", "555342430820298900000000000003f0010100000000000000000000000000"); 1630 break; 1631 case SN_DLINK_DWR_510: 1632 fprintf(fp, "DefaultVendor=0x%04x\n", 0x2001); 1633 fprintf(fp, "DefaultProduct=0x%04x\n", 0xa805); 1634 fprintf(fp, "TargetVendor=0x%04x\n", 0x2001); 1635 fprintf(fp, "TargetProduct=0x%04x\n", 0x7e12); 1636 fprintf(fp, "MessageContent=%s\n", "5553424308407086000000000000061b000000020000000000000000000000"); 1637 break; 1638 case SN_Novatel_MC996D: 1639 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1410); 1640 fprintf(fp, "DefaultProduct=0x%04x\n", 0x5023); 1641 fprintf(fp, "TargetVendor=0x%04x\n", 0x1410); 1642 fprintf(fp, "TargetProduct=0x%04x\n", 0x7030); 1643 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1644 break; 1645 case SN_Pantech_UML290: 1646 fprintf(fp, "DefaultVendor=0x%04x\n", 0x106c); 1647 fprintf(fp, "DefaultProduct=0x%04x\n", 0x3b11); 1648 fprintf(fp, "TargetVendor=0x%04x\n", 0x106c); 1649 fprintf(fp, "TargetProduct=0x%04x\n", 0x3718); 1650 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1651 break; 1652 case SN_Onda_MT8205_LTE: 1653 fprintf(fp, "DefaultVendor=0x%04x\n", 0x19d2); 1654 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0266); 1655 fprintf(fp, "TargetVendor=0x%04x\n", 0x19d2); 1656 fprintf(fp, "TargetProduct=0x%04x\n", 0x0265); 1657 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1658 break; 1659 case SN_Axesstel_Modems: 1660 fprintf(fp, "DefaultVendor=0x%04x\n", 0x05c6); 1661 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0010); 1662 fprintf(fp, "TargetVendor=0x%04x\n", 0x05c6); 1663 fprintf(fp, "TargetProduct=0x%04x\n", 0x00a0); 1664 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1665 break; 1666 case SN_Nokia_CS_12: 1667 fprintf(fp, "DefaultVendor=0x%04x\n", 0x0421); 1668 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0618); 1669 fprintf(fp, "TargetVendor=0x%04x\n", 0x0421); 1670 fprintf(fp, "TargetProduct=0x%04x\n", 0x0619); 1671 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1672 break; 1673 case SN_Onda_WM301: 1674 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1ee8); 1675 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0068); 1676 fprintf(fp, "TargetVendor=0x%04x\n", 0x1ee8); 1677 fprintf(fp, "TargetProduct=0x%04x\n", 0x0069); 1678 fprintf(fp, "MessageContent=%s\n", "5553424312345678000000000000061b000000020000000000000000000000"); 1679 break; 1680 case SN_Onda_TM201_14_4: 1681 fprintf(fp, "DefaultVendor=0x%04x\n", 0x1ee8); 1682 fprintf(fp, "DefaultProduct=0x%04x\n", 0x0063); 1683 fprintf(fp, "TargetVendor=0x%04x\n", 0x1ee8); 1684 fprintf(fp, "TargetProduct=0x%04x\n", 0x0064); 1685 fprintf(fp, "MessageContent=%s\n", "555342431234567800000000000008FF000000000000030000000000000000"); 1686 break; 1687 default: 1688 fprintf(fp, "\n"); 1689 if(vid != 0 && pid != 0){ 1690 fprintf(fp, "DefaultVendor=0x%04x\n", vid); 1691 fprintf(fp, "DefaultProduct=0x%04x\n", pid); 1692 if(vid == 0x12d1){ // Huawei 1693 fprintf(fp, "HuaweiMode=1\n"); 1694 } 1695 } 1696 break; 1697 } 1698 1699 return 0; 1700} 1701 1702int init_3g_param(const char *port_path, const unsigned int vid, const unsigned int pid) 1703{ 1704 FILE *fp; 1705 char conf_file[32]; 1706 char dongle_name[32]; 1707 int asus_extra_auto = 0; 1708 1709 memset(conf_file, 0, 32); 1710 sprintf(conf_file, "%s.%s", USB_MODESWITCH_CONF, port_path); 1711 if((fp = fopen(conf_file, "r")) != NULL){ 1712 fclose(fp); 1713 usb_dbg("%04x:%04x Already had the usb_modeswitch file.\n", vid, pid); 1714#ifdef LINUX30 1715 return 0; 1716#else 1717 return 1; 1718#endif 1719 } 1720 1721 fp = fopen(conf_file, "w+"); 1722 if(!fp){ 1723 usb_dbg("Couldn't write the config file(%s).\n", conf_file); 1724 return 0; 1725 } 1726 1727 memset(dongle_name, 0, 32); 1728 strncpy(dongle_name, nvram_safe_get("Dev3G"), 32); 1729 1730 if(!strcmp(dongle_name, "Huawei-E160G") 1731 || !strcmp(dongle_name, "Huawei-E176") 1732 || !strcmp(dongle_name, "Huawei-K3520") 1733 || !strcmp(dongle_name, "Huawei-ET128") 1734 || !strcmp(dongle_name, "Huawei-E1800") 1735 || !strcmp(dongle_name, "Huawei-E172") 1736 || !strcmp(dongle_name, "Huawei-E372") 1737 || !strcmp(dongle_name, "Huawei-E122") 1738 || !strcmp(dongle_name, "Huawei-E160E") 1739 || !strcmp(dongle_name, "Huawei-E1552") 1740 || !strcmp(dongle_name, "Huawei-E1823") 1741 || !strcmp(dongle_name, "Huawei-E1762") 1742 || !strcmp(dongle_name, "Huawei-E1750C") 1743 || !strcmp(dongle_name, "Huawei-E1752Cu") 1744 ) 1745 asus_extra_auto = 1; 1746 1747 if(nvram_match("Dev3G", "AUTO") || (asus_extra_auto == 1)){ 1748 if(asus_extra_auto) 1749 nvram_set("d3g", dongle_name); 1750 else 1751 nvram_set("d3g", "usb_3g_dongle"); 1752usb_dbg("3G: Auto setting.\n"); 1753 1754 if(vid == 0x0408 && (pid == 0xea02 || pid == 0x1000)) 1755 write_3g_conf(fp, SN_MU_Q101, 1, vid, pid); 1756 else if(vid == 0x0408 && pid == 0xea43) 1757 write_3g_conf(fp, SN_Quanta_MobileGenie_4G_lte, 1, vid, pid); 1758 else if(vid == 0x0408 && pid == 0xea25) 1759 write_3g_conf(fp, SN_Quanta_1K3_LTE, 1, vid, pid); 1760 else if(vid == 0x05c6 && pid == 0x1000) // also Option-GlobeSurfer-Icon72(may have new fw setting, bug not included here), Option-GlobeTrotter-GT-MAX36.....Option-Globexx series, AnyDATA-ADU-500A, Samsung-SGH-Z810, Vertex Wireless 100 Series 1761 write_3g_conf(fp, SN_Option_GlobeSurfer_Icon, 1, vid, pid); 1762 else if(vid == 0x05c6 && pid == 0x2001) 1763 write_3g_conf(fp, SN_D_Link_DWM162_U5, 1, vid, pid); 1764 else if(vid == 0x05c6 && pid == 0xf000) 1765 write_3g_conf(fp, SN_Siptune_LM75, 1, vid, pid); 1766 else if(vid == 0x05c6 && pid == 0x9024) 1767 write_3g_conf(fp, SN_Alcatel_TL131, 1, vid, pid); 1768 else if(vid == 0x05c6 && pid == 0x2000) 1769 write_3g_conf(fp, SN_dealextreme, 1, vid, pid); 1770 else if(vid == 0x05c6 && pid == 0x0010) 1771 write_3g_conf(fp, SN_Axesstel_Modems, 1, vid, pid); 1772 else if(vid == 0x1e0e && pid == 0xf000) // A-Link-3GU 1773 write_3g_conf(fp, SN_Option_iCON210, 1, vid, pid); 1774 else if(vid == 0x0af0 && pid == 0x6971) 1775 { 1776 nvram_set("d3g", "OPTION-ICON225"); 1777 write_3g_conf(fp, SN_OPTION_ICON225, 1, vid, pid); 1778 } 1779 else if(vid == 0x0af0 && pid == 0x7011) 1780 { 1781 nvram_set("d3g", "Option-GlobeTrotter-HSUPA-Modem"); 1782 write_3g_conf(fp, SN_Option_GlobeTrotter_HSUPA_Modem, 1, vid, pid); 1783 } 1784 else if(vid == 0x0af0 && pid == 0x7401) 1785 { 1786 nvram_set("d3g", "Option-iCON-401"); 1787 write_3g_conf(fp, SN_Option_iCON401, 1, vid, pid); 1788 } 1789 else if(vid == 0x0af0 && pid == 0x7501) 1790 { 1791 nvram_set("d3g", "Vodafone-K3760"); 1792 write_3g_conf(fp, SN_Vodafone_K3760, 1, vid, pid); 1793 } 1794 else if(vid == 0x0af0 && pid == 0xd033) 1795 { 1796 nvram_set("d3g", "ATT-USBConnect-Quicksilver"); 1797 write_3g_conf(fp, SN_ATT_USBConnect_Quicksilver, 1, vid, pid); 1798 } 1799 else if(vid == 0x0af0 && pid == 0x7a05) 1800 write_3g_conf(fp, SN_OPTION_ICON_461, 1, vid, pid); 1801 else if(vid == 0x0af0 && pid == 0xd001) 1802 write_3g_conf(fp, SN_Option_GI1515, 1, vid, pid); 1803 else if(vid == 0x0af0 && pid == 0x8006) 1804 write_3g_conf(fp, SN_Option_Globetrotter, 1, vid, pid); 1805 else if(vid == 0x0af0 && pid == 0x4007) 1806 write_3g_conf(fp, SN_Option_ICON_711, 1, vid, pid); 1807 else if(vid == 0x12d1 && pid == 0x1505) 1808 write_3g_conf(fp, SN_Huawei_EC156, 1, vid, pid); 1809 else if(vid == 0x12d1 && pid == 0x1001) 1810 write_3g_conf(fp, SN_Huawei_E169, 1, vid, pid); 1811 else if(vid == 0x12d1 && pid == 0x1003) 1812 write_3g_conf(fp, SN_Huawei_E220, 1, vid, pid); 1813 else if(vid == 0x12d1 && pid == 0x1414) 1814 write_3g_conf(fp, SN_Huawei_E180, 1, vid, pid); 1815 else if(vid == 0x12d1 && pid == 0x1c0b) // tmp test 1816 write_3g_conf(fp, SN_Huawei_Exxx, 1, vid, pid); 1817 else if(vid == 0x12d1 && pid == 0x14b5) 1818 write_3g_conf(fp, SN_Huawei_E173, 1, vid, pid); 1819 else if(vid == 0x1033 && pid == 0x0035) 1820 write_3g_conf(fp, SN_Huawei_E630, 1, vid, pid); 1821 else if(vid == 0x12d1 && pid == 0x1446) // E1550, E1612, E1690 1822 write_3g_conf(fp, SN_Huawei_E270, 1, vid, pid); 1823 else if(vid == 0x12d1 && pid == 0x1520) 1824 write_3g_conf(fp, SN_Huawei_K3765, 1, vid, pid); 1825 else if(vid == 0x12d1 && pid == 0x1521) 1826 write_3g_conf(fp, SN_Huawei_K4505, 1, vid, pid); 1827 else if(vid == 0x12d1 && pid == 0x14c4) 1828 write_3g_conf(fp, SN_Huawei_K3771, 1, vid, pid); 1829 else if(vid == 0x12d1 && pid == 0x14d1) 1830 write_3g_conf(fp, SN_Huawei_K3770, 1, vid, pid); 1831 else if(vid == 0x12d1 && pid == 0x1030) 1832 write_3g_conf(fp, SN_Huawei_U8220, 1, vid, pid); 1833 else if(vid == 0x12d1 && pid == 0x14fe) 1834 write_3g_conf(fp, SN_Huawei_T_Mobile_NL, 1, vid, pid); 1835 else if(vid == 0x12d1 && pid == 0x157c) 1836 write_3g_conf(fp, SN_Huawei_E3276S150, 1, vid, pid); 1837 else if(vid == 0x12d1 && pid == 0x1009) 1838 write_3g_conf(fp, SN_Huawei_V725, 1, vid, pid); 1839 else if(vid == 0x12d1 && pid == 0x1da1) 1840 write_3g_conf(fp, SN_Huawei_ET8282, 1, vid, pid); 1841 else if(vid == 0x12d1 && pid == 0x1449) 1842 write_3g_conf(fp, SN_Huawei_E352, 1, vid, pid); 1843 else if(vid == 0x12d1 && pid == 0x380b) 1844 write_3g_conf(fp, SN_Huawei_BM358, 1, vid, pid); 1845 else if(vid == 0x12d1 && pid == 0x1031) 1846 write_3g_conf(fp, SN_Huawei_U8110, 1, vid, pid); 1847 else if(vid == 0x12d1 && pid == 0x1523) 1848 write_3g_conf(fp, SN_Huawei_R201, 1, vid, pid); 1849 else if(vid == 0x12d1 && pid == 0x14c1) 1850 write_3g_conf(fp, SN_Huawei_K4605, 1, vid, pid); 1851 else if(vid == 0x12d1 && pid == 0x101e) 1852 write_3g_conf(fp, SN_Huawei_U7510, 1, vid, pid); 1853 else if(vid == 0x12d1 && pid == 0x1f01) 1854 write_3g_conf(fp, SN_Huawei_E353, 1, vid, pid); 1855 else if(vid == 0x12d1 && pid == 0x14c3) 1856 write_3g_conf(fp, SN_Huawei_K5005, 1, vid, pid); 1857 else if(vid == 0x12d1 && pid == 0x1c24) 1858 write_3g_conf(fp, SN_Huawei_E173_MoiveStar, 1, vid, pid); 1859 else if(vid == 0x12d1 && pid == 0x1f16) 1860 write_3g_conf(fp, SN_Huawei_K5150, 1, vid, pid); 1861 else if(vid == 0x12d1 && pid == 0x1f15) 1862 write_3g_conf(fp, SN_Huawei_K4305, 1, vid, pid); 1863 else if(vid == 0x12d1 && pid == 0x156a) 1864 write_3g_conf(fp, SN_Huawei_E3276s, 1, vid, pid); 1865 else if(vid == 0x19d2 && pid == 0x2000) // also ZTE 620, 622, 628, 6535-Z, K3520-Z, K3565, ONDA-MT503HS, ONDA-MT505UP 1866 write_3g_conf(fp, SN_ZTE_MF626, 1, vid, pid); 1867 else if(vid == 0x19d2 && pid == 0xfff5) 1868 write_3g_conf(fp, SN_ZTE_AC2710, 1, vid, pid); // 2710 1869 else if(vid == 0x19d2 && pid == 0xbccd) 1870 write_3g_conf(fp, SN_ZTEAX226, 1, vid, pid); 1871 else if(vid == 0x19d2 && pid == 0x0026) 1872 write_3g_conf(fp, SN_ZTE_AC581, 1, vid, pid); 1873 else if(vid == 0x19d2 && pid == 0x0169) 1874 write_3g_conf(fp, SN_ZTE_A371B, 1, vid, pid); 1875 else if(vid == 0x19d2 && pid == 0x1520) 1876 write_3g_conf(fp, SN_ZTE_MF652, 1, vid, pid); 1877 else if(vid == 0x19d2 && pid == 0x0146) 1878 write_3g_conf(fp, SN_ZTE_MF652_VAR, 1, vid, pid); 1879 else if(vid == 0x19d2 && pid == 0x0031) 1880 write_3g_conf(fp, SN_ZTE_MF637_2, 1, vid, pid); 1881 else if(vid == 0x19d2 && pid == 0x1514) 1882 write_3g_conf(fp, SN_ZTE_MF192_VAR, 1, vid, pid); 1883 else if(vid == 0x19d2 && pid == 0x1225) 1884 write_3g_conf(fp, SN_ZTE_MF823, 1, vid, pid); 1885 else if(vid == 0x19d2 && pid == 0x0053) 1886 write_3g_conf(fp, SN_ZTE_MF110, 1, vid, pid); 1887 else if(vid == 0x19d2 && pid == 0x0149) 1888 write_3g_conf(fp, SN_ZTE_MF190_var, 1, vid, pid); 1889 else if(vid == 0x19d2 && pid == 0x1216) 1890 write_3g_conf(fp, SN_ZTE_MF192, 1, vid, pid); 1891 else if(vid == 0x19d2 && pid == 0x1201) 1892 write_3g_conf(fp, SN_ZTE_MF691, 1, vid, pid); 1893 else if(vid == 0x19d2 && pid == 0x1224) 1894 write_3g_conf(fp, SN_ZTE_MF190, 1, vid, pid); 1895 else if(vid == 0x19d2 && pid == 0xffe6) 1896 write_3g_conf(fp, SN_ZTE_ffe, 1, vid, pid); 1897 else if(vid == 0x19d2 && pid == 0x0013) 1898 write_3g_conf(fp, SN_ZTE_K3806Z, 1, vid, pid); 1899 else if(vid == 0x19d2 && pid == 0x0110) 1900 write_3g_conf(fp, SN_ZTE_MF637, 1, vid, pid); 1901 else if(vid == 0x19d2 && pid == 0x0003) 1902 write_3g_conf(fp, SN_ZTE_MU351, 1, vid, pid); 1903 else if(vid == 0x19d2 && pid == 0x0083) 1904 write_3g_conf(fp, SN_ZTE_MF110_var, 1, vid, pid); 1905 else if(vid == 0x19d2 && pid == 0x0103) 1906 write_3g_conf(fp, SN_ZTE_MF112, 1, vid, pid); 1907 else if(vid == 0x19d2 && pid == 0x1001) 1908 write_3g_conf(fp, SN_ZTE_K3805_Z, 1, vid, pid); 1909 else if(vid == 0x19d2 && pid == 0x1227) 1910 write_3g_conf(fp, SN_ZTE_MF680, 1, vid, pid); 1911 else if(vid == 0x19d2 && pid == 0x0150) 1912 write_3g_conf(fp, SN_ZTE_MF656A, 1, vid, pid); 1913 else if(vid == 0x19d2 && pid == 0x1528) 1914 write_3g_conf(fp, SN_ZTE_MF196, 1, vid, pid); 1915 else if(vid == 0x19d2 && pid == 0x0266) 1916 write_3g_conf(fp, SN_Onda_MT8205_LTE, 1, vid, pid); 1917 else if(vid == 0x1410 && pid == 0x5010) // U727 1918 write_3g_conf(fp, SN_Novatel_Wireless_Ovation_MC950D, 1, vid, pid); 1919 else if(vid == 0x1410 && pid == 0x5020) 1920 write_3g_conf(fp, SN_Novatel_MC990D, 1, vid, pid); 1921 else if(vid == 0x1410 && pid == 0x5030) 1922 write_3g_conf(fp, SN_Novatel_U760, 1, vid, pid); 1923 else if(vid == 0x1410 && pid == 0x5031) 1924 write_3g_conf(fp, SN_Novatel_MC760, 1, vid, pid); 1925 else if(vid == 0x1410 && pid == 0x2110) 1926 write_3g_conf(fp, SN_NovatelU720, 1, vid, pid); 1927 else if(vid == 0x1410 && pid == 0x5023) 1928 write_3g_conf(fp, SN_Novatel_MC996D, 1, vid, pid); 1929 else if(vid == 0x1c9e && pid == 0x1001) 1930 write_3g_conf(fp, SN_Alcatel_X020, 1, vid, pid); 1931 else if(vid == 0x1c9e && pid == 0xf000) // ST-Mobile, MobiData MBD-200HU, // BSNL 310G 1932 write_3g_conf(fp, SN_BSNL_310G, 1, vid, pid); 1933 else if(vid == 0x1c9e && pid == 0x9605) // chk BSNL 310G 1934 write_3g_conf(fp, SN_BSNL_310G, 1, vid, pid); 1935 else if(vid == 0x1c9e && pid == 0x9200) 1936 write_3g_conf(fp, SN_MyWave_SW006, 1, vid, pid); 1937 else if(vid == 0x1c9e && pid == 0x9800) 1938 write_3g_conf(fp, SN_SU9800, 1, vid, pid); 1939 else if(vid == 0x1c9e && pid == 0x6061) 1940 write_3g_conf(fp, SN_Vibe_3G, 1, vid, pid); 1941 else if(vid == 0x1c9e && pid == 0x9e00) 1942 write_3g_conf(fp, SN_BSNL_Capitel, 1, vid, pid); 1943 else if(vid == 0x1c9e && pid == 0x98ff) 1944 write_3g_conf(fp, SN_Telewell_TW_3G, 1, vid, pid); 1945 else if(vid == 0x1bbb && pid == 0xf000) 1946 write_3g_conf(fp, SN_Alcatel_X200, 1, vid, pid); 1947 else if(vid == 0x1dd6 && pid == 0x1000) 1948 write_3g_conf(fp, SN_Solomon_S3Gm660, 1, vid, pid); 1949 else if(vid == 0x16d8 && pid == 0x6803) 1950 write_3g_conf(fp, SN_C_motechD50, 1, vid, pid); 1951 else if(vid == 0x16d8 && pid == 0xf000) 1952 write_3g_conf(fp, SN_C_motech_CGU628, 1, vid, pid); 1953 else if(vid == 0x16d8 && pid == 0x700a) 1954 write_3g_conf(fp, SN_C_motech_CHU_629S, 1, vid, pid); 1955 else if(vid == 0x16d8 && pid == 0x700b) 1956 write_3g_conf(fp, SN_CHU_629S, 1, vid, pid); 1957 else if(vid == 0x16d8 && pid == 0x6281) 1958 write_3g_conf(fp, SN_CHU_628S, 1, vid, pid); 1959 else if(vid == 0x0930 && pid == 0x0d46) 1960 write_3g_conf(fp, SN_Toshiba_G450, 1, vid, pid); 1961 else if(vid == 0x106c && pid == 0x3b03) 1962 write_3g_conf(fp, SN_UTStarcom_UM175, 1, vid, pid); 1963 else if(vid == 0x106c && pid == 0x3b05) 1964 write_3g_conf(fp, SN_UMW190, 1, vid, pid); 1965 else if(vid == 0x106c && pid == 0x3b06) 1966 write_3g_conf(fp, SN_UTStarcom_UM185E, 1, vid, pid); 1967 else if(vid == 0x106c && pid == 0x3711) 1968 write_3g_conf(fp, SN_Pantech_UM150, 1, vid, pid); 1969 else if(vid == 0x106c && pid == 0x3714) 1970 write_3g_conf(fp, SN_Pantech_UM175, 1, vid, pid); 1971 else if(vid == 0x106c && pid == 0x3b11) 1972 write_3g_conf(fp, SN_Pantech_UML290, 1, vid, pid); 1973 else if(vid == 0x1ab7 && pid == 0x5700) 1974 write_3g_conf(fp, SN_Hummer_DTM5731, 1, vid, pid); 1975 else if(vid == 0x1199 && pid == 0x0fff) // Sierra881U 1976 write_3g_conf(fp, SN_Sierra_Wireless_Compass597, 1, vid, pid); 1977 else if(vid == 0x1199 && pid == 0x0120) 1978 write_3g_conf(fp, SN_Sierra_U595, 1, vid, pid); 1979 else if(vid == 0x0fce && pid == 0xd0e1) 1980 write_3g_conf(fp, SN_Sony_Ericsson_MD400, 1, vid, pid); 1981 else if(vid == 0x0fce && pid == 0xd103) 1982 write_3g_conf(fp, SN_SE_MD400G, 1, vid, pid); 1983 else if(vid == 0x230d && pid == 0x0001) 1984 write_3g_conf(fp, SN_BSNL_LW272, 1, vid, pid); 1985 else if(vid == 0x230d && pid == 0x0103) 1986 write_3g_conf(fp, SN_Teracom_LW272, 1, vid, pid); 1987 else if(vid == 0x1f28 && pid == 0x0021) 1988 write_3g_conf(fp, SN_Cricket_A600, 1, vid, pid); 1989 else if(vid == 0x1b7d && pid == 0x0700) 1990 write_3g_conf(fp, SN_EpiValley_SEC7089, 1, vid, pid); 1991 else if(vid == 0x04e8 && pid == 0xf000) 1992 write_3g_conf(fp, SN_Samsung_U209, 1, vid, pid); 1993 else if(vid == 0x04e8 && pid == 0x689a) 1994 write_3g_conf(fp, SN_Samsung_GT_B3730, 1, vid, pid); 1995 else if(vid == 0x04e8 && pid == 0x680c) 1996 write_3g_conf(fp, SN_Samsung_GT_B1110, 1, vid, pid); 1997 else if(vid == 0x0471 && pid == 0x1237) // HuaXing E600 1998 write_3g_conf(fp, SN_Philips_TalkTalk, 1, vid, pid); 1999 else if(vid == 0x0471 && pid == 0x1210) 2000 write_3g_conf(fp, SN_Vodafone_MD950, 1, vid, pid); 2001 else if(vid == 0x0421 && pid == 0x060c) 2002 write_3g_conf(fp, SN_Nokia_CS10, 1, vid, pid); 2003 else if(vid == 0x0421 && pid == 0x0610) 2004 write_3g_conf(fp, SN_Nokia_CS15, 1, vid, pid); 2005 else if(vid == 0x0421 && pid == 0x0622) 2006 write_3g_conf(fp, SN_Nokia_CS17, 1, vid, pid); 2007 else if(vid == 0x0421 && pid == 0x0627) 2008 write_3g_conf(fp, SN_Nokia_CS18, 1, vid, pid); 2009 else if(vid == 0x0421 && pid == 0x0637) 2010 write_3g_conf(fp, SN_Nokia_CS_21M_02, 1, vid, pid); 2011 else if(vid == 0x0421 && pid == 0x0618) 2012 write_3g_conf(fp, SN_Nokia_CS_12, 1, vid, pid); 2013 else if(vid == 0x0df7 && pid == 0x0800) 2014 write_3g_conf(fp, SN_Mobile_Action, 1, vid, pid); 2015 else if(vid == 0x03f0 && pid == 0x002a) 2016 write_3g_conf(fp, SN_HP_P1102, 1, vid, pid); 2017 else if(vid == 0x198a && pid == 0x0003) 2018 write_3g_conf(fp, SN_JOA_LM_700r, 1, vid, pid); 2019 else if(vid == 0x07d1 && pid == 0xa804) 2020 write_3g_conf(fp, SN_DLINK_DWM_156_A3, 1, vid, pid); 2021 else if(vid == 0x2001 && pid == 0xa706) 2022 write_3g_conf(fp, SN_DLINK_DWM_156_A7_1, 1, vid, pid); 2023 else if(vid == 0x2001 && pid == 0xa707) 2024 write_3g_conf(fp, SN_DLINK_DWM_156_A7_2, 1, vid, pid); 2025 else if(vid == 0x2001 && pid == 0xa708) 2026 write_3g_conf(fp, SN_DLINK_DWM_156_A7_3, 1, vid, pid); 2027 else if(vid == 0x2001 && pid == 0xa805) 2028 write_3g_conf(fp, SN_DLINK_DWR_510, 1, vid, pid); 2029 else if(vid == 0x1ee8 && pid == 0x0040) 2030 write_3g_conf(fp, SN_ONDA_MW836UP_K, 1, vid, pid); 2031 else if(vid == 0x1ee8 && pid == 0x0009) 2032 write_3g_conf(fp, SN_ONDA_MW833UP, 1, vid, pid); 2033 else if(vid == 0x1ee8 && pid == 0x0013) 2034 write_3g_conf(fp, SN_ONDA_MW833UP_2, 1, vid, pid); 2035 else if(vid == 0x1ee8 && pid == 0x0060) 2036 write_3g_conf(fp, SN_Onda_MSA14_4, 1, vid, pid); 2037 else if(vid == 0x1ee8 && pid == 0x0068) 2038 write_3g_conf(fp, SN_Onda_WM301, 1, vid, pid); 2039 else if(vid == 0x1ee8 && pid == 0x0063) 2040 write_3g_conf(fp, SN_Onda_TM201_14_4, 1, vid, pid); 2041 else if(vid == 0x201e && pid == 0x2009) 2042 write_3g_conf(fp, SN_Haier_CE_100, 1, vid, pid); 2043 else if(vid == 0x201e && pid == 0x1023) 2044 write_3g_conf(fp, SN_Haier_CE682, 1, vid, pid); 2045 else if(vid == 0x1fac && pid == 0x0032) 2046 write_3g_conf(fp, SN_Franklin_Wireless_U210_var, 1, vid, pid); 2047 else if(vid == 0x1fac && pid == 0x0130) 2048 write_3g_conf(fp, SN_Franklin_Wireless_U210, 1, vid, pid); 2049 else if(vid == 0x8888 && pid == 0x6500) 2050 write_3g_conf(fp, SN_Exiss_E_190, 1, vid, pid); 2051 else if(vid == 0x1edf && pid == 0x6003) 2052 write_3g_conf(fp, SN_AirPlus_MCD_800, 1, vid, pid); 2053 else if(vid == 0x1004 && pid == 0x1000) 2054 write_3g_conf(fp, SN_LG_LDU_1900D, 1, vid, pid); 2055 else if(vid == 0x1004 && pid == 0x6190) 2056 write_3g_conf(fp, SN_LG_AD600, 1, vid, pid); 2057 else if(vid == 0x1004 && pid == 0x613f) 2058 write_3g_conf(fp, SN_LG_LUU_2100TI, 1, vid, pid); 2059 else if(vid == 0x1004 && pid == 0x613a) 2060 write_3g_conf(fp, SN_LG_L_05A, 1, vid, pid); 2061 else if(vid == 0x1004 && pid == 0x607f) 2062 write_3g_conf(fp, SN_LG_HDM_2100, 1, vid, pid); 2063 else if(vid == 0x1004 && pid == 0x61dd) 2064 write_3g_conf(fp, SN_LG_L_02C_LTE, 1, vid, pid); 2065 else if(vid == 0x1004 && pid == 0x61e7) 2066 write_3g_conf(fp, SN_LG_SD711, 1, vid, pid); 2067 else if(vid == 0x1004 && pid == 0x61eb) 2068 write_3g_conf(fp, SN_LG_L_08C, 1, vid, pid); 2069 else if(vid == 0x1004 && pid == 0x614e) 2070 write_3g_conf(fp, SN_LG_L_07A, 1, vid, pid); 2071 else if(vid == 0x0fd1 && pid == 0x1000) 2072 write_3g_conf(fp, SN_GW_D301, 1, vid, pid); 2073 else if(vid == 0x05c7 && pid == 0x1000) 2074 write_3g_conf(fp, SN_Qtronix_EVDO_3G, 1, vid, pid); 2075 else if(vid == 0x0b3c && pid == 0xf000) 2076 write_3g_conf(fp, SN_Olicard_145, 1, vid, pid); 2077 else if(vid == 0x0b3c && pid == 0xc700) 2078 write_3g_conf(fp, SN_Olicard_100, 1, vid, pid); 2079 else if(vid == 0x0d46 && pid == 0x45a5) 2080 write_3g_conf(fp, SN_Kobil_mIdentity_3G_2, 1, vid, pid); 2081 else if(vid == 0x0d46 && pid == 0x45a1) 2082 write_3g_conf(fp, SN_Kobil_mIdentity_3G_1, 1, vid, pid); 2083 else if(vid == 0x0cf3 && pid == 0x20ff) 2084 write_3g_conf(fp, SN_Netgear_WNDA3200, 1, vid, pid); 2085 else if(vid == 0x0fce && pid == 0xd0cf) 2086 write_3g_conf(fp, SN_SE_MD300, 1, vid, pid); 2087 else if(vid == 0x1266 && pid == 0x1000) 2088 write_3g_conf(fp, SN_Digicom_8E4455, 1, vid, pid); 2089 else if(vid == 0x0482 && pid == 0x024d) 2090 write_3g_conf(fp, SN_Kyocera_W06K, 1, vid, pid); 2091 else if(vid == 0x198f && pid == 0xbccd) 2092 write_3g_conf(fp, SN_Beceem_BCSM250, 1, vid, pid); 2093 else if(vid == 0x0b05 && pid == 0xbccd) 2094 write_3g_conf(fp, SN_Beceem_BCSM250_ASUS, 1, vid, pid); 2095 else if(vid == 0x057c && pid == 0x84ff) 2096 write_3g_conf(fp, SN_AVM_Fritz, 1, vid, pid); 2097 else if(vid == 0x057c && pid == 0x62ff) 2098 write_3g_conf(fp, SN_AVM_Fritz_V2, 1, vid, pid); 2099 else if(vid == 0x2020 && pid == 0xf00e) 2100 write_3g_conf(fp, SN_SU_8000U, 1, vid, pid); 2101 else if(vid == 0x2020 && pid == 0x0002) 2102 write_3g_conf(fp, SN_Mediatek_MT6229, 1, vid, pid); 2103 else if(vid == 0x1307 && pid == 0x1169) 2104 write_3g_conf(fp, SN_Cisco_AM10, 1, vid, pid); 2105 else if(vid == 0x1da5 && pid == 0xf000) 2106 write_3g_conf(fp, SN_Qisda_H21, 1, vid, pid); 2107 else if(vid == 0x21f5 && pid == 0x1000) 2108 write_3g_conf(fp, SN_StrongRising_Air_FlexiNet, 1, vid, pid); 2109 else if(vid == 0x1a8d && pid == 0x2000) 2110 write_3g_conf(fp, SN_BandLuxe_C339, 1, vid, pid); 2111 else if(vid == 0x04bb && pid == 0xbccd) 2112 write_3g_conf(fp, SN_IODATA_WMX2_U, 1, vid, pid); 2113 else if(vid == 0x2077 && pid == 0xf000) 2114 write_3g_conf(fp, SN_T_W_WU160, 1, vid, pid); 2115 else if(vid == 0x0e8d && pid == 0x0002) 2116 write_3g_conf(fp, SN_MediaTek_MT6276M, 1, vid, pid); 2117 else if(vid == 0x22f4 && pid == 0x0021) 2118 write_3g_conf(fp, SN_Tata_Photon_plus, 1, vid, pid); 2119 else if(vid == 0x109b && pid == 0xf009) 2120 write_3g_conf(fp, SN_HISENSE_E910, 1, vid, pid); 2121 else if(vid == 0x22de && pid == 0x6803) 2122 write_3g_conf(fp, SN_WeTelecom_WMD300, 1, vid, pid); 2123 else if(vid == 0x22de && pid == 0x6801) 2124 write_3g_conf(fp, SN_WeTelecom_WMD200, 1, vid, pid); 2125 else if(vid == 0x10a9 && pid == 0x6080) 2126 write_3g_conf(fp, SN_Pantech_LTE, 1, vid, pid); 2127 else if(vid == 0x0fca && pid == 0x8020) 2128 write_3g_conf(fp, SN_BlackBerry_Q10, 1, vid, pid); 2129 else if(vid == 0x2357 && pid == 0xf000) 2130 write_3g_conf(fp, SN_TP_Link_MA260, 1, vid, pid); 2131 else if(vid == 0x12d1 && pid == 0x155b) 2132 write_3g_conf(fp, SN_Huawei_E3131, 1, vid, pid); 2133 else if(vid == 0x12d1 && pid == 0x157d) 2134 write_3g_conf(fp, SN_Huawei_E3372, 1, vid, pid); 2135 else if(vid == 0x12d1 && pid == 0x15ca) 2136 write_3g_conf(fp, SN_Huawei_E303u, 1, vid, pid); 2137 else if(vid == 0x12d1 && pid == 0x15cd) 2138 write_3g_conf(fp, SN_Huawei_E3531s, 1, vid, pid); 2139 else if(vid == 0x12d1) 2140 write_3g_conf(fp, UNKNOWNDEV, 1, vid, pid); 2141 else{ 2142 fclose(fp); 2143 unlink(conf_file); 2144 return 0; 2145 } 2146 } 2147 else /* manaul setting */ 2148 { 2149usb_dbg("3G: manaul setting.\n"); 2150 nvram_set("d3g", dongle_name); 2151 2152 if(strcmp(dongle_name, "MU-Q101") == 0){ // on list 2153 write_3g_conf(fp, SN_MU_Q101, 0, vid, pid); 2154 } else if (strcmp(dongle_name, "ASUS-T500") == 0 && vid == 0x0b05){ // on list 2155 write_3g_conf(fp, UNKNOWNDEV, 0, vid, pid); 2156 //} else if (strcmp(dongle_name, "OPTION-ICON225") == 0){ // on list 2157 // write_3g_conf(fp, SN_OPTION_ICON225, 0, vid, pid); 2158 } else if (strcmp(dongle_name, "Option-GlobeSurfer-Icon") == 0){ 2159 write_3g_conf(fp, SN_Option_GlobeSurfer_Icon, 0, vid, pid); 2160 } else if (strcmp(dongle_name, "Option-GlobeSurfer-Icon-7.2") == 0){ 2161 write_3g_conf(fp, SN_Option_GlobeSurfer_Icon72, 0, vid, pid); 2162 } else if (strcmp(dongle_name, "Option-GlobeTrotter-GT-MAX-3.6") == 0){ 2163 write_3g_conf(fp, SN_Option_GlobeTrotter_GT_MAX36, 0, vid, pid); 2164 } else if (strcmp(dongle_name, "Option-GlobeTrotter-GT-MAX-7.2") == 0){ 2165 write_3g_conf(fp, SN_Option_GlobeTrotter_GT_MAX72, 0, vid, pid); 2166 } else if (strcmp(dongle_name, "Option-GlobeTrotter-EXPRESS-7.2") == 0){ 2167 write_3g_conf(fp, SN_Option_GlobeTrotter_EXPRESS72, 0, vid, pid); 2168 } else if (strcmp(dongle_name, "Option-iCON-210") == 0){ 2169 write_3g_conf(fp, SN_Option_iCON210, 0, vid, pid); 2170 } else if (strcmp(dongle_name, "Option-GlobeTrotter-HSUPA-Modem") == 0){ 2171 write_3g_conf(fp, SN_Option_GlobeTrotter_HSUPA_Modem, 0, vid, pid); 2172 } else if (strcmp(dongle_name, "Option-iCON-401") == 0){ 2173 write_3g_conf(fp, SN_Option_iCON401, 0, vid, pid); 2174 } else if (strcmp(dongle_name, "Vodafone-K3760") == 0){ 2175 write_3g_conf(fp, SN_Vodafone_K3760, 0, vid, pid); 2176 } else if (strcmp(dongle_name, "ATT-USBConnect-Quicksilver") == 0){ 2177 write_3g_conf(fp, SN_ATT_USBConnect_Quicksilver, 0, vid, pid); 2178 } else if (strcmp(dongle_name, "Huawei-E169") == 0){ // on list 2179 write_3g_conf(fp, SN_Huawei_E169, 0, vid, pid); 2180 } else if (strcmp(dongle_name, "Huawei-E180") == 0){ // on list 2181 //write_3g_conf(fp, SN_Huawei_E180, 0, vid, pid); 2182 write_3g_conf(fp, SN_Huawei_E220, 1, vid, pid); // E180:12d1/1003 (as E220) 2183 } else if (strcmp(dongle_name, "Huawei-E220") == 0){ // on list 2184 write_3g_conf(fp, SN_Huawei_E220, 0, vid, pid); 2185 } else if (strcmp(dongle_name, "Huawei-E630") == 0){ 2186 write_3g_conf(fp, SN_Huawei_E630, 0, vid, pid); 2187 } else if (strcmp(dongle_name, "Huawei-E270") == 0){ 2188 write_3g_conf(fp, SN_Huawei_E270, 0, vid, pid); 2189 } else if (strcmp(dongle_name, "Huawei-E1550") == 0){ 2190 write_3g_conf(fp, SN_Huawei_E1550, 0, vid, pid); 2191 } else if (strcmp(dongle_name, "Huawei-E161") == 0){ 2192 write_3g_conf(fp, SN_Huawei_E1612, 0, vid, pid); 2193 } else if (strcmp(dongle_name, "Huawei-E1612") == 0){ 2194 write_3g_conf(fp, SN_Huawei_E1612, 0, vid, pid); 2195 } else if (strcmp(dongle_name, "Huawei-E1690") == 0){ 2196 write_3g_conf(fp, SN_Huawei_E1690, 0, vid, pid); 2197 } else if (strcmp(dongle_name, "Huawei-K3765") == 0){ 2198 write_3g_conf(fp, SN_Huawei_K3765, 0, vid, pid); 2199 } else if (strcmp(dongle_name, "Huawei-K4505") == 0){ 2200 write_3g_conf(fp, SN_Huawei_K4505, 0, vid, pid); 2201 } else if (strcmp(dongle_name, "Huawei-E372") == 0){ // 20120919: From Lencer's test, must run EC156 to switch. 2202 write_3g_conf(fp, SN_Huawei_EC156, 0, vid, pid); 2203 } else if (strcmp(dongle_name, "Huawei-E173") == 0){ 2204 write_3g_conf(fp, SN_Huawei_E173, 0, vid, pid); 2205 } else if (strcmp(dongle_name, "MTS-AC2746") == 0){ // Couldn't switch with usb_modeswitch. 2206 fclose(fp); 2207 unlink(conf_file); 2208 return 0; 2209 } else if (strcmp(dongle_name, "ZTE-MF626") == 0){ 2210 write_3g_conf(fp, SN_ZTE_MF626, 0, vid, pid); 2211 } else if (strcmp(dongle_name, "ZTE-AC8710") == 0){ 2212 write_3g_conf(fp, SN_ZTE_AC8710, 0, vid, pid); 2213 } else if (strcmp(dongle_name, "ZTE-AC2710") == 0){ 2214 write_3g_conf(fp, SN_ZTE_AC2710, 0, vid, pid); 2215 } else if (strcmp(dongle_name, "ZTE-MF110") == 0){ 2216 write_3g_conf(fp, SN_ZTE_MF110, 0, vid, pid); 2217 } else if (strcmp(dongle_name, "Novatel-Wireless-Ovation-MC950D-HSUPA") == 0){ 2218 write_3g_conf(fp, SN_Novatel_Wireless_Ovation_MC950D, 0, vid, pid); 2219 } else if (strcmp(dongle_name, "Novatel-U727") == 0){ 2220 write_3g_conf(fp, SN_Novatel_U727, 0, vid, pid); 2221 } else if (strcmp(dongle_name, "Novatel-MC990D") == 0){ 2222 write_3g_conf(fp, SN_Novatel_MC990D, 0, vid, pid); 2223 } else if (strcmp(dongle_name, "Novatel-U760") == 0){ 2224 write_3g_conf(fp, SN_Novatel_U760, 0, vid, pid); 2225 } else if (strcmp(dongle_name, "Alcatel-X020") == 0){ 2226 write_3g_conf(fp, SN_Alcatel_X020, 0, vid, pid); 2227 } else if (strcmp(dongle_name, "Alcatel-X200") == 0){ 2228 write_3g_conf(fp, SN_Alcatel_X200, 0, vid, pid); 2229 } else if (strcmp(dongle_name, "AnyDATA-ADU-500A") == 0){ 2230 write_3g_conf(fp, SN_AnyDATA_ADU_500A, 0, vid, pid); 2231 } else if (strncmp(dongle_name, "BandLuxe-", 9) == 0){ // on list 2232 fclose(fp); 2233 unlink(conf_file); 2234 return 0; 2235 } else if (strcmp(dongle_name, "Solomon-S3Gm-660") == 0){ 2236 write_3g_conf(fp, SN_Solomon_S3Gm660, 0, vid, pid); 2237 } else if (strcmp(dongle_name, "C-motechD-50") == 0){ 2238 write_3g_conf(fp, SN_C_motechD50, 0, vid, pid); 2239 } else if (strcmp(dongle_name, "C-motech-CGU-628") == 0){ 2240 write_3g_conf(fp, SN_C_motech_CGU628, 0, vid, pid); 2241 } else if (strcmp(dongle_name, "Toshiba-G450") == 0){ 2242 write_3g_conf(fp, SN_Toshiba_G450, 0, vid, pid); 2243 } else if (strcmp(dongle_name, "UTStarcom-UM175") == 0){ 2244 write_3g_conf(fp, SN_UTStarcom_UM175, 0, vid, pid); 2245 } else if (strcmp(dongle_name, "Hummer-DTM5731") == 0){ 2246 write_3g_conf(fp, SN_Hummer_DTM5731, 0, vid, pid); 2247 } else if (strcmp(dongle_name, "A-Link-3GU") == 0){ 2248 write_3g_conf(fp, SN_A_Link_3GU, 0, vid, pid); 2249 } else if (strcmp(dongle_name, "Sierra-Wireless-Compass-597") == 0){ 2250 write_3g_conf(fp, SN_Sierra_Wireless_Compass597, 0, vid, pid); 2251 } else if (strcmp(dongle_name, "Sierra-881U") == 0){ 2252 write_3g_conf(fp, SN_Sierra881U, 0, vid, pid); 2253 } else if (strcmp(dongle_name, "Sony-Ericsson-MD400") == 0){ 2254 write_3g_conf(fp, SN_Sony_Ericsson_MD400, 0, vid, pid); 2255 } else if (strcmp(dongle_name, "LG-LDU-1900D") == 0){ 2256 write_3g_conf(fp, SN_LG_LDU_1900D, 0, vid, pid); 2257 } else if (strcmp(dongle_name, "Samsung-SGH-Z810") == 0){ 2258 write_3g_conf(fp, SN_Samsung_SGH_Z810, 0, vid, pid); 2259 } else if (strcmp(dongle_name, "MobiData-MBD-200HU") == 0){ 2260 write_3g_conf(fp, SN_MobiData_MBD_200HU, 0, vid, pid); 2261 } else if (strcmp(dongle_name, "ST-Mobile") == 0){ 2262 write_3g_conf(fp, SN_ST_Mobile, 0, vid, pid); 2263 } else if (strcmp(dongle_name, "MyWave-SW006") == 0){ 2264 write_3g_conf(fp, SN_MyWave_SW006, 0, vid, pid); 2265 } else if (strcmp(dongle_name, "Cricket-A600") == 0){ 2266 write_3g_conf(fp, SN_Cricket_A600, 0, vid, pid); 2267 } else if (strcmp(dongle_name, "EpiValley-SEC-7089") == 0){ 2268 write_3g_conf(fp, SN_EpiValley_SEC7089, 0, vid, pid); 2269 } else if (strcmp(dongle_name, "Samsung-U209") == 0){ 2270 write_3g_conf(fp, SN_Samsung_U209, 0, vid, pid); 2271 } else if (strcmp(dongle_name, "D-Link-DWM-162-U5") == 0){ 2272 write_3g_conf(fp, SN_D_Link_DWM162_U5, 0, vid, pid); 2273 } else if (strcmp(dongle_name, "Novatel-MC760") == 0){ 2274 write_3g_conf(fp, SN_Novatel_MC760, 0, vid, pid); 2275 } else if (strcmp(dongle_name, "Philips-TalkTalk") == 0){ 2276 write_3g_conf(fp, SN_Philips_TalkTalk, 0, vid, pid); 2277 } else if (strcmp(dongle_name, "HuaXing-E600") == 0){ 2278 write_3g_conf(fp, SN_HuaXing_E600, 0, vid, pid); 2279 } else if (strcmp(dongle_name, "C-motech-CHU-629S") == 0){ 2280 write_3g_conf(fp, SN_C_motech_CHU_629S, 0, vid, pid); 2281 } else if (strcmp(dongle_name, "Sagem-9520") == 0){ 2282 write_3g_conf(fp, SN_Sagem9520, 0, vid, pid); 2283 } else if (strcmp(dongle_name, "Nokia-CS15") == 0){ 2284 write_3g_conf(fp, SN_Nokia_CS15, 0, vid, pid); 2285 } else if (strcmp(dongle_name, "Nokia-CS17") == 0){ 2286 write_3g_conf(fp, SN_Nokia_CS17, 0, vid, pid); 2287 } else if (strcmp(dongle_name, "Vodafone-MD950") == 0){ 2288 write_3g_conf(fp, SN_Vodafone_MD950, 0, vid, pid); 2289 } else if (strcmp(dongle_name, "Siptune-LM-75") == 0){ 2290 write_3g_conf(fp, SN_Siptune_LM75, 0, vid, pid); 2291 } else if (strcmp(dongle_name, "Celot_CT-680") == 0){ // 0703 add 2292 write_3g_conf(fp, SN_Celot_CT680, 0, vid, pid); 2293 } else if (strcmp(dongle_name, "Celot_CT-K300") == 0){ // 0703 add 2294 write_3g_conf(fp, SN_Celot_K300, 0, vid, pid); 2295 } else if (strncmp(dongle_name, "Huawei-", 7) == 0 && vid == 0x12d1){ 2296 write_3g_conf(fp, UNKNOWNDEV, 0, vid, pid); 2297 } else{ 2298 nvram_set("d3g", "usb_3g_dongle"); // the plugged dongle was not the manual-setting one. 2299 fclose(fp); 2300 unlink(conf_file); 2301 return 0; 2302 } 2303 } 2304 fclose(fp); 2305 2306 return 1; 2307} 2308 2309int write_3g_ppp_conf(void){ 2310 char modem_node[16]; 2311 FILE *fp; 2312 char usb_node[32]; 2313 unsigned int vid, pid; 2314 int wan_unit; 2315 char prefix[] = "wanXXXXXXXXXX_", tmp[100]; 2316 int retry, lock; 2317#ifdef SET_USB_MODEM_MTU_PPP 2318 int modem_mtu; 2319#endif 2320 2321 snprintf(modem_node, 16, "%s", nvram_safe_get("usb_modem_act_int")); 2322 if(strlen(modem_node) <= 0){ 2323 usb_dbg(": Fail to get the act modem node.\n"); 2324 return 0; 2325 } 2326 2327 if(get_device_type_by_device(modem_node) != DEVICE_TYPE_MODEM){ 2328 usb_dbg("(%s): test 1.\n", modem_node); 2329 return 0; 2330 } 2331 2332 if ((wan_unit = get_usbif_dualwan_unit()) < 0) { 2333 usb_dbg("(%s): Don't enable the USB interface as the WAN type yet.\n", modem_node); 2334 return 0; 2335 } 2336 2337 snprintf(prefix, sizeof(prefix), "wan%d_", wan_unit); 2338 2339 retry = 0; 2340 while((lock = file_lock("3g")) == -1 && retry < MAX_WAIT_FILE) 2341 sleep(1); 2342 if(lock == -1){ 2343 usb_dbg("(%s): test 3.\n", modem_node); 2344 return 0; 2345 } 2346 2347 unlink(PPP_CONF_FOR_3G); 2348 if((fp = fopen(PPP_CONF_FOR_3G, "w+")) == NULL){ 2349 eval("mkdir", "-p", PPP_DIR); 2350 2351 if((fp = fopen(PPP_CONF_FOR_3G, "w+")) == NULL){ 2352 usb_dbg("(%s): test 4.\n", modem_node); 2353 file_unlock(lock); 2354 return 0; 2355 } 2356 } 2357 2358 // Get USB node. 2359 if(get_usb_node_by_device(modem_node, usb_node, 32) == NULL){ 2360 usb_dbg("(%s): test 5.\n", modem_node); 2361 file_unlock(lock); 2362 return 0; 2363 } 2364 2365 // Get VID. 2366 if((vid = get_usb_vid(usb_node)) == 0){ 2367 usb_dbg("(%s): test 6.\n", modem_node); 2368 file_unlock(lock); 2369 return 0; 2370 } 2371 2372 // Get PID. 2373 if((pid = get_usb_pid(usb_node)) == 0){ 2374 usb_dbg("(%s): test 7.\n", modem_node); 2375 file_unlock(lock); 2376 return 0; 2377 } 2378 2379 char *modem_enable = nvram_safe_get("modem_enable"); 2380 char *user = nvram_safe_get("modem_user"); 2381 char *pass = nvram_safe_get("modem_pass"); 2382 char *isp = nvram_safe_get("modem_isp"); 2383 char *baud = nvram_safe_get("modem_baud"); 2384 2385 fprintf(fp, "/dev/%s\n", modem_node); 2386 if(strlen(baud) > 0) 2387 fprintf(fp, "%s\n", baud); 2388 if(strlen(user) > 0) 2389 fprintf(fp, "user %s\n", user); 2390 if(strlen(pass) > 0) 2391 fprintf(fp, "password %s\n", pass); 2392 if(!strcmp(isp, "Virgin")){ 2393 fprintf(fp, "refuse-chap\n"); 2394 fprintf(fp, "refuse-mschap\n"); 2395 fprintf(fp, "refuse-mschap-v2\n"); 2396 } 2397 else if(!strcmp(isp, "CDMA-UA")){ 2398 fprintf(fp, "refuse-chap\n"); 2399 fprintf(fp, "refuse-mschap\n"); 2400 fprintf(fp, "refuse-mschap-v2\n"); 2401 } 2402 fprintf(fp, "linkname wan%d\n", wan_unit); 2403 fprintf(fp, "modem\n"); 2404 fprintf(fp, "crtscts\n"); 2405 fprintf(fp, "noauth\n"); 2406 fprintf(fp, "noipdefault\n"); 2407 fprintf(fp, "usepeerdns\n"); 2408 fprintf(fp, "defaultroute\n"); 2409 fprintf(fp, "nopcomp\n"); 2410 fprintf(fp, "noaccomp\n"); 2411 fprintf(fp, "novj\n"); 2412 fprintf(fp, "nobsdcomp\n"); 2413 fprintf(fp, "nodeflate\n"); 2414 if(!strcmp(nvram_safe_get("modem_demand"), "1")){ 2415 fprintf(fp, "demand\n"); 2416 fprintf(fp, "idle %d\n", nvram_get_int("modem_idletime")?:30); 2417 } 2418 fprintf(fp, "persist\n"); 2419 fprintf(fp, "holdoff %s\n", nvram_invmatch(strcat_r(prefix, "pppoe_holdoff", tmp), "")?nvram_safe_get(tmp):"10"); 2420#ifdef SET_USB_MODEM_MTU_PPP 2421 modem_mtu = nvram_get_int("modem_mtu"); 2422 if (modem_mtu >= 576) 2423 fprintf(fp, "mtu %d\n", modem_mtu); 2424#endif 2425 if(!strcmp(modem_enable, "2")){ 2426 fprintf(fp, "connect \"/bin/comgt -d /dev/%s -s %s/ppp/3g/EVDO_conn.scr\"\n", modem_node, MODEM_SCRIPTS_DIR); 2427 fprintf(fp, "disconnect \"/bin/comgt -d /dev/%s -s %s/ppp/3g/EVDO_disconn.scr\"\n", modem_node, MODEM_SCRIPTS_DIR); 2428 } 2429 else if(!strcmp(modem_enable, "3")){ 2430 fprintf(fp, "connect \"/bin/comgt -d /dev/%s -s %s/ppp/3g/td_conn.scr\"\n", modem_node, MODEM_SCRIPTS_DIR); 2431 fprintf(fp, "disconnect \"/bin/comgt -d /dev/%s -s %s/ppp/3g/Generic_disconn.scr\"\n", modem_node, MODEM_SCRIPTS_DIR); 2432 } 2433 else{ 2434 if(vid == 0x0b05 && pid == 0x0302) // T500 2435 fprintf(fp, "connect \"/bin/comgt -d /dev/%s -s %s/ppp/3g/t500_conn.scr\"\n", modem_node, MODEM_SCRIPTS_DIR); 2436 else if(vid == 0x0421 && pid == 0x0612) // CS-15 2437 fprintf(fp, "connect \"/bin/comgt -d /dev/%s -s %s/ppp/3g/t500_conn.scr\"\n", modem_node, MODEM_SCRIPTS_DIR); 2438 else if(vid == 0x106c && pid == 0x3716) 2439 fprintf(fp, "connect \"/bin/comgt -d /dev/%s -s %s/ppp/3g/verizon_conn.scr\"\n", modem_node, MODEM_SCRIPTS_DIR); 2440 else if(vid == 0x1410 && pid == 0x4400) 2441 fprintf(fp, "connect \"/bin/comgt -d /dev/%s -s %s/ppp/3g/rogers_conn.scr\"\n", modem_node, MODEM_SCRIPTS_DIR); 2442 else 2443 fprintf(fp, "connect \"/bin/comgt -d /dev/%s -s %s/ppp/3g/Generic_conn.scr\"\n", modem_node, MODEM_SCRIPTS_DIR); 2444 2445 fprintf(fp, "disconnect \"/bin/comgt -d /dev/%s -s %s/ppp/3g/Generic_disconn.scr\"\n", modem_node, MODEM_SCRIPTS_DIR); 2446 } 2447 2448 fclose(fp); 2449 file_unlock(lock); 2450 return 1; 2451} 2452 2453#ifdef RTCONFIG_USB_BECEEM 2454int write_beceem_conf(const char *eth_node){ 2455 FILE *fp; 2456 int retry, lock; 2457 2458 retry = 0; 2459 while((lock = file_lock("3g")) == -1 && retry < MAX_WAIT_FILE) 2460 sleep(1); 2461 if(lock == -1){ 2462 usb_dbg("(%s): test 1.\n", eth_node); 2463 return 0; 2464 } 2465 2466 unlink(WIMAX_CONF); 2467 if((fp = fopen(WIMAX_CONF, "w+")) == NULL){ 2468 usb_dbg("(%s): test 2.\n", eth_node); 2469 file_unlock(lock); 2470 return 0; 2471 } 2472 2473 char *modem_enable = nvram_safe_get("modem_enable"); 2474 char *isp = nvram_safe_get("modem_isp"); 2475 char *user = nvram_safe_get("modem_user"); 2476 char *pass = nvram_safe_get("modem_pass"); 2477 char *ttlsid = nvram_safe_get("modem_ttlsid"); 2478 2479 if(strcmp(modem_enable, "4") || !strcmp(isp, "")){ 2480 usb_dbg("(%s): test 3.\n", eth_node); 2481 file_unlock(lock); 2482 return 0; 2483 } 2484 2485 fprintf(fp, "AuthEnabled Yes\n"); 2486 fprintf(fp, "CACertPath '/lib/firmware'\n"); 2487 fprintf(fp, "NetEntryIPRefreshEnabled Yes\n"); 2488 fprintf(fp, "IPRefreshCommand 'udhcpc -i %s -p /var/run/udhcpc%d.pid -s /tmp/udhcpc &'\n", eth_node, get_wan_unit((char*)eth_node)); 2489 fprintf(fp, "FirmwareFileName '/lib/firmware/macxvi200.bin'\n"); 2490 fprintf(fp, "ConfigFileName '/lib/firmware/macxvi.cfg'\n"); 2491 fprintf(fp, "BandwidthMHz 10\n"); 2492 fprintf(fp, "NetworkSearchTimeoutSec 10\n"); 2493 2494 if(!strcmp(isp, "Yota")){ 2495 fprintf(fp, "CenterFrequencyMHz 2505 2515 2525 2625\n"); 2496 fprintf(fp, "EAPMethod 4\n"); 2497 fprintf(fp, "ValidateServerCert Yes\n"); 2498 fprintf(fp, "CACertFileName '/tmp/Beceem_firmware/Server_CA.pem'\n"); 2499 fprintf(fp, "TLSDeviceCertFileName 'DeviceMemSlot3'\n"); 2500 fprintf(fp, "TLSDevicePrivateKeyFileName 'DeviceMemSlot2'\n"); 2501 fprintf(fp, "TLSDevicePrivateKeyPassword 'Motorola'\n"); 2502 fprintf(fp, "TLSDeviceSubCA1CertFileName 'DeviceMemSlot1'\n"); 2503 fprintf(fp, "TLSDeviceSubCA2CertFileName ''\n"); 2504 } 2505 else if(!strcmp(isp, "GMC")){ 2506 fprintf(fp, "CenterFrequencyMHz 2600 2610 2620\n"); 2507 fprintf(fp, "EAPMethod 0\n"); 2508 fprintf(fp, "ValidateServerCert No\n"); 2509 fprintf(fp, "UserIdentity '%s'\n", user); 2510 fprintf(fp, "UserPassword '%s'\n", pass); 2511 if(strlen(ttlsid) > 0) 2512 fprintf(fp, "TTLSAnonymousIdentity '%s'\n", ttlsid); 2513 } 2514 else if(!strcmp(isp, "FreshTel")){ 2515 fprintf(fp, "CenterFrequencyMHz 3405 3415 3425 3435 3445 3455 3465 3475 3485 3495 3505 3515 3525 3535 3545 3555 3565 3575 3585 3595 3417 3431 3459 3473 3487 3517 3531 3559 3573 3587\n"); 2516 fprintf(fp, "EAPMethod 0\n"); 2517 fprintf(fp, "ValidateServerCert No\n"); 2518 fprintf(fp, "UserIdentity '%s'\n", user); 2519 fprintf(fp, "UserPassword '%s'\n", pass); 2520 if(strlen(ttlsid) > 0) 2521 fprintf(fp, "TTLSAnonymousIdentity '%s'\n", ttlsid); 2522 } 2523 else if(!strcmp(isp, "Giraffe")){ 2524 fprintf(fp, "CenterFrequencyMHz 2355 2365 2375 2385 2395\n"); 2525 fprintf(fp, "EAPMethod 0\n"); 2526 fprintf(fp, "ValidateServerCert No\n"); 2527 fprintf(fp, "UserIdentity '%s'\n", user); 2528 fprintf(fp, "UserPassword '%s'\n", pass); 2529 if(strlen(ttlsid) > 0) 2530 fprintf(fp, "TTLSAnonymousIdentity '%s'\n", ttlsid); 2531 } 2532 2533 if(!strcmp(nvram_safe_get("modem_debug"), "1")){ 2534 fprintf(fp, "CSCMDebugLogLevel 4\n"); 2535 fprintf(fp, "CSCMDebugLogFileName '/lib/firmware/CM_Server_Debug.log'\n"); 2536 fprintf(fp, "CSCMDebugLogFileMaxSizeMB 1\n"); 2537 fprintf(fp, "AuthLogLevel 4\n"); 2538 fprintf(fp, "AuthLogFileName '/lib/firmware/CM_Auth.log'\n"); 2539 fprintf(fp, "AuthLogFileMaxSizeMB 1\n"); 2540 fprintf(fp, "EngineLoggingEnabled Yes\n"); 2541 fprintf(fp, "EngineLogFileName '/lib/firmware/CM_Engine.log'\n"); 2542 fprintf(fp, "EngineLogFileMaxSizeMB 1\n"); 2543 } 2544 2545 fclose(fp); 2546 file_unlock(lock); 2547 return 1; 2548} 2549 2550int write_gct_conf(void) 2551{ 2552 FILE *fp; 2553 int retry, lock; 2554 2555 retry = 0; 2556 while((lock = file_lock("3g")) == -1 && retry < MAX_WAIT_FILE) 2557 sleep(1); 2558 if(lock == -1){ 2559 usb_dbg("test 1.\n"); 2560 return 0; 2561 } 2562 2563 unlink(WIMAX_CONF); 2564 if((fp = fopen(WIMAX_CONF, "w+")) == NULL){ 2565 usb_dbg("test 2.\n"); 2566 file_unlock(lock); 2567 return 0; 2568 } 2569 2570 char *modem_enable = nvram_safe_get("modem_enable"); 2571 char *isp = nvram_safe_get("modem_isp"); 2572 char *user = nvram_safe_get("modem_user"); 2573 char *pass = nvram_safe_get("modem_pass"); 2574 char *ttlsid = nvram_safe_get("modem_ttlsid"); 2575 2576 if(strcmp(modem_enable, "4") || !strcmp(isp, "")){ 2577 usb_dbg("test 3.\n"); 2578 file_unlock(lock); 2579 return 0; 2580 } 2581 2582 if(!strcmp(isp, "FreshTel")){ 2583 fprintf(fp, "nspid=50\n"); 2584 fprintf(fp, "use_pkm=1\n"); 2585 fprintf(fp, "eap_type=5\n"); 2586 fprintf(fp, "use_nv=0\n"); 2587 fprintf(fp, "identity=\"%s\"\n", user); 2588 fprintf(fp, "password=\"%s\"\n", pass); 2589 if(strlen(ttlsid) > 0) 2590 fprintf(fp, "anonymous_identity=\"%s\"\n", ttlsid); 2591 fprintf(fp, "ca_cert_null=1\n"); 2592 fprintf(fp, "dev_cert_null=1\n"); 2593 fprintf(fp, "cert_nv=0\n"); 2594 } 2595 else if(!strcmp(isp, "Yes")){ 2596 fprintf(fp, "nspid=0\n"); 2597 fprintf(fp, "use_pkm=1\n"); 2598 fprintf(fp, "eap_type=5\n"); 2599 fprintf(fp, "use_nv=0\n"); 2600 fprintf(fp, "identity=\"%s\"\n", user); 2601 fprintf(fp, "password=\"%s\"\n", pass); 2602 if(strlen(ttlsid) > 0) 2603 fprintf(fp, "anonymous_identity=\"%s\"\n", ttlsid); 2604 fprintf(fp, "ca_cert_null=1\n"); 2605 fprintf(fp, "dev_cert_null=1\n"); 2606 fprintf(fp, "cert_nv=0\n"); 2607 } 2608 2609 if(!strcmp(nvram_safe_get("modem_debug"), "1")){ 2610 fprintf(fp, "wimax_verbose_level=1\n"); 2611 fprintf(fp, "wpa_debug_level=3\n"); 2612 fprintf(fp, "log_file=\"%s\"\n", WIMAX_LOG); 2613 } 2614 else 2615 fprintf(fp, "log_file=\"\"\n"); 2616 fprintf(fp, "event_script=\"\"\n"); 2617 2618 fclose(fp); 2619 file_unlock(lock); 2620 return 1; 2621} 2622#endif 2623#endif // RTCONFIG_USB_MODEM 2624 2625#ifdef RTCONFIG_USB 2626 2627#ifdef RTCONFIG_BCMARM 2628 2629int hotplug_pid = -1; 2630FILE *fp = NULL; 2631#define hotplug_dbg(fmt, args...) (\ 2632{ \ 2633 char err_str[100] = {0}; \ 2634 char err_str2[100] = {0}; \ 2635 if (hotplug_pid == -1) hotplug_pid = getpid(); \ 2636 if (!fp) fp = fopen("/tmp/usb_err", "a+"); \ 2637 sprintf(err_str, fmt, ##args); \ 2638 sprintf(err_str2, "PID:%d %s", hotplug_pid, err_str); \ 2639 fwrite(err_str2, strlen(err_str2), 1, fp); \ 2640 fflush(fp); \ 2641} \ 2642) 2643 2644#define LOCK_FILE "/tmp/hotplug_block_lock" 2645 2646int hotplug_usb_power(int port, int boolOn) 2647{ 2648 char name[] = "usbport%d"; /* 1 ~ 99 ports */ 2649 unsigned long gpiomap; 2650 int usb_gpio; 2651 2652 if (port > MAX_USB_PORT) 2653 return -1; 2654 2655 sprintf(name, "usbport%d", port); 2656 usb_gpio = bcmgpio_getpin(name, BCMGPIO_UNDEFINED); 2657 if (usb_gpio == BCMGPIO_UNDEFINED) 2658 return 0; 2659 if (bcmgpio_connect(usb_gpio, BCMGPIO_DIRN_OUT)) 2660 return 0; 2661 2662 gpiomap = (1 << usb_gpio); 2663 bcmgpio_out(gpiomap, boolOn? gpiomap: 0); 2664 bcmgpio_disconnect(usb_gpio); 2665 return 1; 2666} 2667 2668/* Return number of usbports enabled */ 2669int hotplug_usb_init(void) 2670{ 2671 /* Enable VBUS via GPIOs for port1 and port2 */ 2672 int i, count; 2673 2674 for (count = 0, i = 1; i <= MAX_USB_PORT; i++) { 2675 if (hotplug_usb_power(i, TRUE) > 0) 2676 count++; 2677 } 2678 return count; 2679} 2680 2681#define PHYSDEVPATH_DEPTH_USB_LPORT 4 /* Depth is from 0 */ 2682 2683#if 0 2684static void 2685hotplug_usb_power_recover(void) 2686{ 2687 char *physdevpath; 2688 char *tok = NULL; 2689 int depth = 0, root_hub_num = -1, usb_lport = -1, nv_port = -1; 2690 2691 if ((physdevpath = getenv("PHYSDEVPATH")) == NULL) 2692 return; 2693 2694 /* Get root_hub and logical port number. 2695 * PHYSDEVPATH in sysfs is /devices/pci/hcd/root_hub/root_hub_num-lport/..... 2696 */ 2697 tok = strtok(physdevpath, "/"); 2698 2699 while (tok != NULL) { 2700 if (PHYSDEVPATH_DEPTH_USB_LPORT == depth) { 2701 sscanf(tok, "%d-%d", &root_hub_num, &usb_lport); 2702 break; 2703 } 2704 depth++; 2705 tok = strtok(NULL, "/"); 2706 } 2707 2708 if (tok && (root_hub_num != -1) && (usb_lport != -1)) { 2709 /* Translate logical port to nvram setting port */ 2710 nv_port = (usb_lport == 1) ? 2 : 1; 2711 2712 hotplug_usb_power(nv_port, FALSE); 2713 sleep(1); 2714 hotplug_usb_power(nv_port, TRUE); 2715 } 2716} 2717#endif 2718 2719/* Optimize performance */ 2720#define READ_AHEAD_KB_BUF 1024 2721#define READ_AHEAD_CONF "/sys/block/%s/queue/read_ahead_kb" 2722 2723static void 2724optimize_block_device(const char *devname) 2725{ 2726 char blkdev[8] = {0}; 2727 char read_ahead_conf[64] = {0}; 2728 char cmdbuf[64] = {0}; 2729 int err; 2730 2731 memset(blkdev, 0, sizeof(blkdev)); 2732 strncpy(blkdev, devname, 3); 2733 sprintf(read_ahead_conf, READ_AHEAD_CONF, blkdev); 2734 sprintf(cmdbuf, "echo %d > %s", READ_AHEAD_KB_BUF, read_ahead_conf); 2735 err = system(cmdbuf); 2736 hotplug_dbg("err = %d\n", err); 2737 2738 if (err) { 2739 hotplug_dbg("read ahead: unsuccess %d!\n", err); 2740 } 2741} 2742 2743int 2744hotplug_block(void) 2745{ 2746 char *action = NULL, *minor = NULL; 2747 char *major = NULL, *driver = NULL; 2748 int retry = 3, lock_fd = -1; 2749 struct flock lk_info = {0}; 2750 2751 if (!(action = getenv("ACTION")) || 2752 !(minor = getenv("MINOR")) || 2753 !(driver = getenv("PHYSDEVDRIVER")) || 2754 !(major = getenv("MAJOR"))) 2755 { 2756 return EINVAL; 2757 } 2758 2759 hotplug_dbg("env %s %s!\n", action, driver); 2760 if (strncmp(driver, "sd", 2)) 2761 { 2762 return EINVAL; 2763 } 2764 2765 if ((lock_fd = open(LOCK_FILE, O_RDWR|O_CREAT, 0666)) < 0) { 2766 hotplug_dbg("Failed opening lock file LOCK_FILE: %s\n", strerror(errno)); 2767 return -1; 2768 } 2769 2770 while (--retry) { 2771 lk_info.l_type = F_WRLCK; 2772 lk_info.l_whence = SEEK_SET; 2773 lk_info.l_start = 0; 2774 lk_info.l_len = 0; 2775 if (!fcntl(lock_fd, F_SETLKW, &lk_info)) break; 2776 } 2777 2778 if (!retry) { 2779 hotplug_dbg("Failed locking LOCK_FILE: %s\n", strerror(errno)); 2780 return -1; 2781 } 2782 2783 if (!strcmp(action, "add")) { 2784 hotplug_dbg("add block!\n"); 2785 2786 } else if (!strcmp(action, "remove")) { 2787 hotplug_dbg("usb power recover!\n"); 2788#if 0 2789 hotplug_usb_power_recover(); // Mark off this. It will let the modem can't be switched. 2790#endif 2791 } else { 2792 hotplug_dbg("unsupported action!\n"); 2793 } 2794 2795 close(lock_fd); 2796 unlink(LOCK_FILE); 2797 return 0; 2798} 2799#endif /* RTCONFIG_BCMARM */ 2800#endif // RTCONFIG_USB 2801 2802// 1: add, 0: remove. 2803int check_hotplug_action(const char *action){ 2804 if(!strcmp(action, "remove")) 2805 return 0; 2806 else 2807 return 1; 2808} 2809 2810int set_usb_common_nvram(const char *action, const char *device_name, const char *usb_node, const char *known_type){ 2811 char type[16], vid[8], pid[8], manufacturer[256], product[256], serial[256], speed[256]; 2812 char been_type[16]; 2813 char port_path[8]; 2814 char prefix[] = "usb_pathXXXXXXXXXXXXXXXXX_", tmp[100]; 2815 char *ptr; 2816 unsigned int val; 2817 2818 if(get_path_by_node(usb_node, port_path, 8) == NULL){ 2819 usb_dbg("(%s): Fail to get usb path.\n", usb_node); 2820 return 0; 2821 } 2822 2823 if(!check_hotplug_action(action)){ 2824 if(known_type == NULL){ 2825 snprintf(prefix, sizeof(prefix), "usb_path%s", port_path); 2826 snprintf(been_type, 16, "%s", nvram_safe_get(prefix)); 2827 2828 if(strcmp(been_type, "storage") || strlen(nvram_safe_get(strcat_r(prefix, "_speed", tmp))) <= 0) 2829 nvram_unset(prefix); 2830 if(strlen(nvram_safe_get(strcat_r(prefix, "_vid", tmp))) > 0) 2831 nvram_unset(tmp); 2832 if(strlen(nvram_safe_get(strcat_r(prefix, "_pid", tmp))) > 0) 2833 nvram_unset(tmp); 2834 if(strlen(nvram_safe_get(strcat_r(prefix, "_manufacturer", tmp))) > 0) 2835 nvram_unset(tmp); 2836 if(strlen(nvram_safe_get(strcat_r(prefix, "_product", tmp))) > 0) 2837 nvram_unset(tmp); 2838 if(strlen(nvram_safe_get(strcat_r(prefix, "_serial", tmp))) > 0) 2839 nvram_unset(tmp); 2840 if(strcmp(been_type, "storage") && strlen(nvram_safe_get(strcat_r(prefix, "_speed", tmp))) > 0) 2841 nvram_unset(tmp); 2842 if(strlen(nvram_safe_get(strcat_r(prefix, "_node", tmp))) > 0) 2843 nvram_unset(tmp); 2844 if(strlen(nvram_safe_get(strcat_r(prefix, "_act_def", tmp))) > 0) 2845 nvram_unset(tmp); 2846 } 2847 else{ 2848 if(!strcmp(known_type, "storage")){ 2849 ptr = (char *)device_name+strlen(device_name)-1; 2850 if(!isdigit(*ptr)){ // disk 2851 snprintf(prefix, sizeof(prefix), "usb_path%s", port_path); 2852 if(strlen(nvram_safe_get(strcat_r(prefix, "_vid", tmp))) <= 0) 2853 nvram_unset(prefix); 2854 // for ATE. { 2855 // Jerry5Chang added for unmount case. 2012.12.03 2856 nvram_unset(strcat_r(prefix, "_removed", tmp)); 2857 nvram_unset(strcat_r(prefix, "_act", tmp)); // for DM. 2858 nvram_unset(strcat_r(prefix, "_fs_path0", tmp)); 2859#ifdef RTCONFIG_DISK_MONITOR 2860 nvram_unset(strcat_r(prefix, "_pool_error", tmp)); 2861#endif 2862 nvram_unset(strcat_r(prefix, "_speed", tmp)); 2863 // for ATE. } 2864 } 2865 else if(!strncmp(device_name, "mmcblk", 6)){ // SD card. 2866 snprintf(prefix, sizeof(prefix), "usb_path%s", port_path); 2867 nvram_unset(prefix); 2868 nvram_unset(strcat_r(prefix, "_node", tmp)); 2869 // for ATE. { 2870 // Jerry5Chang added for unmount case. 2012.12.03 2871 nvram_unset(strcat_r(prefix, "_removed", tmp)); 2872 nvram_unset(strcat_r(prefix, "_act", tmp)); // for DM. 2873 nvram_unset(strcat_r(prefix, "_fs_path0", tmp)); 2874#ifdef RTCONFIG_DISK_MONITOR 2875 nvram_unset(strcat_r(prefix, "_pool_error", tmp)); 2876#endif 2877 nvram_unset(strcat_r(prefix, "_speed", tmp)); 2878 // for ATE. } 2879 } 2880 } 2881 } 2882 } 2883 else{ 2884 snprintf(prefix, sizeof(prefix), "usb_path%s", port_path); 2885 memset(been_type, 0, 16); 2886 strcpy(been_type, nvram_safe_get(prefix)); 2887 if(strlen(been_type) > 0){ 2888#ifdef RTCONFIG_USB_PRINTER 2889 if(!strcmp(been_type, "printer")){ // Top priority 2890 return 0; 2891 } 2892 else 2893#endif 2894#ifdef RTCONFIG_USB_MODEM 2895 if(!strcmp(been_type, "modem")){ // 2nd priority 2896#ifdef RTCONFIG_USB_PRINTER 2897 if(strcmp(known_type, "printer")) 2898#endif 2899 return 0; 2900 } 2901 else 2902#endif 2903 if(!strcmp(been_type, "storage")){ 2904#if defined(RTCONFIG_USB_PRINTER) || defined(RTCONFIG_USB_MODEM) 2905 if( 2906#ifdef RTCONFIG_USB_PRINTER 2907 strcmp(known_type, "printer") 2908#else 2909 1 2910#endif 2911 && 2912#ifdef RTCONFIG_USB_MODEM 2913 strcmp(known_type, "modem") 2914#else 2915 1 2916#endif 2917 ) 2918#endif 2919 return 0; 2920 } 2921 else 2922 { // unknown device. 2923 return 0; 2924 } 2925 } 2926 if(known_type != NULL) 2927 nvram_set(prefix, known_type); 2928 else if(get_device_type_by_node(usb_node, type, 16) != NULL) 2929 nvram_set(prefix, type); 2930 else // unknown device. 2931 return 0; 2932 2933 strcat_r(prefix, "_vid", tmp); 2934 if ((val = get_usb_vid(usb_node)) != 0) { 2935 snprintf(vid, sizeof(vid), "%04x", val); 2936 nvram_set(tmp, vid); 2937 } 2938 2939 strcat_r(prefix, "_pid", tmp); 2940 if ((val = get_usb_pid(usb_node)) != 0) { 2941 snprintf(pid, sizeof(pid), "%04x", val); 2942 nvram_set(tmp, pid); 2943 } 2944 2945 strcat_r(prefix, "_manufacturer", tmp); 2946 if(get_usb_manufacturer(usb_node, manufacturer, 256) != NULL && strlen(manufacturer) > 0) 2947 nvram_set(tmp, manufacturer); 2948 2949 strcat_r(prefix, "_product", tmp); 2950 if(get_usb_product(usb_node, product, 256) != NULL && strlen(product) > 0) 2951 nvram_set(tmp, product); 2952 2953 strcat_r(prefix, "_serial", tmp); 2954 if(get_usb_serial(usb_node, serial, 256) != NULL && strlen(serial) > 0) 2955 nvram_set(tmp, serial); 2956 2957 strcat_r(prefix, "_speed", tmp); 2958 if(get_usb_speed(usb_node, speed, 256) != NULL && strlen(speed) > 0) 2959 nvram_set(tmp, speed); 2960 2961 strcat_r(prefix, "_node", tmp); 2962 nvram_set(tmp, usb_node); 2963 } 2964 2965 return 0; 2966} 2967 2968#ifdef BCM_MMC 2969int asus_mmc(const char *device_name, const char *action){ 2970#ifdef RTCONFIG_USB 2971 char usb_port[32]; 2972 int isLock; 2973 char env_dev[64], env_major[64], env_port[64]; 2974 char port_path[8]; 2975 char prefix[] = "usb_pathXXXXXXXXXXXXXXXXX_", tmp[100]; 2976 char *ptr; 2977 2978 usb_dbg("(%s): action=%s.\n", device_name, action); 2979 2980 if(!strcmp(nvram_safe_get("stop_mmc"), "1")){ 2981 usb_dbg("(%s): stop_mmc be set.\n", device_name); 2982 return 0; 2983 } 2984 2985 if(get_device_type_by_device(device_name) != DEVICE_TYPE_DISK){ 2986 usb_dbg("(%s): The device is not a mmc device.\n", device_name); 2987 return 0; 2988 } 2989 2990 // Check Lock. 2991 if((isLock = file_lock((char *)device_name)) == -1){ 2992 usb_dbg("(%s): Can't set the file lock!\n", device_name); 2993 return 0; 2994 } 2995 2996 ptr = (char *)device_name+strlen(device_name)-1; 2997 2998 snprintf(usb_port, 32, "%s", SDCARD_PORT); 2999 3000 if(!check_hotplug_action(action)){ 3001 snprintf(prefix, sizeof(prefix), "usb_path_%s", device_name); 3002 nvram_unset(strcat_r(prefix, "_label", tmp)); 3003 3004 if(get_path_by_node(usb_port, port_path, 8) == NULL){ 3005 usb_dbg("(%s): Fail to get usb path.\n", usb_port); 3006 file_unlock(isLock); 3007 return 0; 3008 } 3009 3010 set_usb_common_nvram(action, device_name, usb_port, "storage"); 3011 3012 usb_dbg("(%s): Remove MMC.\n", device_name); 3013 3014 putenv("INTERFACE=8/0/0"); 3015 putenv("ACTION=remove"); 3016 putenv("PRODUCT=asus_mmc"); 3017 snprintf(env_dev, 64, "DEVICENAME=%s", device_name); 3018 putenv(env_dev); 3019 putenv("SUBSYSTEM=block"); 3020 snprintf(env_major, 64, "MAJOR=%d", USB_DISK_MAJOR); 3021 putenv(env_major); 3022 putenv("PHYSDEVBUS=scsi"); 3023 3024 eval("hotplug", "block"); 3025 3026 unsetenv("INTERFACE"); 3027 unsetenv("ACTION"); 3028 unsetenv("PRODUCT"); 3029 unsetenv("DEVICENAME"); 3030 unsetenv("SUBSYSTEM"); 3031 unsetenv("MAJOR"); 3032 unsetenv("PHYSDEVBUS"); 3033 3034#ifdef RTCONFIG_MMC_LED 3035 led_control(LED_MMC, LED_OFF); 3036#endif 3037 3038 file_unlock(isLock); 3039 return 0; 3040 } 3041 3042 // there is a static usb node with the SD card, so don't need to set the usb_node record. 3043 if(get_path_by_node(usb_port, port_path, 8) == NULL){ 3044 usb_dbg("(%s): Fail to get usb path.\n", usb_port); 3045 file_unlock(isLock); 3046 return 0; 3047 } 3048 3049 snprintf(prefix, sizeof(prefix), "usb_path%s", port_path); 3050 3051 // There is only a hotplug with the partition of the SD card. 3052 //if(!isdigit(*ptr)){ // disk 3053 // set USB common nvram. 3054 set_usb_common_nvram(action, device_name, usb_port, "storage"); 3055 3056 // for DM. 3057 if(!strcmp(nvram_safe_get(prefix), "storage")){ 3058 nvram_set(strcat_r(prefix, "_act", tmp), device_name); 3059 } 3060 //} 3061 3062 putenv("INTERFACE=8/0/0"); 3063 putenv("ACTION=add"); 3064 putenv("PRODUCT=asus_mmc"); 3065 snprintf(env_dev, 64, "DEVICENAME=%s", device_name); 3066 putenv(env_dev); 3067 putenv("SUBSYSTEM=block"); 3068 snprintf(env_port, 64, "USBPORT=%s", usb_port); 3069 putenv(env_port); 3070 snprintf(env_major, 64, "MAJOR=%d", USB_DISK_MAJOR); 3071 putenv(env_major); 3072 putenv("PHYSDEVBUS=scsi"); 3073 3074 eval("hotplug", "block"); 3075 3076 unsetenv("INTERFACE"); 3077 unsetenv("ACTION"); 3078 unsetenv("PRODUCT"); 3079 unsetenv("DEVICENAME"); 3080 unsetenv("SUBSYSTEM"); 3081 unsetenv("USBPORT"); 3082 unsetenv("MAJOR"); 3083 unsetenv("PHYSDEVBUS"); 3084 3085#ifdef RTCONFIG_MMC_LED 3086 led_control(LED_MMC, LED_ON); 3087#endif 3088 3089 usb_dbg("(%s): Success!\n", device_name); 3090 file_unlock(isLock); 3091 3092#endif 3093 return 1; 3094} 3095#endif 3096 3097int asus_sd(const char *device_name, const char *action){ 3098#ifdef RTCONFIG_USB 3099 char usb_node[32], usb_port[32]; 3100 int isLock; 3101 char nvram_value[32]; 3102 char env_dev[64], env_major[64], env_port[64]; 3103 char port_path[8]; 3104 char buf1[32]; 3105 char prefix[] = "usb_pathXXXXXXXXXXXXXXXXX_", tmp[100]; 3106#ifdef RTCONFIG_XHCIMODE 3107 int usb2mode = 0; 3108 unsigned int vid, pid; 3109 char speed[256]; 3110#endif 3111 char *ptr; 3112 int model = get_model(); 3113#ifdef RTCONFIG_USB_PRINTER 3114 int retry; 3115#endif 3116 3117 usb_dbg("(%s): action=%s.\n", device_name, action); 3118 3119 if(!strcmp(nvram_safe_get("stop_sd"), "1")){ 3120 usb_dbg("(%s): stop_sd be set.\n", device_name); 3121 return 0; 3122 } 3123 3124 if(get_device_type_by_device(device_name) != DEVICE_TYPE_DISK){ 3125 usb_dbg("(%s): The device is not a sd device.\n", device_name); 3126 return 0; 3127 } 3128 3129 // Check Lock. 3130 if((isLock = file_lock((char *)device_name)) == -1){ 3131 usb_dbg("(%s): Can't set the file lock!\n", device_name); 3132 return 0; 3133 } 3134 3135 ptr = (char *)device_name+strlen(device_name)-1; 3136 3137 // If remove the device? 3138 if(!check_hotplug_action(action)){ 3139 memset(buf1, 0, 32); 3140 sprintf(buf1, "usb_path_%s", device_name); 3141 memset(usb_node, 0, 32); 3142 strcpy(usb_node, nvram_safe_get(buf1)); 3143 nvram_unset(buf1); 3144 nvram_unset(strcat_r(buf1, "_label", tmp)); 3145 3146 snprintf(nvram_value, 32, "%s", nvram_safe_get("usb_modem_act_reset_path")); 3147 if(!strcmp(nvram_value, usb_node)){ 3148 usb_dbg("(%s): the device is resetting...(%s)\n", device_name, action); 3149 file_unlock(isLock); 3150 return 0; 3151 } 3152 3153 if(get_path_by_node(usb_node, port_path, 8) == NULL){ 3154 usb_dbg("(%s): Fail to get usb path.\n", usb_node); 3155 file_unlock(isLock); 3156 return 0; 3157 } 3158 3159 snprintf(prefix, sizeof(prefix), "usb_path%s", port_path); 3160 3161#ifdef RTCONFIG_XHCIMODE 3162 if(atoi(port_path) == 1 && nvram_get_int("usb_usb3") != 1 && !isdigit(*ptr)){ 3163 // Get the xhci mode. 3164 if(f_read_string("/sys/module/xhci_hcd/parameters/usb2mode", buf1, 32) <= 0){ 3165 usb_dbg("(%s): Fail to get xhci mode.\n", device_name); 3166 file_unlock(isLock); 3167 return 0; 3168 } 3169 usb2mode = atoi(buf1); 3170 3171 snprintf(nvram_value, 32, "%s", nvram_safe_get(strcat_r(prefix, "_speed", tmp))); 3172 if(usb2mode != 0 && strlen(nvram_value) > 0 && strcmp(nvram_value, "5000")) 3173 notify_rc("restart_xhcimode 0"); 3174 } 3175#endif 3176 3177#ifdef RTCONFIG_USB_MODEM 3178 snprintf(buf1, 32, "%s.%s", USB_MODESWITCH_CONF, port_path); 3179 unlink(buf1); 3180#endif 3181 3182 if(strlen(usb_node) > 0){ 3183 // for the storage interface of the second modem. 3184 if(!strcmp(nvram_safe_get(prefix), "modem") && strcmp(usb_node, nvram_safe_get("usb_modem_act_path"))){ 3185 usb_dbg("(%s): Reset the usb path nvram.\n", device_name); 3186 set_usb_common_nvram(action, device_name, usb_node, NULL); 3187 } 3188 else if(!strcmp(nvram_safe_get(prefix), "storage") && !isdigit(*ptr)) 3189 set_usb_common_nvram(action, device_name, usb_node, "storage"); 3190 usb_dbg("(%s): Remove Storage on USB node %s.\n", device_name, usb_node); 3191 } 3192 else 3193 usb_dbg("(%s): Remove a unknown-port Storage.\n", device_name); 3194 3195 putenv("INTERFACE=8/0/0"); 3196 putenv("ACTION=remove"); 3197 putenv("PRODUCT=asus_sd"); 3198 snprintf(env_dev, 64, "DEVICENAME=%s", device_name); 3199 putenv(env_dev); 3200 putenv("SUBSYSTEM=block"); 3201 snprintf(env_major, 64, "MAJOR=%d", USB_DISK_MAJOR); 3202 putenv(env_major); 3203 putenv("PHYSDEVBUS=scsi"); 3204 3205 eval("hotplug", "block"); 3206 3207 unsetenv("INTERFACE"); 3208 unsetenv("ACTION"); 3209 unsetenv("PRODUCT"); 3210 unsetenv("DEVICENAME"); 3211 unsetenv("SUBSYSTEM"); 3212 unsetenv("MAJOR"); 3213 unsetenv("PHYSDEVBUS"); 3214 3215 file_unlock(isLock); 3216 return 0; 3217 } 3218 3219 // Get USB node. 3220 if(get_usb_node_by_device(device_name, usb_node, 32) == NULL){ 3221 usb_dbg("(%s): Fail to get usb node.\n", device_name); 3222 file_unlock(isLock); 3223 return 0; 3224 } 3225 else 3226 usb_dbg("(%s): Got usb node: %s.\n", device_name, usb_node); 3227 3228 if(get_path_by_node(usb_node, port_path, 8) == NULL){ 3229 usb_dbg("(%s): Fail to get usb path.\n", usb_node); 3230 file_unlock(isLock); 3231 return 0; 3232 } 3233 3234 // Get USB port. 3235 if(get_usb_port_by_string(usb_node, usb_port, 32) == NULL){ 3236 usb_dbg("(%s): Fail to get usb port.\n", usb_node); 3237 file_unlock(isLock); 3238 return 0; 3239 } 3240 else 3241 usb_dbg("(%s): Got usb port: %s.\n", device_name, usb_port); 3242 3243 memset(buf1, 0, 32); 3244 sprintf(buf1, "usb_path_%s", device_name); 3245 nvram_set(buf1, usb_node); 3246 3247#ifdef RTCONFIG_XHCIMODE 3248 if(get_usb_speed(usb_node, speed, 256) != NULL && strcmp(speed, "5000")){ 3249 goto after_change_xhcimode; 3250 } 3251 3252 // Get the xhci mode. 3253 if(f_read_string("/sys/module/xhci_hcd/parameters/usb2mode", buf1, 32) <= 0){ 3254 usb_dbg("(%s): Fail to get xhci mode.\n", device_name); 3255 file_unlock(isLock); 3256 return 0; 3257 } 3258 usb2mode = atoi(buf1); 3259 3260 if(nvram_get_int("stop_xhcimode") == 1) 3261 usb_dbg("(%s): stop the xhci mode.\n", device_name); 3262 else if(nvram_get_int("usb_usb3") != 1){ 3263 // Get VID & PID 3264 if ((vid = get_usb_vid(usb_node)) == 0 || 3265 (pid = get_usb_pid(usb_node)) == 0) { 3266 usb_dbg("(%s): Fail to get VID/PID of USB(%s).\n", device_name, usb_node); 3267 file_unlock(isLock); 3268 return 0; 3269 } 3270 3271 if((vid == 0x0bc2 && (pid == 0xa0a1 || pid == 0x5031)) 3272 || (vid == 0x174c && pid == 0x5106) 3273 ){ 3274 if(usb2mode != 1){ 3275 if(!isdigit(*ptr)) 3276 notify_rc("restart_xhcimode 1"); 3277 file_unlock(isLock); 3278 return 0; 3279 } 3280 } 3281 else if(usb2mode == 0 || usb2mode == 1){ 3282 if(!isdigit(*ptr)) 3283 notify_rc("restart_xhcimode 2"); 3284 file_unlock(isLock); 3285 return 0; 3286 } 3287 } 3288 else if(usb2mode != 0){ 3289 if(!isdigit(*ptr)) 3290 notify_rc("restart_xhcimode 0"); 3291 file_unlock(isLock); 3292 return 0; 3293 } 3294 3295after_change_xhcimode: 3296#endif 3297 3298#ifdef RTCONFIG_USB_PRINTER 3299 // Wait if there is the printer interface. 3300 retry = 0; 3301 while(!hadPrinterModule() && retry < MAX_WAIT_PRINTER_MODULE){ 3302 ++retry; 3303 sleep(1); // Wait the printer module to be ready. 3304 } 3305#ifdef REMOVE 3306 // When the dongle was plugged off during changing the mode, this delay will confuse the procedure. 3307 // TODO: Find the strange printers which need this delay. Will let them be the special case. 3308 sleep(1); // Wait the printer interface to be ready. 3309#endif 3310 3311 if(hadPrinterInterface(usb_node)){ 3312 usb_dbg("(%s): Had Printer interface on Port %s.\n", device_name, usb_node); 3313 file_unlock(isLock); 3314 return 0; 3315 } 3316#endif 3317 3318 snprintf(prefix, sizeof(prefix), "usb_path%s", port_path); 3319 3320 memset(nvram_value, 0, 32); 3321 strcpy(nvram_value, nvram_safe_get(prefix)); 3322 if(strcmp(nvram_value, "") && strcmp(nvram_value, "storage")){ 3323 usb_dbg("(%s): Had other interfaces(%s) on Port %s.\n", device_name, nvram_value, usb_port); 3324 file_unlock(isLock); 3325 return 0; 3326 } 3327 3328 if(!isdigit(*ptr)){ // disk 3329#ifdef RTCONFIG_NOTIFICATION_CENTER 3330 char buf[MAX_NVRAM_SPACE], str[32]; 3331 char *name; 3332 int plugged_disk = 0; 3333 int ntevent_firstdisk = nvram_get_int("ntevent_firstdisk"); 3334 int ntevent_nodiskuse = nvram_get_int("ntevent_nodiskuse"); 3335#if defined(RTCONFIG_USB_XHCI) || defined(RTCONFIG_ETRON_XHCI) 3336 int ntevent_disableusb3 = nvram_get_int("ntevent_disableusb3"); 3337 int usb_usb3 = nvram_get_int("usb_usb3"); 3338#endif 3339 3340 if(!ntevent_firstdisk){ 3341 nvram_getall(buf, sizeof(buf)); 3342 for(name = buf; *name; name += strlen(name)+1){ 3343 // non usb nvrams 3344 if(strncmp(name, "usb_path", 8)) 3345 continue; 3346 3347 // non disk utility nvrams 3348 if(strstr(name, "_diskmon_")) 3349 continue; 3350 3351 if(!isdigit(*(name+8))) 3352 continue; 3353 3354 plugged_disk = 1; 3355 break; 3356 } 3357 3358 if(!plugged_disk){ 3359 usb_dbg("(%s): Got the first storage on Port %s.\n", device_name, usb_port); 3360 snprintf(str, 32, "0x%x", HINT_USB_FIRSTIME_CHECK_EVENT); 3361 eval("Notify_Event2NC", str, ""); 3362 nvram_set("ntevent_firstdisk", "1"); 3363 3364 if(!ntevent_nodiskuse) 3365 nvram_set("ntevent_nodiskuse", "1"); 3366 3367#if defined(RTCONFIG_USB_XHCI) || defined(RTCONFIG_ETRON_XHCI) 3368 if(!usb_usb3 && !ntevent_disableusb3){ 3369 snprintf(str, 32, "0x%x", HINT_USB3_WITHOUT_ENHANCE_EVENT); 3370 eval("Notify_Event2NC", str, ""); 3371 nvram_set("ntevent_disableusb3", "1"); 3372 } 3373#endif 3374 3375 nvram_commit(); 3376 } 3377 } 3378#endif 3379 3380 // set USB common nvram. 3381 set_usb_common_nvram(action, device_name, usb_node, "storage"); 3382 3383 // for DM. 3384 if(!strcmp(nvram_safe_get(prefix), "storage")){ 3385 nvram_set(strcat_r(prefix, "_act", tmp), device_name); 3386 } 3387 } 3388 3389 if (have_usb3_led(model)) { 3390 if (is_usb3_port(usb_node)) 3391 nvram_set_int("usb_led_id", LED_USB3); 3392 else 3393 nvram_set_int("usb_led_id", LED_USB); 3394 } 3395 3396 kill_pidfile_s("/var/run/usbled.pid", SIGUSR1); // inform usbled to start blinking USB LED 3397 3398 putenv("INTERFACE=8/0/0"); 3399 putenv("ACTION=add"); 3400 putenv("PRODUCT=asus_sd"); 3401 snprintf(env_dev, 64, "DEVICENAME=%s", device_name); 3402 putenv(env_dev); 3403 putenv("SUBSYSTEM=block"); 3404 snprintf(env_port, 64, "USBPORT=%s", usb_port); 3405 putenv(env_port); 3406 3407 eval("hotplug", "block"); 3408 3409 kill_pidfile_s("/var/run/usbled.pid", SIGUSR2); // inform usbled to stop blinking USB LED 3410 if (have_usb3_led(model)) 3411 nvram_unset("usb_led_id"); 3412 3413 unsetenv("INTERFACE"); 3414 unsetenv("ACTION"); 3415 unsetenv("PRODUCT"); 3416 unsetenv("DEVICENAME"); 3417 unsetenv("SUBSYSTEM"); 3418 unsetenv("USBPORT"); 3419 3420#ifdef RTCONFIG_BCMARM 3421 /* Optimize performance */ 3422 optimize_block_device(device_name); 3423#endif 3424 3425 usb_dbg("(%s): Success!\n", device_name); 3426 file_unlock(isLock); 3427 3428#endif // RTCONFIG_USB 3429 return 1; 3430} 3431 3432int asus_lp(const char *device_name, const char *action){ 3433#ifdef RTCONFIG_USB_PRINTER 3434 char usb_node[32]; 3435 int u2ec_fifo; 3436 int isLock; 3437 char port_path[8]; 3438 char buf1[32]; 3439 char prefix[] = "usb_pathXXXXXXXXXXXXXXXXX_", tmp[100]; 3440 usb_dbg("(%s): action=%s.\n", device_name, action); 3441 3442 if(!strcmp(nvram_safe_get("stop_lp"), "1")){ 3443 usb_dbg("(%s): stop_lp be set.\n", device_name); 3444 return 0; 3445 } 3446 3447 if(get_device_type_by_device(device_name) != DEVICE_TYPE_PRINTER){ 3448 usb_dbg("(%s): The device is not a printer.\n", device_name); 3449 return 0; 3450 } 3451 3452 // Check Lock. 3453 if((isLock = file_lock((char *)device_name)) == -1){ 3454 usb_dbg("(%s): Can't set the file lock!\n", device_name); 3455 return 0; 3456 } 3457 3458 // If remove the device? 3459 if(!check_hotplug_action(action)){ 3460 memset(buf1, 0, 32); 3461 sprintf(buf1, "usb_path_%s", device_name); 3462 memset(usb_node, 0, 32); 3463 strcpy(usb_node, nvram_safe_get(buf1)); 3464 nvram_unset(buf1); 3465 3466 if(strlen(usb_node) > 0){ 3467 u2ec_fifo = open(U2EC_FIFO, O_WRONLY | O_NONBLOCK); 3468 write(u2ec_fifo, "r", 1); 3469 close(u2ec_fifo); 3470 3471 set_usb_common_nvram(action, device_name, usb_node, "printer"); 3472 usb_dbg("(%s): Remove Printer on USB node %s.\n", device_name, usb_node); 3473 } 3474 else 3475 usb_dbg("(%s): Remove a unknown-port Printer.\n", device_name); 3476 3477 file_unlock(isLock); 3478 return 0; 3479 } 3480 3481 // Get USB node. 3482 if(get_usb_node_by_device(device_name, usb_node, 32) == NULL){ 3483 usb_dbg("(%s): Fail to get usb node.\n", device_name); 3484 file_unlock(isLock); 3485 return 0; 3486 } 3487 3488 if(get_path_by_node(usb_node, port_path, 8) == NULL){ 3489 usb_dbg("(%s): Fail to get usb path.\n", usb_node); 3490 file_unlock(isLock); 3491 return 0; 3492 } 3493 3494 memset(buf1, 0, 32); 3495 sprintf(buf1, "usb_path_%s", device_name); 3496 nvram_set(buf1, usb_node); 3497 3498 // set USB common nvram. 3499 set_usb_common_nvram(action, device_name, usb_node, "printer"); 3500 3501 snprintf(prefix, sizeof(prefix), "usb_path%s", port_path); 3502 3503 // Don't support the second printer device on a DUT. 3504 // Only see the other usb port. 3505 memset(buf1, 0, 32); 3506 strncpy(buf1, nvram_safe_get("u2ec_serial"), 32); 3507 if(strlen(buf1) > 0 && strcmp(nvram_safe_get(strcat_r(prefix, "_serial", tmp)), buf1)){ 3508 // We would show the second printer device but didn't let it work. 3509 // Because it didn't set the nvram: usb_path%d_act. 3510 usb_dbg("(%s): Already had the printer device in the other USB port!\n", device_name); 3511 file_unlock(isLock); 3512 return 0; 3513 } 3514 3515 u2ec_fifo = open(U2EC_FIFO, O_WRONLY | O_NONBLOCK); 3516 write(u2ec_fifo, "a", 1); 3517 close(u2ec_fifo); 3518 3519 usb_dbg("(%s): Success!\n", device_name); 3520 file_unlock(isLock); 3521#endif // RTCONFIG_USB_PRINTER 3522 return 1; 3523} 3524 3525int asus_sg(const char *device_name, const char *action){ 3526#ifdef RTCONFIG_USB_MODEM 3527 char usb_node[32]; 3528 unsigned int vid, pid; 3529 int isLock; 3530 char switch_file[32]; 3531 char port_path[8]; 3532 char nvram_name[32], nvram_value[32]; 3533 usb_dbg("(%s): action=%s.\n", device_name, action); 3534 3535 if(!strcmp(nvram_safe_get("stop_sg"), "1")){ 3536 usb_dbg("(%s): stop_sg be set.\n", device_name); 3537 return 0; 3538 } 3539 3540 if(get_device_type_by_device(device_name) != DEVICE_TYPE_SG){ 3541 usb_dbg("(%s): The device is not a sg one.\n", device_name); 3542 return 0; 3543 } 3544 3545 // Don't support the second modem device on a DUT. 3546 snprintf(nvram_value, 32, "%s", nvram_safe_get("usb_modem_act_path")); 3547 if(strlen(nvram_value) > 0 && strcmp(nvram_value, usb_node)){ 3548 usb_dbg("(%s): Already had a running modem.\n", device_name); 3549 return 0; 3550 } 3551 3552 // If remove the device? 3553 if(!check_hotplug_action(action)){ 3554 usb_dbg("(%s): Remove sg device.\n", device_name); 3555 return 0; 3556 } 3557 3558 // Check Lock. 3559 if((isLock = file_lock((char *)device_name)) == -1){ 3560 usb_dbg("(%s): Can't set the file lock!\n", device_name); 3561 return 0; 3562 } 3563 3564 // Get USB node. 3565 if(get_usb_node_by_device(device_name, usb_node, 32) == NULL){ 3566 usb_dbg("(%s): Fail to get usb node.\n", device_name); 3567 file_unlock(isLock); 3568 return 0; 3569 } 3570 3571 if(get_path_by_node(usb_node, port_path, 8) == NULL){ 3572 usb_dbg("(%s): Fail to get usb path.\n", usb_node); 3573 file_unlock(isLock); 3574 return 0; 3575 } 3576 3577 memset(nvram_name, 0, 32); 3578 sprintf(nvram_name, "usb_path%s", port_path); 3579 memset(nvram_value, 0, 32); 3580 strcpy(nvram_value, nvram_safe_get(nvram_name)); 3581 //if(!strcmp(nvram_value, "printer") || !strcmp(nvram_value, "modem")){ 3582 memset(switch_file, 0, 32); 3583 sprintf(switch_file, "%s.%s", USB_MODESWITCH_CONF, port_path); 3584 if(strcmp(nvram_value, "") && check_if_file_exist(switch_file)){ 3585 usb_dbg("(%s): Already there was a other interface(%s).\n", usb_node, nvram_value); 3586 file_unlock(isLock); 3587 return 0; 3588 } 3589 3590 // Get VID & PID 3591 if ((vid = get_usb_vid(usb_node)) == 0 || 3592 (pid = get_usb_pid(usb_node)) == 0) { 3593 usb_dbg("(%s): Fail to get VID/PID of USB(%s).\n", device_name, usb_node); 3594 file_unlock(isLock); 3595 return 0; 3596 } 3597 3598 // initial the config file of usb_modeswitch. 3599 /*if(!strcmp(nvram_safe_get("Dev3G"), "AUTO") 3600 && (vid == 0x19d2 || vid == 0x1a8d) 3601 ){ 3602 modprobe("cdrom"); 3603 modprobe("sr_mod"); 3604 sleep(1); // wait the module be ready. 3605 } 3606 else//*/ 3607#ifdef RTCONFIG_USB_BECEEM 3608 // Could use usb_modeswitch to switch the Beceem's dongles, besides ZTE's. 3609 if(!strcmp(nvram_safe_get("beceem_switch"), "1") 3610 && is_beceem_dongle(0, vid, pid)){ 3611 usb_dbg("(%s): Running switchmode...\n", device_name); 3612 xstart("switchmode"); 3613 } 3614 else 3615 if(is_gct_dongle(0, vid, pid)){ 3616 if(strcmp(nvram_safe_get("stop_sg_remove"), "1")){ 3617 usb_dbg("(%s): Running gctwimax -D...\n", device_name); 3618 xstart("gctwimax", "-D"); 3619 } 3620 } 3621 else 3622#endif 3623 if(vid == 0x1199) 3624 ; // had do usb_modeswitch before. 3625 else if(vid == 0x19d2 && pid == 0x0167) // MF821's modem mode. 3626 ; // do nothing. 3627 else if(is_create_file_dongle(vid, pid)) 3628 ; // do nothing. 3629 else if(init_3g_param(port_path, vid, pid)){ 3630 if(strcmp(nvram_safe_get("stop_sg_remove"), "1")){ 3631 usb_dbg("(%s): Running usb_modeswitch...\n", device_name); 3632 xstart("usb_modeswitch", "-c", switch_file); 3633 } 3634 } 3635 else if(atoi(port_path) == 3) 3636 ; // usb_path3 is worked for the built-in card reader. 3637 else{ 3638 if(strcmp(nvram_safe_get("stop_sg_remove"), "1")) 3639 { 3640 usb_dbg("(%s): insmod cdrom!\n", device_name); 3641 modprobe("cdrom"); 3642 modprobe("sr_mod"); 3643 sleep(1); // wait the module be ready. 3644 } 3645 } 3646 3647 usb_dbg("(%s): Success!\n", device_name); 3648 file_unlock(isLock); 3649#endif // RTCONFIG_USB_MODEM 3650 return 1; 3651} 3652 3653int asus_sr(const char *device_name, const char *action){ 3654#ifdef RTCONFIG_USB_MODEM 3655 char usb_node[32]; 3656 unsigned int vid, pid; 3657 int isLock; 3658 char eject_cmd[128]; 3659 char port_path[8]; 3660 char nvram_name[32], nvram_value[32]; 3661 char sg_device[32]; 3662 usb_dbg("(%s): action=%s.\n", device_name, action); 3663 3664 if(!strcmp(nvram_safe_get("stop_cd"), "1")){ 3665 usb_dbg("(%s): stop_cd be set.\n", device_name); 3666 return 0; 3667 } 3668 3669 if(get_device_type_by_device(device_name) != DEVICE_TYPE_CD){ 3670 usb_dbg("(%s): The device is not a CD one.\n", device_name); 3671 return 0; 3672 } 3673 3674 // Don't support the second modem device on a DUT. 3675 snprintf(nvram_value, 32, "%s", nvram_safe_get("usb_modem_act_path")); 3676 if(strlen(nvram_value) > 0 && strcmp(nvram_value, usb_node)){ 3677 usb_dbg("(%s): Already had a running modem.\n", device_name); 3678 return 0; 3679 } 3680 3681 // If remove the device? 3682 if(!check_hotplug_action(action)){ 3683 usb_dbg("(%s): Remove CD device.\n", device_name); 3684 3685 return 0; 3686 } 3687 3688 // Check Lock. 3689 if((isLock = file_lock((char *)device_name)) == -1){ 3690 usb_dbg("(%s): Can't set the file lock!\n", device_name); 3691 return 0; 3692 } 3693 3694 // Get USB node. 3695 if(get_usb_node_by_device(device_name, usb_node, 32) == NULL){ 3696 usb_dbg("(%s): Fail to get usb node.\n", device_name); 3697 file_unlock(isLock); 3698 return 0; 3699 } 3700 3701 if(get_path_by_node(usb_node, port_path, 8) == NULL){ 3702 usb_dbg("(%s): Fail to get usb path.\n", usb_node); 3703 file_unlock(isLock); 3704 return 0; 3705 } 3706 3707 snprintf(nvram_name, 32, "usb_path%s", port_path); 3708 snprintf(nvram_value, 32, "%s", nvram_safe_get(nvram_name)); 3709 3710 // Storage interface is first up with some composite devices, 3711 // so needs to wait that other interfaces wake up. 3712 int i; 3713 for(i = 0; i < 3; ++i){ 3714 if(strcmp(nvram_value, "printer") && strcmp(nvram_value, "modem")){ 3715 usb_dbg("%s: wait for the printer/modem interface...\n", __FUNCTION__); 3716 sleep(1); 3717 snprintf(nvram_value, 32, "%s", nvram_safe_get(nvram_name)); 3718 } 3719 else 3720 break; 3721 } 3722 if(!strcmp(nvram_value, "printer") || !strcmp(nvram_value, "modem")){ 3723 usb_dbg("(%s): Already there was a other interface(%s).\n", usb_node, nvram_value); 3724 file_unlock(isLock); 3725 return 0; 3726 } 3727 3728 // Get VID & PID 3729 if ((vid = get_usb_vid(usb_node)) == 0 || 3730 (pid = get_usb_pid(usb_node)) == 0) { 3731 usb_dbg("(%s): Fail to get VID/PID of USB(%s).\n", device_name, usb_node); 3732 file_unlock(isLock); 3733 return 0; 3734 } 3735 3736#ifdef RTCONFIG_USB_BECEEM 3737 if(is_gct_dongle(0, vid, pid)){ 3738 if(strcmp(nvram_safe_get("stop_cd_remove"), "1")){ 3739 usb_dbg("(%s): Running gctwimax -D...\n", device_name); 3740 xstart("gctwimax", "-D"); 3741 } 3742 } 3743 else 3744#endif 3745 if(is_storage_cd(0, vid, pid)){ 3746 usb_dbg("(%s): skip to eject CD...\n", device_name); 3747 } 3748 else if(strcmp(nvram_safe_get("stop_cd_remove"), "1")){ 3749 usb_dbg("(%s): Running sdparm...\n", device_name); 3750 3751 snprintf(eject_cmd, 128, "/dev/%s", device_name); 3752 eval("sdparm", "--command=eject", eject_cmd); 3753 sleep(1); 3754 3755 if(find_sg_of_device(device_name, sg_device, sizeof(sg_device)) != NULL){ 3756 snprintf(eject_cmd, 128, "/dev/%s", sg_device); 3757 eval("sdparm", "--command=eject", eject_cmd); 3758 sleep(1); 3759 } 3760 3761 modprobe_r("sr_mod"); 3762 modprobe_r("cdrom"); 3763 } 3764 3765 usb_dbg("(%s): Success!\n", device_name); 3766 file_unlock(isLock); 3767#endif // RTCONFIG_USB_MODEM 3768 return 1; 3769} 3770 3771int asus_tty(const char *device_name, const char *action){ 3772#ifdef RTCONFIG_USB_MODEM 3773 char usb_node[32]; 3774 unsigned int vid, pid; 3775 char *ptr, interface_name[16]; 3776 int got_Int_endpoint = 0; 3777 int isLock = -1, isLock_tty = -1; 3778 char current_act[16], current_def[16]; 3779 int cur_val, tmp_val; 3780 int retry; 3781 int wan_unit; 3782 char port_path[8]; 3783 char buf1[32]; 3784 char act_dev[8]; 3785 char prefix[] = "usb_pathXXXXXXXXXXXXXXXXX_", tmp[100]; 3786 usb_dbg("(%s): action=%s.\n", device_name, action); 3787 3788 if(!strcmp(nvram_safe_get("stop_modem"), "1")){ 3789 usb_dbg("(%s): stop_modem be set.\n", device_name); 3790 return 0; 3791 } 3792 3793 if(get_device_type_by_device(device_name) != DEVICE_TYPE_MODEM){ 3794 usb_dbg("(%s): The device is not a Modem node.\n", device_name); 3795 return 0; 3796 } 3797 3798 // Check Lock. 3799 if((isLock = file_lock((char *)device_name)) == -1){ 3800 usb_dbg("(%s): Can't set the file lock!\n", device_name); 3801 return 0; 3802 } 3803 3804 // If remove the device? 3805 if(!check_hotplug_action(action)){ 3806 snprintf(current_act, 16, "%s", nvram_safe_get("usb_modem_act_path")); 3807 snprintf(buf1, 32, "usb_path_%s", device_name); 3808 snprintf(usb_node, 32, "%s", nvram_safe_get(buf1)); 3809 nvram_unset(buf1); 3810 snprintf(act_dev, 8, "%s", nvram_safe_get("usb_modem_act_dev")); 3811 3812 usb_dbg("(%s): usb_modem_act_path=%s.\n", usb_node, current_act); 3813 if(!strcmp(current_act, usb_node)){ 3814 if(get_path_by_node(usb_node, port_path, 8) == NULL){ 3815 usb_dbg("(%s): Fail to get usb path.\n", usb_node); 3816 file_unlock(isLock); 3817 return 0; 3818 } 3819 3820 if(strncmp(act_dev, "usb", 3) && strncmp(act_dev, "eth", 3)){ 3821 snprintf(prefix, sizeof(prefix), "usb_path%s", port_path); 3822 nvram_unset(strcat_r(prefix, "_act", tmp)); 3823 nvram_unset(strcat_r(prefix, "_act_def", tmp)); 3824 3825 clean_modem_state(1); 3826 } 3827 else 3828 clean_modem_state(0); 3829 3830#if 0 3831 // TODO: for the bad CTF. After updating CTF, need to mark these codes. 3832 if(nvram_match("ctf_disable_modem", "1")){ 3833 set_usb_common_nvram(action, device_name, usb_node, "modem"); 3834 3835 nvram_set("ctf_disable_modem", "0"); 3836 nvram_commit(); 3837 notify_rc_and_wait("reboot"); 3838 file_unlock(isLock); 3839 3840 return 0; 3841 } 3842#endif 3843 // Modem remove action. 3844 unlink(PPP_CONF_FOR_3G); 3845 3846 if ((wan_unit = get_usbif_dualwan_unit()) < 0) { 3847 usb_dbg("(%s): in the current dual wan mode, didn't support the USB modem.\n", device_name); 3848 file_unlock(isLock); 3849 return 0; 3850 } 3851 3852 /* Stop pppd */ 3853 stop_pppd(wan_unit); 3854 3855 killall_tk("usb_modeswitch"); 3856 killall_tk("sdparm"); 3857 3858 retry = 0; 3859 while(hadOptionModule() && retry < 3){ 3860 usb_dbg("(%s): Remove the option module.\n", device_name); 3861 modprobe_r("option"); 3862 ++retry; 3863 } 3864 3865#if LINUX_KERNEL_VERSION >= KERNEL_VERSION(2,6,36) 3866 retry = 0; 3867 while(hadWWANModule() && retry < 3){ 3868 usb_dbg("(%s): Remove the USB WWAN module.\n", device_name); 3869 modprobe_r("usb_wwan"); 3870 ++retry; 3871 } 3872#endif 3873 3874 retry = 0; 3875 while(hadSerialModule() && retry < 3){ 3876 usb_dbg("(%s): Remove the serial module.\n", device_name); 3877 modprobe_r("usbserial"); 3878 ++retry; 3879 } 3880 3881 retry = 0; 3882 while(hadACMModule() && retry < 3){ 3883 usb_dbg("(%s): Remove the acm module.\n", device_name); 3884 modprobe_r("cdc-acm"); 3885 ++retry; 3886 } 3887 } 3888 3889 if(strlen(usb_node) > 0){ 3890 set_usb_common_nvram(action, device_name, usb_node, "modem"); 3891 usb_dbg("(%s): Remove the modem node on USB node %s.\n", device_name, usb_node); 3892 } 3893 else 3894 usb_dbg("(%s): Remove a unknown-port Modem.\n", device_name); 3895 3896 file_unlock(isLock); 3897 return 0; 3898 } 3899 3900 // Get USB node. 3901 if(get_usb_node_by_device(device_name, usb_node, 32) == NULL){ 3902 usb_dbg("(%s): Fail to get usb node.\n", device_name); 3903 file_unlock(isLock); 3904 return 0; 3905 } 3906 3907 if(get_path_by_node(usb_node, port_path, 8) == NULL){ 3908 usb_dbg("(%s): Fail to get usb path.\n", usb_node); 3909 file_unlock(isLock); 3910 return 0; 3911 } 3912 3913 memset(buf1, 0, 32); 3914 sprintf(buf1, "usb_path_%s", device_name); 3915 nvram_set(buf1, usb_node); 3916 3917 // Get VID & PID 3918 if ((vid = get_usb_vid(usb_node)) == 0 || 3919 (pid = get_usb_pid(usb_node)) == 0) { 3920 usb_dbg("(%s): Fail to get VID/PID of USB(%s).\n", device_name, usb_node); 3921 file_unlock(isLock); 3922 return 0; 3923 } 3924 3925 // Don't support the second modem device on a DUT. 3926 // Only see the other usb port, because in the same port there are more modem interfaces and they need to compare. 3927 snprintf(buf1, 32, "%s", nvram_safe_get("usb_modem_act_path")); 3928 if(strlen(buf1) > 0 && strcmp(buf1, usb_node)){ 3929 // We would show the second modem device but didn't let it work. 3930 // Because it didn't set the nvram: usb_path%d_act. 3931 usb_dbg("(%s): Already had the modem device in the other USB port!\n", device_name); 3932 file_unlock(isLock); 3933 return 0; 3934 } 3935 else if(strlen(buf1) <= 0){ 3936 nvram_set("usb_modem_act_path", usb_node); 3937 snprintf(buf1, 32, "%u", vid); 3938 nvram_set("usb_modem_act_vid", buf1); 3939 snprintf(buf1, 32, "%u", pid); 3940 nvram_set("usb_modem_act_pid", buf1); 3941 } 3942 3943 // Find the control node of modem. 3944 // Get Interface name. 3945 if(get_interface_by_device(device_name, interface_name, sizeof(interface_name)) == NULL){ 3946 usb_dbg("(%s): Fail to get usb interface.\n", device_name); 3947 file_unlock(isLock); 3948 return 0; 3949 } 3950 3951 snprintf(prefix, sizeof(prefix), "usb_path%s", port_path); 3952 3953 // Check Lock and wait 3954 while((isLock_tty = file_lock((char *)__FUNCTION__)) == -1){ 3955 usb_dbg("(%s): lock and wait!\n", device_name); 3956 usleep(5000); 3957 } 3958 // check the current working node of modem. 3959 memset(current_act, 0, 16); 3960 strcpy(current_act, nvram_safe_get(strcat_r(prefix, "_act", tmp))); 3961 memset(current_def, 0, 16); 3962 strcpy(current_def, nvram_safe_get(strcat_r(prefix, "_act_def", tmp))); 3963 usb_dbg("(%s): interface_name=%s, current_act=%s, current_def=%s.\n", device_name, interface_name, current_act, current_def); 3964 3965 if(strlen(current_act) > 0 && get_device_type_by_device(current_act) != DEVICE_TYPE_MODEM && get_device_type_by_device(current_act) != DEVICE_TYPE_DISK) // for ECM, NCM, QMI...etc. 3966 ; 3967 else if(isSerialNode(device_name)){ 3968 // Find the endpoint: 03(Int). 3969 got_Int_endpoint = get_interface_Int_endpoint(interface_name); 3970 usb_dbg("(%s): got_Int_endpoint(%d)!\n", device_name, got_Int_endpoint); 3971 if(!got_Int_endpoint){ 3972 // Set the default node be ttyUSB0, because there is no Int endpoint in some dongles. 3973 if(strcmp(device_name, "ttyUSB0")){ 3974 usb_dbg("(%s): No Int endpoint!\n", device_name); 3975 file_unlock(isLock_tty); 3976 file_unlock(isLock); 3977 return 0; 3978 } 3979 else if(!strcmp(current_act, "") || get_device_type_by_device(current_act) == DEVICE_TYPE_DISK){ 3980 usb_dbg("(%s): set_default_node!\n", device_name); 3981 nvram_set(strcat_r(prefix, "_act_def", tmp), "1"); 3982 memset(current_def, 0, 16); 3983 strcpy(current_def, "1"); 3984 } 3985 else { 3986 usb_dbg("(%s): has act(%s) already!\n", device_name, current_act); 3987 file_unlock(isLock_tty); 3988 file_unlock(isLock); 3989 return 0; 3990 } 3991 } 3992 3993 if(vid == 0x0f3d && pid == 0x68aa){ 3994 if(!strcmp(device_name, "ttyUSB3")){ 3995 nvram_set(strcat_r(prefix, "_act", tmp), device_name); 3996 memset(current_act, 0, 16); 3997 strncpy(current_act, device_name, 16); 3998 } 3999 else{ 4000 file_unlock(isLock_tty); 4001 file_unlock(isLock); 4002 return 0; 4003 } 4004 } 4005 else if(!strcmp(current_act, "") || get_device_type_by_device(current_act) == DEVICE_TYPE_DISK){ 4006 nvram_set(strcat_r(prefix, "_act", tmp), device_name); 4007 memset(current_act, 0, 16); 4008 strncpy(current_act, device_name, 16); 4009 } 4010 else{ 4011 cur_val = -1; 4012 if(strlen(current_act) > 6) { 4013 errno = 0; 4014 cur_val = strtol(¤t_act[6], &ptr, 10); 4015 if(errno != 0 || ¤t_act[6] == ptr){ 4016 cur_val = -1; 4017 } 4018 } 4019 4020 errno = 0; 4021 tmp_val = strtol(&device_name[6], &ptr, 10); 4022 if(errno != 0 || &device_name[6] == ptr){ 4023 usb_dbg("(%s): Can't get the working node.\n", device_name); 4024 file_unlock(isLock_tty); 4025 file_unlock(isLock); 4026 return 0; 4027 } 4028 else if(cur_val != -1 && cur_val < tmp_val && strcmp(current_def, "1")){ // get the smaller node safely. 4029usb_dbg("(%s): cur_val=%d, tmp_val=%d, set_default_node=%s.\n", device_name, cur_val, tmp_val, current_def); 4030 usb_dbg("(%s): Skip to write PPP's conf.\n", device_name); 4031 file_unlock(isLock_tty); 4032 file_unlock(isLock); 4033 return 0; 4034 } 4035 else{ 4036usb_dbg("(%s): current_act=%s, device_name=%s.\n", device_name, current_act, device_name); 4037usb_dbg("(%s): cur_val=%d, tmp_val=%d.\n", device_name, cur_val, tmp_val); 4038 nvram_set(strcat_r(prefix, "_act", tmp), device_name); 4039 memset(current_act, 0, 16); 4040 strncpy(current_act, device_name, 16); 4041 if(got_Int_endpoint){ 4042 nvram_set(strcat_r(prefix, "_act_def", tmp), ""); 4043 memset(current_def, 0, 16); 4044 } 4045 } 4046 } 4047 4048 // Only let act node trigger the dial procedure and avoid the wrong node to write the PPP conf. 4049 if(strcmp(device_name, current_act)){ 4050 usb_dbg("(%s): Success!\n", device_name); 4051 file_unlock(isLock_tty); 4052 file_unlock(isLock); 4053 return 0; 4054 } 4055 4056 // Wait all ttyUSB nodes to ready. 4057 sleep(1); 4058 } 4059 else{ // isACMNode(device_name). 4060 // Find the control interface of cdc-acm. 4061 if(!isACMInterface(interface_name, 1, vid, pid)){ 4062 usb_dbg("(%s): Not control interface!\n", device_name); 4063 file_unlock(isLock_tty); 4064 file_unlock(isLock); 4065 return 0; 4066 } 4067 4068 if(!strcmp(device_name, "ttyACM0")){ 4069 nvram_set(strcat_r(prefix, "_act", tmp), device_name); 4070 } 4071 else{ 4072 file_unlock(isLock_tty); 4073 file_unlock(isLock); 4074 return 0; 4075 } 4076 } 4077 4078#ifdef RTCONFIG_DUALWAN 4079 // If the node is the default node without the Int endpoint, skip to autorun restart_wan_if. 4080 if(!nvram_match("wans_mode", "off") && strcmp(current_def, "1")){ 4081#endif 4082 if ((wan_unit = get_usbif_dualwan_unit()) >= 0) { 4083 // show the manual-setting dongle in Networkmap when it was plugged after reboot. 4084 init_3g_param(port_path, vid, pid); 4085#if 0 4086 // TODO: for the bad CTF. After updating CTF, need to mark these codes. 4087 if(nvram_invmatch("ctf_disable", "1") && nvram_invmatch("ctf_disable_modem", "1")){ 4088 nvram_set("ctf_disable_modem", "1"); 4089 nvram_commit(); 4090 notify_rc_and_wait("reboot"); 4091 file_unlock(isLock_tty); 4092 file_unlock(isLock); 4093 4094 return 0; 4095 } 4096#endif 4097 } 4098#ifdef RTCONFIG_DUALWAN 4099 else 4100usb_dbg("Didn't support the USB connection now...\n"); 4101 } 4102#endif 4103 4104 usb_dbg("(%s): Success!\n", device_name); 4105 file_unlock(isLock_tty); 4106 file_unlock(isLock); 4107#endif // RTCONFIG_USB_MODEM 4108 return 1; 4109} 4110 4111// Beceem's driver: drxvi314 identifies only one dongle. 4112int asus_usbbcm(const char *device_name, const char *action){ 4113#ifdef RTCONFIG_USB_BECEEM 4114 char usb_node[32]; 4115 int isLock; 4116 char port_path[8]; 4117 char buf1[32]; 4118 char prefix[] = "usb_pathXXXXXXXXXXXXXXXXX_", tmp[100]; 4119 usb_dbg("(%s): action=%s.\n", device_name, action); 4120 4121 if(!strcmp(nvram_safe_get("stop_modem"), "1")){ 4122 usb_dbg("(%s): stop_modem be set.\n", device_name); 4123 return 0; 4124 } 4125 4126 if(get_device_type_by_device(device_name) != DEVICE_TYPE_BECEEM){ 4127 usb_dbg("(%s): The device is not a Modem node.\n", device_name); 4128 return 0; 4129 } 4130 4131 // Check Lock. 4132 if((isLock = file_lock((char *)device_name)) == -1){ 4133 usb_dbg("(%s): Can't set the file lock!\n", device_name); 4134 return 0; 4135 } 4136 4137 // If remove the device? 4138 if(!check_hotplug_action(action)){ 4139 memset(buf1, 0, 32); 4140 sprintf(buf1, "usb_path_%s", device_name); 4141 memset(usb_node, 0, 32); 4142 strncpy(usb_node, nvram_safe_get(buf1), 32); 4143 nvram_unset(buf1); 4144 4145 if(get_path_by_node(usb_node, port_path, 8) == NULL){ 4146 usb_dbg("(%s): Fail to get usb path.\n", usb_node); 4147 file_unlock(isLock); 4148 return 0; 4149 } 4150 4151 snprintf(prefix, sizeof(prefix), "usb_path%s", port_path); 4152 if(!strcmp(nvram_safe_get(strcat_r(prefix, "_act", tmp)), device_name)) 4153 nvram_unset(tmp); 4154 nvram_unset("usb_modem_act_path"); 4155 4156 if(strlen(usb_node) > 0){ 4157 // Modem remove action. 4158 unlink(WIMAX_CONF); 4159 4160 killall_tk("usb_modeswitch"); 4161 4162 set_usb_common_nvram(action, device_name, usb_node, "modem"); 4163 usb_dbg("(%s): Remove the Beceem node on USB node %s.\n", device_name, usb_node); 4164 } 4165 else 4166 usb_dbg("(%s): Remove a unknown-port Modem.\n", device_name); 4167 4168 file_unlock(isLock); 4169 return 0; 4170 } 4171 4172 // Get USB node. 4173 if(get_usb_node_by_device(device_name, usb_node, 32) == NULL){ 4174 usb_dbg("(%s): Fail to get usb node.\n", device_name); 4175 file_unlock(isLock); 4176 return 0; 4177 } 4178 4179 if(get_path_by_node(usb_node, port_path, 8) == NULL){ 4180 usb_dbg("(%s): Fail to get usb path.\n", usb_node); 4181 file_unlock(isLock); 4182 return 0; 4183 } 4184 4185 memset(buf1, 0, 32); 4186 sprintf(buf1, "usb_path_%s", device_name); 4187 nvram_set(buf1, usb_node); 4188 4189 // Don't support the second modem device on a DUT. 4190 // Only see the other usb port, because in the same port there are more modem interfaces and they need to compare. 4191 snprintf(buf1, 32, "%s", nvram_safe_get("usb_modem_act_path")); 4192 if(strlen(buf1) > 0 && strcmp(buf1, usb_node)){ 4193 // We would show the second modem device but didn't let it work. 4194 // Because it didn't set the nvram: usb_path%d_act. 4195 usb_dbg("(%s): Already had the modem device in the other USB port!\n", device_name); 4196 file_unlock(isLock); 4197 return 0; 4198 } 4199 else if(strlen(buf1) <= 0) 4200 nvram_set("usb_modem_act_path", usb_node); 4201 4202 // check the current working node of modem. 4203 snprintf(prefix, sizeof(prefix), "usb_path%s", port_path); 4204 4205 nvram_set(strcat_r(prefix, "_act", tmp), device_name); 4206 4207 usb_dbg("(%s): Success!\n", device_name); 4208 file_unlock(isLock); 4209#endif // RTCONFIG_USB_BECEEM 4210 return 1; 4211} 4212 4213int asus_usb_interface(const char *device_name, const char *action){ 4214#if defined(RTCONFIG_USB) || defined(RTCONFIG_USB_PRINTER) || defined(RTCONFIG_USB_MODEM) 4215 char usb_node[32], usb_port[32]; 4216#ifdef RTCONFIG_USB_MODEM 4217 unsigned int vid, pid; 4218 char modem_cmd[128], buf[128]; 4219#endif 4220#if defined(RTCONFIG_USB_PRINTER) || defined(RTCONFIG_USB_BECEEM) 4221 int retry; 4222#endif 4223 int isLock; 4224 char device_type[16]; 4225 char nvram_usb_path[32]; 4226 char prefix[] = "usb_pathXXXXXXXXXXXXXXXXX_", tmp[100]; 4227 char conf_file[32]; 4228 char port_path[8]; 4229 int port_num; 4230 int turn_on_led = 1; 4231 char class_path[PATH_MAX], class[10] = ""; 4232 4233 usb_dbg("(%s): action=%s.\n", device_name, action); 4234 4235 if(!strcmp(nvram_safe_get("stop_ui"), "1")){ 4236 usb_dbg("(%s): stop_ui be set.\n", device_name); 4237 return 0; 4238 } 4239 4240 // Check Lock. 4241 if((isLock = file_lock((char *)device_name)) == -1){ 4242 usb_dbg("(%s): Can't set the file lock!\n", device_name); 4243 return 0; 4244 } 4245 4246 // Get USB node. 4247 if(get_usb_node_by_string(device_name, usb_node, 32) == NULL){ 4248 usb_dbg("(%s): Fail to get usb node.\n", device_name); 4249 file_unlock(isLock); 4250 return 0; 4251 } 4252 4253 if(get_path_by_node(usb_node, port_path, 8) == NULL){ 4254 usb_dbg("(%s): Fail to get usb path.\n", usb_node); 4255 file_unlock(isLock); 4256 return 0; 4257 } 4258 4259 // Get USB port. 4260 if(get_usb_port_by_string(usb_node, usb_port, 32) == NULL){ 4261 usb_dbg("(%s): Fail to get usb port.\n", usb_node); 4262 file_unlock(isLock); 4263 return 0; 4264 } 4265 4266 port_num = get_usb_port_number(usb_port); 4267 if(!port_num){ 4268 usb_dbg("(%s): Fail to get usb port number.\n", usb_port); 4269 file_unlock(isLock); 4270 return 0; 4271 } 4272 4273 // check the current working node of modem. 4274 snprintf(prefix, sizeof(prefix), "usb_path%s", port_path); 4275 4276 // If remove the device? Handle the remove hotplug of the printer and modem. 4277 if(!check_hotplug_action(action)){ 4278 snprintf(nvram_usb_path, 32, "usb_led%d", port_num); 4279 if (!strcmp(nvram_safe_get(nvram_usb_path), "1")) { 4280 int turn_off_led = 1; 4281 disk_info_t *disk_list, *disk_info; 4282 4283 disk_list = read_disk_data(); 4284 for (disk_info = disk_list; disk_info != NULL && turn_off_led; disk_info = disk_info->next) { 4285 if (port_num != atoi(disk_info->port)) 4286 continue; 4287 4288 turn_off_led = 0; 4289 _dprintf("Another disk exist on USB port %d, don't turn off USB LED\n", port_num); 4290 } 4291 free_disk_data(&disk_list); 4292 4293 if (turn_off_led) 4294 nvram_unset(nvram_usb_path); 4295 } 4296 4297 strcpy(device_type, nvram_safe_get(prefix)); 4298 4299#ifdef RTCONFIG_USB_MODEM 4300 snprintf(conf_file, 32, "%s.%s", USB_MODESWITCH_CONF, port_path); 4301 unlink(conf_file); 4302 4303 if(!strcmp(device_type, "modem") && !strcmp(usb_node, nvram_safe_get("usb_modem_act_path"))){ 4304 snprintf(buf, 128, "%s", nvram_safe_get(strcat_r(prefix, "_act", tmp))); 4305 4306 // remove the device between adding interface and adding tty. 4307 modprobe_r("option"); 4308#if LINUX_KERNEL_VERSION >= KERNEL_VERSION(2,6,36) 4309 modprobe_r("usb_wwan"); 4310#endif 4311 modprobe_r("usbserial"); 4312 modprobe_r("cdc-acm"); 4313#ifdef RTCONFIG_USB_BECEEM 4314 modprobe_r("drxvi314"); 4315 4316 vid = atoi(nvram_safe_get("usb_modem_act_vid")); 4317 pid = atoi(nvram_safe_get("usb_modem_act_pid")); 4318 if(is_samsung_dongle(1, vid, pid) || is_gct_dongle(1, vid, pid)){ 4319 nvram_unset("usb_modem_act_path"); 4320 nvram_unset("usb_modem_act_vid"); 4321 nvram_unset("usb_modem_act_pid"); 4322 nvram_unset(tmp); 4323 } 4324#endif 4325 4326#ifndef RTCONFIG_INTERNAL_GOBI 4327 // When ACM dongles are removed, there are no removed hotplugs of ttyACM nodes. 4328 if(!strncmp(buf, "ttyACM", 6)){ 4329 // No methods let DUT restore the normal state after removing the ACM dongle. 4330 notify_rc("reboot"); 4331 file_unlock(isLock); 4332 return 0; 4333 } 4334#endif 4335 } 4336#endif 4337 4338 if(strlen(device_type) > 0){ 4339 // Remove USB common nvram. 4340 set_usb_common_nvram(action, device_name, usb_node, NULL); 4341 4342 usb_dbg("(%s): Remove %s interface on USB node %s.\n", device_name, device_type, usb_node); 4343 } 4344 else 4345 usb_dbg("(%s): Remove a unknown-type interface.\n", device_name); 4346 4347 file_unlock(isLock); 4348 return 0; 4349 } 4350 4351 /* Don't turn on USB LED for USB HUB. */ 4352 snprintf(class_path, sizeof(class_path), "/sys/bus/usb/devices/%s/%s", 4353 device_name, strchr(device_name, ':')? "bInterfaceClass" : "bDeviceClass"); 4354 if (f_read_string(class_path, class, sizeof(class)) > 0 && atoi(class) == 9) 4355 turn_on_led = 0; 4356 4357 snprintf(nvram_usb_path, 32, "usb_led%d", port_num); 4358#ifdef RTCONFIG_INTERNAL_GOBI 4359 if(nvram_get_int("usb_buildin") == port_num) 4360 ; //skip this LED 4361 else 4362#endif /* RTCONFIG_INTERNAL_GOBI */ 4363 if (turn_on_led && strcmp(nvram_safe_get(nvram_usb_path), "1")) 4364 nvram_set(nvram_usb_path, "1"); 4365 4366#ifdef RTCONFIG_USB_MODEM 4367 // Get VID & PID 4368 if ((vid = get_usb_vid(usb_node)) == 0 || 4369 (pid = get_usb_pid(usb_node)) == 0) { 4370 usb_dbg("(%s): Fail to get VID/PID of USB(%s).\n", device_name, usb_node); 4371 file_unlock(isLock); 4372 return 0; 4373 } 4374 4375 // there is no any bounded drivers with Some Sierra dongles in the default state. 4376 if(vid == 0x1199 && isStorageInterface(device_name)){ 4377 if(init_3g_param(port_path, vid, pid)){ 4378 4379 if(strcmp(nvram_safe_get("stop_ui_remove"), "1")){ 4380 usb_dbg("(%s): Running usb_modeswitch...\n", device_name); 4381 snprintf(modem_cmd, 128, "%s.%s", USB_MODESWITCH_CONF, port_path); 4382 xstart("usb_modeswitch", "-c", modem_cmd); 4383 } 4384 4385 file_unlock(isLock); 4386 return 0; 4387 } 4388 } 4389 4390 if(!isSerialInterface(device_name, 1, vid, pid) 4391 && !isACMInterface(device_name, 1, vid, pid) 4392 && !isRNDISInterface(device_name, vid, pid) 4393 && !isCDCETHInterface(device_name) 4394 && !isNCMInterface(device_name) 4395#ifdef RTCONFIG_USB_BECEEM 4396 && !isGCTInterface(device_name) 4397#endif 4398 ){ 4399 usb_dbg("(%s): Not modem interface.\n", device_name); 4400 file_unlock(isLock); 4401 return 0; 4402 } 4403#endif 4404 4405#ifdef RTCONFIG_USB_PRINTER 4406 // Wait if there is the printer interface. 4407 retry = 0; 4408 while(!hadPrinterModule() && retry < MAX_WAIT_PRINTER_MODULE){ 4409 ++retry; 4410 sleep(1); // Wait the printer module to be ready. 4411 } 4412 sleep(1); // Wait the printer interface to be ready. 4413 4414 if(hadPrinterInterface(usb_node)){ 4415 usb_dbg("(%s): Had Printer interface on Port %s.\n", device_name, usb_node); 4416 file_unlock(isLock); 4417 return 0; 4418 } 4419#endif 4420 4421#ifdef RTCONFIG_USB_MODEM 4422 // set USB common nvram. 4423 set_usb_common_nvram(action, device_name, usb_node, "modem"); 4424 4425 // Don't support the second modem device on a DUT. 4426 snprintf(tmp, 100, "%s", nvram_safe_get("usb_modem_act_path")); 4427 if(strlen(tmp) > 0 && strcmp(tmp, usb_node)){ 4428 usb_dbg("(%s): Already had the modem device in the other USB port!\n", device_name); 4429 file_unlock(isLock); 4430 return 0; 4431 } 4432#ifdef RTCONFIG_INTERNAL_GOBI 4433 else if((nvram_get_int("usb_gobi") == 1 && strcmp(port_path, "2")) 4434 || (nvram_get_int("usb_gobi") != 1 && !strcmp(port_path, "2")) 4435 ){ 4436 if(nvram_get_int("usb_gobi") == 1){ 4437 usb_dbg("(%s): Just use the built-in Gobi and disable the USB modem.\n", device_name); 4438 file_unlock(isLock); 4439 return 0; 4440 } 4441 else 4442 usb_dbg("(%s): Just use the USB modem and disable the built-in Gobi.\n", device_name); 4443 } 4444#endif 4445 4446 // Modem add action. 4447 // WiMAX 4448#ifdef RTCONFIG_USB_BECEEM 4449 if(is_beceem_dongle(1, vid, pid)){ 4450 usb_dbg("(%s): Runing Beceem module...\n", device_name); 4451 4452 char *isp = nvram_safe_get("modem_isp"); 4453 4454 eval("rm", "-rf", BECEEM_DIR); 4455 eval("mkdir", "-p", BECEEM_DIR); 4456 eval("ln", "-sf", "/rom/Beceem_firmware/RemoteProxy.cfg", "/tmp/Beceem_firmware/RemoteProxy.cfg"); 4457 4458 if(!strcmp(isp, "Yota")){ 4459 eval("ln", "-sf", "/rom/Beceem_firmware/macxvi200.bin.normal", "/tmp/Beceem_firmware/macxvi200.bin"); 4460 eval("ln", "-sf", "/rom/Beceem_firmware/macxvi.cfg.yota", "/tmp/Beceem_firmware/macxvi.cfg"); 4461 eval("ln", "-sf", "/rom/Beceem_firmware/Server_CA.pem.yota", "/tmp/Beceem_firmware/Server_CA.pem"); 4462 } 4463 else if(!strcmp(isp, "GMC")){ 4464 eval("ln", "-sf", "/rom/Beceem_firmware/macxvi200.bin.normal", "/tmp/Beceem_firmware/macxvi200.bin"); 4465 eval("ln", "-sf", "/rom/Beceem_firmware/macxvi.cfg.gmc", "/tmp/Beceem_firmware/macxvi.cfg"); 4466 } 4467 else if(!strcmp(isp, "FreshTel")){ 4468 eval("ln", "-sf", "/rom/Beceem_firmware/macxvi200.bin.normal", "/tmp/Beceem_firmware/macxvi200.bin"); 4469 eval("ln", "-sf", "/rom/Beceem_firmware/macxvi.cfg.freshtel", "/tmp/Beceem_firmware/macxvi.cfg"); 4470 } 4471 else if(!strcmp(isp, "Giraffe")){ 4472 eval("ln", "-sf", "/rom/Beceem_firmware/macxvi200.bin.giraffe", "/tmp/Beceem_firmware/macxvi200.bin"); 4473 eval("ln", "-sf", "/rom/Beceem_firmware/macxvi.cfg.giraffe", "/tmp/Beceem_firmware/macxvi.cfg"); 4474 } 4475 else{ 4476 usb_dbg("(%s): Didn't assign the ISP or it was not supported.\n", device_name); 4477 file_unlock(isLock); 4478 return 0; 4479 } 4480 4481 //sleep(2); // sometimes the device is not ready. 4482 modprobe("drxvi314"); 4483 sleep(1); 4484 4485 retry = 0; 4486 while(!check_if_dir_exist("/sys/class/usb/usbbcm") && (retry++ < 3)){ 4487 usb_dbg("(%s): wait %d second for binding...\n", device_name, retry); 4488 modprobe_r("drxvi314"); 4489 4490 modprobe("drxvi314"); 4491 sleep(1); 4492 } 4493 } 4494 else if(is_samsung_dongle(1, vid, pid)){ // Samsung U200 4495 // need to run one time and fillfull the nvram: usb_path%d_act. 4496 usb_dbg("(%s): Runing madwimax...\n", device_name); 4497 4498 nvram_set(strcat_r(prefix, "_act", tmp), "wimax0"); 4499 nvram_set("usb_modem_act_path", usb_node); 4500 snprintf(buf, 128, "%u", vid); 4501 nvram_set("usb_modem_act_vid", buf); 4502 snprintf(buf, 128, "%u", pid); 4503 nvram_set("usb_modem_act_pid", buf); 4504 } 4505 else if(is_gct_dongle(1, vid, pid)){ 4506 // need to run one time and fillfull the nvram: usb_path%d_act. 4507 usb_dbg("(%s): Runing GCT dongle...\n", device_name); 4508 4509 nvram_set(strcat_r(prefix, "_act", tmp), "wimax0"); 4510 nvram_set("usb_modem_act_path", usb_node); 4511 snprintf(buf, 128, "%u", vid); 4512 nvram_set("usb_modem_act_vid", buf); 4513 snprintf(buf, 128, "%u", pid); 4514 nvram_set("usb_modem_act_pid", buf); 4515 } 4516 else 4517#endif 4518 if(is_android_phone(0, vid, pid)){ 4519 usb_dbg("(%s): do nothing with the MTP mode.\n", device_name); 4520 } 4521 else if(isRNDISInterface(device_name, vid, pid)){ 4522 usb_dbg("(%s): Runing RNDIS...\n", device_name); 4523 } 4524 else if(isCDCETHInterface(device_name)){ 4525 usb_dbg("(%s): Runing cdc_ether...\n", device_name); 4526 } 4527 else if(isNCMInterface(device_name)){ 4528 usb_dbg("(%s): Runing cdc_ncm...\n", device_name); 4529 } 4530 else if(!strcmp(nvram_safe_get("stop_ui_insmod"), "1")){ 4531 usb_dbg("(%s): Don't insmod the serial modules.\n", device_name); 4532 } 4533 else if(isSerialInterface(device_name, 1, vid, pid) && vid == 0x05c6 && pid == 0x9026 && nvram_get_int("usb_gobi") == 1){ 4534 usb_dbg("(%s): Runing Gobi ...\n", device_name); 4535 } 4536 else if(!(vid == 0x05c6 && pid == 0x9026) && 4537 (!strncmp(nvram_safe_get(strcat_r(prefix, "_manufacturer", tmp)), "Android", 7) || !strncmp(nvram_safe_get(strcat_r(prefix, "_product", tmp)), "Android", 7)) 4538 ){ 4539 usb_dbg("(%s): Android phone: Runing RNDIS...\n", device_name); 4540 } 4541 else if(isSerialInterface(device_name, 1, vid, pid)){ 4542 usb_dbg("(%s): Runing USB serial with (0x%04x/0x%04x)...\n", device_name, vid, pid); 4543 sleep(1); 4544 modprobe("usbserial"); 4545#if LINUX_KERNEL_VERSION >= KERNEL_VERSION(2,6,36) 4546 modprobe("usb_wwan"); 4547#endif 4548 snprintf(modem_cmd, 128, "vendor=0x%04x", vid); 4549 snprintf(buf, 128, "product=0x%04x", pid); 4550 eval("insmod", "option", modem_cmd, buf); 4551 sleep(1); 4552 } 4553 else if(isACMInterface(device_name, 1, vid, pid)){ 4554 usb_dbg("(%s): Runing USB ACM...\n", device_name); 4555 modprobe("cdc-acm"); 4556 sleep(1); 4557 } 4558#endif // RTCONFIG_USB_MODEM 4559 4560 usb_dbg("(%s): Success!\n", device_name); 4561 file_unlock(isLock); 4562#endif 4563 return 1; 4564} 4565