• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/core


Commit MetaInfo

Revisionf6895c0621ae29a4893ef49f7bf6d8d8be26a1a0 (tree)
Zeit2011-11-06 02:26:32
AutorChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

Merge branch 'aosp/honeycomb-LTE-release' into honeycomb-mr2-x86

Ändern Zusammenfassung

Diff

--- a/fastboot/engine.c
+++ b/fastboot/engine.c
@@ -69,6 +69,7 @@ struct Action
6969 Action *next;
7070
7171 char cmd[64];
72+ const char *prod;
7273 void *data;
7374 unsigned size;
7475
@@ -183,6 +184,16 @@ static int cb_check(Action *a, int status, char *resp, int invert)
183184 return status;
184185 }
185186
187+ if (a->prod) {
188+ if (strcmp(a->prod, cur_product) != 0) {
189+ double split = now();
190+ fprintf(stderr,"IGNORE, product is %s required only for %s [%7.3fs]\n",
191+ cur_product, a->prod, (split - a->start));
192+ a->start = split;
193+ return 0;
194+ }
195+ }
196+
186197 yes = match(resp, value, count);
187198 if (invert) yes = !yes;
188199
@@ -214,10 +225,12 @@ static int cb_reject(Action *a, int status, char *resp)
214225 return cb_check(a, status, resp, 1);
215226 }
216227
217-void fb_queue_require(const char *var, int invert, unsigned nvalues, const char **value)
228+void fb_queue_require(const char *prod, const char *var,
229+ int invert, unsigned nvalues, const char **value)
218230 {
219231 Action *a;
220232 a = queue_action(OP_QUERY, "getvar:%s", var);
233+ a->prod = prod;
221234 a->data = value;
222235 a->size = nvalues;
223236 a->msg = mkmsg("checking %s", var);
@@ -244,6 +257,25 @@ void fb_queue_display(const char *var, const char *prettyname)
244257 a->func = cb_display;
245258 }
246259
260+static int cb_save(Action *a, int status, char *resp)
261+{
262+ if (status) {
263+ fprintf(stderr, "%s FAILED (%s)\n", a->cmd, resp);
264+ return status;
265+ }
266+ strncpy(a->data, resp, a->size);
267+ return 0;
268+}
269+
270+void fb_queue_query_save(const char *var, char *dest, unsigned dest_size)
271+{
272+ Action *a;
273+ a = queue_action(OP_QUERY, "getvar:%s", var);
274+ a->data = (void *)dest;
275+ a->size = dest_size;
276+ a->func = cb_save;
277+}
278+
247279 static int cb_do_nothing(Action *a, int status, char *resp)
248280 {
249281 fprintf(stderr,"\n");
--- a/fastboot/fastboot.c
+++ b/fastboot/fastboot.c
@@ -42,6 +42,8 @@
4242
4343 #include "fastboot.h"
4444
45+char cur_product[FB_RESPONSE_SZ + 1];
46+
4547 void bootimg_set_cmdline(boot_img_hdr *h, const char *cmdline);
4648
4749 boot_img_hdr *mkbootimg(void *kernel, unsigned kernel_size,
@@ -340,6 +342,7 @@ static int setup_requirement_line(char *name)
340342 {
341343 char *val[MAX_OPTIONS];
342344 const char **out;
345+ char *prod = NULL;
343346 unsigned n, count;
344347 char *x;
345348 int invert = 0;
@@ -350,6 +353,14 @@ static int setup_requirement_line(char *name)
350353 } else if (!strncmp(name, "require ", 8)) {
351354 name += 8;
352355 invert = 0;
356+ } else if (!strncmp(name, "require-for-product:", 20)) {
357+ // Get the product and point name past it
358+ prod = name + 20;
359+ name = strchr(name, ' ');
360+ if (!name) return -1;
361+ *name = 0;
362+ name += 1;
363+ invert = 0;
353364 }
354365
355366 x = strchr(name, '=');
@@ -381,7 +392,7 @@ static int setup_requirement_line(char *name)
381392 if (out[n] == 0) return -1;
382393 }
383394
384- fb_queue_require(name, invert, n, out);
395+ fb_queue_require(prod, name, invert, n, out);
385396 return 0;
386397 }
387398
@@ -432,6 +443,8 @@ void do_update(char *fn)
432443
433444 queue_info_dump();
434445
446+ fb_queue_query_save("product", cur_product, sizeof(cur_product));
447+
435448 zdata = load_file(fn, &zsize);
436449 if (zdata == 0) die("failed to load '%s'", fn);
437450
@@ -498,6 +511,8 @@ void do_flashall(void)
498511
499512 queue_info_dump();
500513
514+ fb_queue_query_save("product", cur_product, sizeof(cur_product));
515+
501516 fname = find_item("info", product);
502517 if (fname == 0) die("cannot find android-info.txt");
503518 data = load_file(fname, &sz);
--- a/fastboot/fastboot.h
+++ b/fastboot/fastboot.h
@@ -43,8 +43,10 @@ char *fb_get_error(void);
4343 /* engine.c - high level command queue engine */
4444 void fb_queue_flash(const char *ptn, void *data, unsigned sz);;
4545 void fb_queue_erase(const char *ptn);
46-void fb_queue_require(const char *var, int invert, unsigned nvalues, const char **value);
46+void fb_queue_require(const char *prod, const char *var, int invert,
47+ unsigned nvalues, const char **value);
4748 void fb_queue_display(const char *var, const char *prettyname);
49+void fb_queue_query_save(const char *var, char *dest, unsigned dest_size);
4850 void fb_queue_reboot(void);
4951 void fb_queue_command(const char *cmd, const char *msg);
5052 void fb_queue_download(const char *name, void *data, unsigned size);
@@ -54,4 +56,7 @@ int fb_execute_queue(usb_handle *usb);
5456 /* util stuff */
5557 void die(const char *fmt, ...);
5658
59+/* Current product */
60+extern char cur_product[FB_RESPONSE_SZ + 1];
61+
5762 #endif
--- a/include/netutils/ifc.h
+++ b/include/netutils/ifc.h
@@ -34,7 +34,7 @@ extern int ifc_down(const char *name);
3434 extern int ifc_enable(const char *ifname);
3535 extern int ifc_disable(const char *ifname);
3636
37-extern int ifc_reset_connections(const char *ifname);
37+extern int ifc_reset_connections(const char *ifname, const int reset_mask);
3838
3939 extern int ifc_get_addr(const char *name, in_addr_t *addr);
4040 extern int ifc_set_addr(const char *name, in_addr_t addr);
--- a/libnetutils/ifc_utils.c
+++ b/libnetutils/ifc_utils.c
@@ -279,7 +279,7 @@ int ifc_get_info(const char *name, in_addr_t *addr, int *prefixLength, unsigned
279279 return 0;
280280 }
281281
282-int ifc_add_ipv4_route(const char *ifname, struct in_addr dst, int prefix_length,
282+int ifc_act_on_ipv4_route(int action, const char *ifname, struct in_addr dst, int prefix_length,
283283 struct in_addr gw)
284284 {
285285 struct rtentry rt;
@@ -311,7 +311,7 @@ int ifc_add_ipv4_route(const char *ifname, struct in_addr dst, int prefix_length
311311 return -errno;
312312 }
313313
314- result = ioctl(ifc_ctl_sock, SIOCADDRT, &rt);
314+ result = ioctl(ifc_ctl_sock, action, &rt);
315315 if (result < 0) {
316316 if (errno == EEXIST) {
317317 result = 0;
@@ -330,17 +330,7 @@ int ifc_create_default_route(const char *name, in_addr_t gw)
330330 in_dst.s_addr = 0;
331331 in_gw.s_addr = gw;
332332
333- return ifc_add_ipv4_route(name, in_dst, 0, in_gw);
334-}
335-
336-int ifc_add_host_route(const char *name, in_addr_t dst)
337-{
338- struct in_addr in_dst, in_gw;
339-
340- in_dst.s_addr = dst;
341- in_gw.s_addr = 0;
342-
343- return ifc_add_ipv4_route(name, in_dst, 32, in_gw);
333+ return ifc_act_on_route(SIOCADDRT, name, in_dst, 0, in_gw);
344334 }
345335
346336 int ifc_enable(const char *ifname)
@@ -373,19 +363,46 @@ int ifc_disable(const char *ifname)
373363 return result;
374364 }
375365
376-int ifc_reset_connections(const char *ifname)
366+#define RESET_IPV4_ADDRESSES 0x01
367+#define RESET_IPV6_ADDRESSES 0x02
368+#define RESET_ALL_ADDRESSES (RESET_IPV4_ADDRESSES | RESET_IPV6_ADDRESSES)
369+
370+int ifc_reset_connections(const char *ifname, const int reset_mask)
377371 {
378372 #ifdef HAVE_ANDROID_OS
379- int result;
373+ int result, success;
380374 in_addr_t myaddr;
381375 struct ifreq ifr;
382-
383- ifc_init();
384- ifc_get_info(ifname, &myaddr, NULL, NULL);
385- ifc_init_ifr(ifname, &ifr);
386- init_sockaddr_in(&ifr.ifr_addr, myaddr);
387- result = ioctl(ifc_ctl_sock, SIOCKILLADDR, &ifr);
388- ifc_close();
376+ struct in6_ifreq ifr6;
377+
378+ if (reset_mask & RESET_IPV4_ADDRESSES) {
379+ /* IPv4. Clear connections on the IP address. */
380+ ifc_init();
381+ ifc_get_info(ifname, &myaddr, NULL, NULL);
382+ ifc_init_ifr(ifname, &ifr);
383+ init_sockaddr_in(&ifr.ifr_addr, myaddr);
384+ result = ioctl(ifc_ctl_sock, SIOCKILLADDR, &ifr);
385+ ifc_close();
386+ } else {
387+ result = 0;
388+ }
389+
390+ if (reset_mask & RESET_IPV6_ADDRESSES) {
391+ /*
392+ * IPv6. On Linux, when an interface goes down it loses all its IPv6
393+ * addresses, so we don't know which connections belonged to that interface
394+ * So we clear all unused IPv6 connections on the device by specifying an
395+ * empty IPv6 address.
396+ */
397+ ifc_init6();
398+ // This implicitly specifies an address of ::, i.e., kill all IPv6 sockets.
399+ memset(&ifr6, 0, sizeof(ifr6));
400+ success = ioctl(ifc_ctl_sock6, SIOCKILLADDR, &ifr6);
401+ if (result == 0) {
402+ result = success;
403+ }
404+ ifc_close6();
405+ }
389406
390407 return result;
391408 #else
@@ -442,67 +459,6 @@ int ifc_remove_host_routes(const char *name)
442459 }
443460
444461 /*
445- * Return the address of the default gateway
446- *
447- * TODO: factor out common code from this and remove_host_routes()
448- * so that we only scan /proc/net/route in one place.
449- */
450-int ifc_get_default_route(const char *ifname)
451-{
452- char name[64];
453- in_addr_t dest, gway, mask;
454- int flags, refcnt, use, metric, mtu, win, irtt;
455- int result;
456- FILE *fp;
457-
458- fp = fopen("/proc/net/route", "r");
459- if (fp == NULL)
460- return 0;
461- /* Skip the header line */
462- if (fscanf(fp, "%*[^\n]\n") < 0) {
463- fclose(fp);
464- return 0;
465- }
466- ifc_init();
467- result = 0;
468- for (;;) {
469- int nread = fscanf(fp, "%63s%X%X%X%d%d%d%X%d%d%d\n",
470- name, &dest, &gway, &flags, &refcnt, &use, &metric, &mask,
471- &mtu, &win, &irtt);
472- if (nread != 11) {
473- break;
474- }
475- if ((flags & (RTF_UP|RTF_GATEWAY)) == (RTF_UP|RTF_GATEWAY)
476- && dest == 0
477- && strcmp(ifname, name) == 0) {
478- result = gway;
479- break;
480- }
481- }
482- fclose(fp);
483- ifc_close();
484- return result;
485-}
486-
487-/*
488- * Sets the specified gateway as the default route for the named interface.
489- */
490-int ifc_set_default_route(const char *ifname, in_addr_t gateway)
491-{
492- struct in_addr addr;
493- int result;
494-
495- ifc_init();
496- addr.s_addr = gateway;
497- if ((result = ifc_create_default_route(ifname, gateway)) < 0) {
498- LOGD("failed to add %s as default route for %s: %s",
499- inet_ntoa(addr), ifname, strerror(errno));
500- }
501- ifc_close();
502- return result;
503-}
504-
505-/*
506462 * Removes the default route for the named interface.
507463 */
508464 int ifc_remove_default_route(const char *ifname)
@@ -565,7 +521,7 @@ ifc_configure(const char *ifname,
565521 return 0;
566522 }
567523
568-int ifc_add_ipv6_route(const char *ifname, struct in6_addr dst, int prefix_length,
524+int ifc_act_on_ipv6_route(int action, const char *ifname, struct in6_addr dst, int prefix_length,
569525 struct in6_addr gw)
570526 {
571527 struct in6_rtmsg rtmsg;
@@ -600,7 +556,7 @@ int ifc_add_ipv6_route(const char *ifname, struct in6_addr dst, int prefix_lengt
600556 return -errno;
601557 }
602558
603- result = ioctl(ifc_ctl_sock6, SIOCADDRT, &rtmsg);
559+ result = ioctl(ifc_ctl_sock6, action, &rtmsg);
604560 if (result < 0) {
605561 if (errno == EEXIST) {
606562 result = 0;
@@ -612,8 +568,8 @@ int ifc_add_ipv6_route(const char *ifname, struct in6_addr dst, int prefix_lengt
612568 return result;
613569 }
614570
615-int ifc_add_route(const char *ifname, const char *dst, int prefix_length,
616- const char *gw)
571+int ifc_act_on_route(int action, const char *ifname, const char *dst, int prefix_length,
572+ const char *gw)
617573 {
618574 int ret = 0;
619575 struct sockaddr_in ipv4_dst, ipv4_gw;
@@ -631,7 +587,7 @@ int ifc_add_route(const char *ifname, const char *dst, int prefix_length,
631587 return -EINVAL;
632588 }
633589
634- if (gw == NULL) {
590+ if (gw == NULL || (strlen(gw) == 0)) {
635591 if (addr_ai->ai_family == AF_INET6) {
636592 gw = "::";
637593 } else if (addr_ai->ai_family == AF_INET) {
@@ -639,6 +595,13 @@ int ifc_add_route(const char *ifname, const char *dst, int prefix_length,
639595 }
640596 }
641597
598+ if (((addr_ai->ai_family == AF_INET6) && (prefix_length < 0 || prefix_length > 128)) ||
599+ ((addr_ai->ai_family == AF_INET) && (prefix_length < 0 || prefix_length > 32))) {
600+ printerr("ifc_add_route: invalid prefix length");
601+ freeaddrinfo(addr_ai);
602+ return -EINVAL;
603+ }
604+
642605 ret = getaddrinfo(gw, NULL, &hints, &gw_ai);
643606 if (ret != 0) {
644607 printerr("getaddrinfo failed: invalid gateway %s\n", gw);
@@ -656,13 +619,13 @@ int ifc_add_route(const char *ifname, const char *dst, int prefix_length,
656619 if (addr_ai->ai_family == AF_INET6) {
657620 memcpy(&ipv6_dst, addr_ai->ai_addr, sizeof(struct sockaddr_in6));
658621 memcpy(&ipv6_gw, gw_ai->ai_addr, sizeof(struct sockaddr_in6));
659- ret = ifc_add_ipv6_route(ifname, ipv6_dst.sin6_addr, prefix_length,
660- ipv6_gw.sin6_addr);
622+ ret = ifc_act_on_ipv6_route(action, ifname, ipv6_dst.sin6_addr,
623+ prefix_length, ipv6_gw.sin6_addr);
661624 } else if (addr_ai->ai_family == AF_INET) {
662625 memcpy(&ipv4_dst, addr_ai->ai_addr, sizeof(struct sockaddr_in));
663626 memcpy(&ipv4_gw, gw_ai->ai_addr, sizeof(struct sockaddr_in));
664- ret = ifc_add_ipv4_route(ifname, ipv4_dst.sin_addr, prefix_length,
665- ipv4_gw.sin_addr);
627+ ret = ifc_act_on_ipv4_route(action, ifname, ipv4_dst.sin_addr,
628+ prefix_length, ipv4_gw.sin_addr);
666629 } else {
667630 printerr("ifc_add_route: getaddrinfo returned un supported address family %d\n",
668631 addr_ai->ai_family);
@@ -673,3 +636,13 @@ int ifc_add_route(const char *ifname, const char *dst, int prefix_length,
673636 freeaddrinfo(gw_ai);
674637 return ret;
675638 }
639+
640+int ifc_add_route(const char *ifname, const char *dst, int prefix_length, const char *gw)
641+{
642+ return ifc_act_on_route(SIOCADDRT, ifname, dst, prefix_length, gw);
643+}
644+
645+int ifc_remove_route(const char *ifname, const char*dst, int prefix_length, const char *gw)
646+{
647+ return ifc_act_on_route(SIOCDELRT, ifname, dst, prefix_length, gw);
648+}
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -377,7 +377,7 @@ service debuggerd /system/bin/debuggerd
377377 class main
378378
379379 service ril-daemon /system/bin/rild
380- class late_start
380+ class main
381381 socket rild stream 660 root radio
382382 socket rild-debug stream 660 radio system
383383 user root