comparison src/ushare.c @ 133:0db6ccf0fe31

modify DLNA display name & UUID
author Naoya OYAMA <naoya.oyama@gmail.com>
date Thu, 14 Oct 2010 00:07:05 +0900
parents 20442921bff5
children 2a9ac5ce2c7e
comparison
equal deleted inserted replaced
132:7b663556757f 133:0db6ccf0fe31
80 __attribute__ ((malloc)); 80 __attribute__ ((malloc));
81 81
82 static struct ushare_t * 82 static struct ushare_t *
83 ushare_new (void) 83 ushare_new (void)
84 { 84 {
85 extern thread_data *gp_tdata;
86 thread_data *tdata = gp_tdata;
85 struct ushare_t *ut = (struct ushare_t *) malloc (sizeof (struct ushare_t)); 87 struct ushare_t *ut = (struct ushare_t *) malloc (sizeof (struct ushare_t));
88 char model_name[32];
89 model_name[0] = '\0';
86 if (!ut) 90 if (!ut)
87 return NULL; 91 return NULL;
92 snprintf(model_name, sizeof(model_name), "%s:dev%d", PACKAGE_NAME, tdata->device_id);
93 model_name[sizeof(model_name)-1] = '\0';
88 94
89 // ut->name = strdup (DEFAULT_USHARE_NAME); 95 // ut->name = strdup (DEFAULT_USHARE_NAME);
90 ut->name = strdup (PACKAGE_NAME); 96 ut->name = strdup (model_name);
91 ut->interface = strdup (DEFAULT_USHARE_IFACE); 97 ut->interface = strdup (DEFAULT_USHARE_IFACE);
92 // ut->model_name = strdup (DEFAULT_USHARE_NAME); 98 // ut->model_name = strdup (DEFAULT_USHARE_NAME);
93 ut->model_name = strdup (PACKAGE_NAME); 99 ut->model_name = strdup (model_name);
94 ut->contentlist = NULL; 100 ut->contentlist = NULL;
95 ut->rb = rbinit (rb_compare, NULL); 101 ut->rb = rbinit (rb_compare, NULL);
96 ut->root_entry = NULL; 102 ut->root_entry = NULL;
97 ut->nr_entries = 0; 103 ut->nr_entries = 0;
98 ut->starting_id = STARTING_ENTRY_ID_DEFAULT; 104 ut->starting_id = STARTING_ENTRY_ID_DEFAULT;
502 } 508 }
503 509
504 static char * 510 static char *
505 create_udn (char *interface) 511 create_udn (char *interface)
506 { 512 {
513 extern thread_data *gp_tdata;
514 thread_data *tdata = gp_tdata;
507 int sock = -1; 515 int sock = -1;
508 char *buf; 516 char *buf;
509 unsigned char *ptr; 517 unsigned char *ptr;
510 pid_t PID = (getpid() & 0xFFFF);
511 518
512 #if (defined(BSD) || defined(__FreeBSD__) || defined(__APPLE__)) 519 #if (defined(BSD) || defined(__FreeBSD__) || defined(__APPLE__))
513 int mib[6]; 520 int mib[6];
514 size_t len; 521 size_t len;
515 struct if_msghdr *ifm; 522 struct if_msghdr *ifm;
572 buf = (char *) malloc (64 * sizeof (char)); 579 buf = (char *) malloc (64 * sizeof (char));
573 memset (buf, 0, 64); 580 memset (buf, 0, 64);
574 ptr = (unsigned char *) ifr.ifr_hwaddr.sa_data; 581 ptr = (unsigned char *) ifr.ifr_hwaddr.sa_data;
575 #endif /* (defined(BSD) || defined(__FreeBSD__)) */ 582 #endif /* (defined(BSD) || defined(__FreeBSD__)) */
576 583
577 snprintf (buf, 64, "%s-%04x-%02x%02x%02x%02x%02x%02x", DEFAULT_UUID, PID, 584 snprintf (buf, 64, "%s-%04x-%02x%02x%02x%02x%02x%02x", DEFAULT_UUID, tdata->device_id,
578 (ptr[0] & 0377), (ptr[1] & 0377), (ptr[2] & 0377), 585 (ptr[0] & 0377), (ptr[1] & 0377), (ptr[2] & 0377),
579 (ptr[3] & 0377), (ptr[4] & 0377), (ptr[5] & 0377)); 586 (ptr[3] & 0377), (ptr[4] & 0377), (ptr[5] & 0377));
580 587
581 if (sock) 588 if (sock)
582 close (sock); 589 close (sock);