summaryrefslogtreecommitdiffstats
path: root/meta-agl-bsp/meta-rcar-gen3
AgeCommit message (Collapse)AuthorFilesLines
2017-03-27Update rcar gen3 script, compliant driver updateRonan Le Martret1-16/+23
Setup_mm_packages.sh must be compliant with driver update. Test if EXTRACT_DIR do not exists block the update. Change-Id: If5a8adfbf187e0894d04488eb40aa6ddbe48ad95 Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
2017-03-27Add OTA wks support to Porter and RCar-M3 boardsAnton Gerasimov2-0/+44
Bug-AGL: SPEC-413 Change-Id: I4ef71fde4a013c1dac4917f66727ce4b6be4170c Signed-off-by: Anton Gerasimov <anton@advancedtelematic.com>
2017-03-24Fix optee-os buildRonan Le Martret6-0/+2133
* Remove the file generation and directly copy the files. the files: default_regular.c default_regular.h were generate with command line: $ scripts/render_font.py \ --font_file lib/libutee/tui/fonts/amble/Amble-Regular.ttf \ --font_size 20 --font_name default_regular \ --out_dir out/arm-plat-rcar/ta_arm64-lib/libutee/tui the files: default_bold.c default_bold.h were generate with command line: $ scripts/render_font.py \ --font_file lib/libutee/tui/fonts/amble/Amble-Bold.ttf \ --font_size 20 --font_name default_bold --out_dir out/arm-plat-rcar/ta_arm64-lib/libutee/tui python-wand 0.4.3 (and newer) is incompatible with imagemagick >= 7.0, so we need to backport imagemagick 6. If you don't have imagemagick 6 install on your host the build of optee-os will failed. Change-Id: I83a6c4b963b7d3e18f2730b601934708a2f6c7ef Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
2017-03-21meta-rcar-3 setup: slight refactoringMartin Kelly1-5/+6
Change-Id: I9c4ba041ede07252c69452dfa747b90b36346fba Signed-off-by: Martin Kelly <mkelly@xevo.com>
2017-03-19[rcar-gen3] Port python-wand for meta-agl-bspRonan Le Martret2-0/+20
* the optee from Renesas rcar gen3 DEPEND on python-wand to build. * python-wand comes from meta-linaro Bug-AGL: SPEC-471 Change-Id: I2837a50ccea1b474c29a4461e7d7535c6d4195fb Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
2017-03-19[rcar-gen3] Disable ipv6Ronan Le Martret2-1/+6
* ipv6 was disable in the previous version of the Renesas gen3 BSP (v2.12) and boot with ipv6 doesn't work, for now, on the Gen3 board. Bug-AGL: SPEC-471 Change-Id: I0c0f14cbf3b5d8404e9b8108d24740ecaea762c2 Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
2017-03-19[rcar-gen3] update weston recipes bbappendRonan Le Martret2-1/+26
- added weston.ini - fix-touchscreen-crash.patch Bug-AGL: SPEC-471 Bug-AGL: SPEC-411 Change-Id: Iee25aae5c25fcdda6e97181ccba946db938e129f Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
2017-03-19[rcar-gen3] Remove fix on arm-trusted-firmware recipesRonan Le Martret2-27/+0
* the new version of arm-trusted-firmware from Renesas rcar gen3 BSP doesn't need this fix for h3 anymore Bug-AGL: SPEC-471 Change-Id: I3101f9cd7c032705bbdcb20cdadbba8af4ed8d62 Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
2017-03-19[rcar-gen3] Renamed weston bbappend recipesRonan Le Martret1-0/+0
Bug-AGL: SPEC-471 Bug-AGL: SPEC-411 Change-Id: Icfcc4144385552718cea8ed43d0aa561686188f5 Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
2017-03-19[rcar-gen3] Fix webp bbappendRonan Le Martret2-0/+21
* the original fix is relevant to YP krogoth only, This branch is based on YP morty * the original patch is from Renesas rcar gen3 v2.16: meta-renesas-rcar-gen3/meta-rcar-gen3/recipes-multimedia/webp/libwebp/ disabled_arm_neon.diff Bug-AGL: SPEC-471 Change-Id: Iff0a6595c15a779eb07a91e0ae3a7a59da99870b Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
2017-03-19[rcar-gen3] Update setup script for gen3 v2.16.0Ronan Le Martret1-5/+6
* update script for Renesas rcar gen3 v2.16.0 and for the last released driver (version 2017-01-25) of Renesas rcar gen3. Bug-AGL: SPEC-471 Change-Id: If078055e5bc65263491b7cadd6c7b55755746257 Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
2017-03-19[rcar-gen3] Rename kernel-module-uvcs recipesRonan Le Martret1-0/+0
* the recipes "kernel-module-uvcs" was change to kernel-module-uvcs-drv Bug-AGL: SPEC-471 Change-Id: I07f4efe47c9c1fe66df7818e98c4c4cc0806973d Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
2017-03-19[rcar-gen3] Remove fix on opteeRonan Le Martret2-18/+1
* the new version of optee from Renesas rcar gen3 v2.16, doesn't need this fix to build anymore. Bug-AGL: SPEC-471 Change-Id: I8869b13bf038e2cd2f45a26affadd757fe1ea10c Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
2017-03-19[rcar-gen3] Remove fix on pppRonan Le Martret1-2/+0
* if you build ppp with a kernel >= 4.8 you need this fix * if you build ppp with a kernel < 4.8 you need to remove this fix * the version of the kernel from Renesas rcar gen3 v2.16 is 4.9, so we need this fix. Bug-AGL: SPEC-471 Change-Id: Iffefa52571163b15c7acd2d1ffc53b9b1ffb0c3b Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
2017-03-19[rcar-gen3] Remove mesa backportRonan Le Martret4-242/+0
* as Renesas rcar gen3 v2.16 do not use mesa recipes (.bbappend) 10.6.3, we do not need to maintain this recipes. Bug-AGL: SPEC-471 Bug-AGL: SPEC-419 Change-Id: I80582d725bec71931d8d5fbf83fe3e0b29381592 Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
2017-03-19[rcar-gen3] Updated arm-trusted-firmwareRonan Le Martret1-10/+10
* this commit fix the patch for the new version of arm-trusted-firmware of the Renesas rcar gen v2.16 Bug-AGL: SPEC-471 Change-Id: I70abed7104efc53d38133cf11be003476aef35c5 Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
2017-03-19[rcar-gen3] Backported gstreamer from poky krogothRonan Le Martret87-1477/+1713
* the Renesas rcar gen3 v2.16 need gstreamer recipes 1.6.3 from krogoth Bug-AGL: SPEC-471 Change-Id: I1ce10935aac45b3f7711ec1033187ba74b1f921c Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
2017-03-17meta-rcar-3 setup: typo fixesMartin Kelly1-2/+2
Change-Id: Idddf52fd1c894493c3c65c45a93733d5ba39f809 Signed-off-by: Martin Kelly <mkelly@xevo.com>
2017-03-17meta-rcar: don't cd; just unzipMartin Kelly1-4/+2
This is slightly cleaner and better for handling failure cases. Change-Id: I824308fc7c8ca8def86b7470a5226a6eff91f51c Signed-off-by: Martin Kelly <mkelly@xevo.com>
2017-03-01Removed touchscreen fix on gen3Ronan Le Martret1-0/+1
* fix-touchscreen-crash.patch is already present in meta-rcar. * need to be backport to CC Change-Id: I66dd246288c243c06f6ee022e07a95abeec10c37 Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
2017-02-06Add bluetooth support to renesas rcar-gen3.Builder2-1/+33
Change-Id: Iad1185f03ad82e297f5368108d586f0af3894b23 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2017-01-31Fix build for MACHINE m3ulcbRonan Le Martret1-4/+3
* 0003-IPL-ddrinit-rev-0.20rc8.patch conflict with 0001-fix-build-for-gcc6-for-h3-init_dram.patch * 0001-fix-build-for-gcc6-for-h3-init_dram.patch is only use for MACHINE h3ulcb Change-Id: I88b90583d8ed878b1aac76592c0953fa4ebdc92d Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
2017-01-18fix gcc 6 build for arm-trusted-firmwareRonan2-0/+27
* prevent error, when gcc 6.2 is used: "initializer element is not a constant expression" * ref: http://c0x.coding-guidelines.com/6.5.7.html Change-Id: I35be13c8b169222972becde16b5382782195de6e Signed-off-by: Ronan <ronan.lemartret@iot.bzh>
2017-01-16hard revert on mesa from the atticRonan2-0/+0
* because of a recipes from meta-rcar, we need to keep a mesa_10 recipes (and never use it...) - meta-rcar/meta-rcar-gen3/recipes-graphics/mesa/mesa_10.%.bbappend * a fix was send uptream and waiting intergration ... * waiting pull request: https://github.com/CogentEmbedded/meta-rcar/pull/9 Change-Id: Ia6bb84892f2a12ec5f8a4d4f3c5c70f60c7fa569 Signed-off-by: Ronan <ronan.lemartret@iot.bzh>
2017-01-16Update meta-agl-bsp for 'Daring Dab'Jan-Simon Möller2-0/+0
This changeset removes unused or old/stale files from the meta-agl-bsp layer before the 'Daring Dab' development cycle starts. Change-Id: I9df5841bb65545a435637d1067df573506f4cb02 Signed-off-by: Jan-Simon Möller <jsmoeller@linuxfoundation.org>
2017-01-10fix mesa version for yocto mortyRonan2-0/+43
Change-Id: I6ef9fb754a2d71aff1eae78ffde40c45a86362b5 Signed-off-by: Ronan <ronan.lemartret@iot.bzh>
2017-01-10fix tar command optionRonan1-0/+8
* the option "-C XXX" must be set in first position. Change-Id: I89f21e9491a03d53ee9ed047e2ae267ad481fdf6 Signed-off-by: Ronan <ronan.lemartret@iot.bzh>
2017-01-10fix build with gcc6Ronan2-0/+31
Change-Id: Iebddf4bed98a8216a521b5e8871b4dc111f3716e Signed-off-by: Ronan <ronan.lemartret@iot.bzh>
2017-01-10fix build with gcc6Ronan1-0/+3
Change-Id: I1ce6a5f4fb2d04962234d4b2f9bcfe92140cccc9 Signed-off-by: Ronan <ronan.lemartret@iot.bzh>
2017-01-10ppp:remove fix for linux 4.8Ronan1-0/+2
Change-Id: I7e79eaf17546d372d2a2fe0a71f25b0f0a83d6de Signed-off-by: Ronan <ronan.lemartret@iot.bzh>
2017-01-10fix gcc 6 buildRonan2-0/+95
Change-Id: I5ca505da0837c28acc4cb133e9d6acd87d1c7bcc Signed-off-by: Ronan <ronan.lemartret@iot.bzh>
2017-01-02Fix to get netboot activated also for renesas gen3Romain Forlot3-1/+6
Change-Id: I9b512a907398de9c96dc46111c74bed4059f7b8e Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2016-12-06add namespace to config kernelRonan2-0/+8
* missing namespace into defconf Change-Id: I9f292f8186fb771f8eb8c82ad8e7e985c474e9ea Signed-off-by: Ronan <ronan.lemartret@iot.bzh>
2016-12-02optee-os depend on python-pycryptoRonan1-0/+2
* optee-os use python script to build so, We need to add: inherit pythonnative If not we use host python during the build. * During the build, optee-os use script: - scripts/pem_to_pub_c.py - scripts/sign.py Those script depend on python-pycrypto "from Crypto.PublicKey import RSA" So we need to add python-pycrypto native to recipes * The python-pycrypto recipes come from meta-security (out of AGL): https://layers.openembedded.org/layerindex/recipe/39101/ Change-Id: I64340544c9a23a8e9ef62aca348fc08722d3dcc2 Signed-off-by: Ronan <ronan.lemartret@iot.bzh>
2016-11-23meta-rcar-gen3: autoload mmp modulesYannick Gicquel4-0/+4
Add KERNEL_MODULES_AUTOLOAD directive some to multimedia package drivers. Thus after bootup, multimedia framework is ready to use hw acceleration IP. Change-Id: I43a92fdf2dff1f546e5a532b13203efd4a6b829c Signed-off-by: Yannick Gicquel <yannick.gicquel@iot.bzh>
2016-11-21meta-rcar-gen3: add template with hw accelerationYannick Gicquel2-0/+45
this introduce gen3 support with egl & multimedia acceleration. Change-Id: Id816c6ae85e2877a1af9203ef893e1db12db5afc Signed-off-by: Yannick Gicquel <yannick.gicquel@iot.bzh>
2016-11-17meta-rcar-gen3: optee-os: build fixupYannick Gicquel2-8/+19
Change-Id: I47dcf04e05ec61eebff20a171df78584c7de70a1 Signed-off-by: Yannick Gicquel <yannick.gicquel@iot.bzh>
2016-11-16meta-rcar-gen3: gles: support for AGL toolchainYannick Gicquel1-0/+4
As TARGET_VENDOR is defined in AGL, the toolchain has a different name. The gles recipe contains hardcoded toolchain name, this add support to custom one. Change-Id: Ie4e768d0570c6a07f92067e39079e6e063d59451 Signed-off-by: Yannick Gicquel <yannick.gicquel@iot.bzh>
2016-11-14meta-agl-bsp: meta-rcar-gen3: initial integrationYannick Gicquel2-0/+17
Note: optee-os recipe is disable for the moment. Change-Id: I8881fcc3c794b1cbb479b8e7d61bb86688f78bf9 Signed-off-by: Yannick Gicquel <yannick.gicquel@iot.bzh>
2016-11-14meta-agl-bsp: backport: gstreamer1.0 v1.4.5 recipesYannick Gicquel55-0/+3075
This is a backport from Jethro as meta-rcar-gen3 append on following: - gstreamer1.0-libav_1.4.5 - gstreamer1.0-omx_1.2.0 - gstreamer1.0-plugins-bad_1.4.5 - gstreamer1.0-plugins-good_1.4.5 v2 (jsmoeller): Move into meta-rcar-gen3 subfolder as it only affects that layer. Change-Id: Iefc9a2c10e76c172f1cb1f8d3babf3544828310e Signed-off-by: Yannick Gicquel <yannick.gicquel@iot.bzh> Signed-off-by: Jan-Simon Möller <jsmoeller@linuxfoundation.org>
2016-11-14meta-agl-bsp: backport: mesa v10.6.3 recipeYannick Gicquel2-0/+199
This is a backport from Jethro as meta-rcar-gen3 append on this package. v2 (jsmoeller): Move underneath meta-rcar-gen3 as it only affects that layer. Change-Id: I1c9f94346da919530c359b471429fad9b1b2c661 Signed-off-by: Yannick Gicquel <yannick.gicquel@iot.bzh> Signed-off-by: Jan-Simon Möller <jsmoeller@linuxfoundation.org>
2016-11-14meta-agl-bsp: backport: linuxptp v1.4 recipeYannick Gicquel2-0/+57
This is a backport from Jethro as meta-rcar-gen3 append on this package. v2 (jsmoeller): move to meta-rcar-gen3 subfolder as it only affects that layer Change-Id: Ic5755342beae2b02a6072d40fc7e8d41596d5b2b Signed-off-by: Yannick Gicquel <yannick.gicquel@iot.bzh> Signed-off-by: Jan-Simon Möller <jsmoeller@linuxfoundation.org>
s="p">, *request; int length, rc; /* make the list of accepted protocols */ protolist = strjoin(-1, protocols, ", "); if (protolist == NULL) return NULL; /* create the request */ getkeypair(&key, &ack); length = make_request(&request, path, host, key, protolist); free(protolist); if (length < 0) return NULL; /* send the request */ do { rc = (int)write(fd, request, length); } while(rc < 0 && errno == EINTR); free(request); return rc < 0 ? NULL : ack; } /* read a line not efficiently but without buffering */ static int receive_line(int fd, char *line, int size) { int rc, length = 0, cr = 0; for(;;) { if (length >= size) { errno = EFBIG; return -1; } do { rc = (int)read(fd, line + length, 1); } while (rc < 0 && errno == EINTR); if (rc < 0) return -1; if (line[length] == '\r') cr = 1; else if (cr != 0 && line[length] == '\n') { line[--length] = 0; return length; } else cr = 0; length++; } } /* check a header */ static inline int isheader(const char *head, size_t klen, const char *key) { return strncasecmp(head, key, klen) == 0 && key[klen] == 0; } /* receives and scan the response */ static int receive_response(int fd, const char **protocols, const char *ack) { char line[4096], *it; int rc, haserr, result = -1; size_t len, clen; /* check the header line to be something like: "HTTP/1.1 101 Switching Protocols" */ rc = receive_line(fd, line, (int)sizeof(line)); if (rc < 0) goto error; len = strcspn(line, " "); if (len != 8 || 0 != strncmp(line, "HTTP/1.1", 8)) goto abort; it = line + len; len = strspn(it, " "); if (len == 0) goto abort; it += len; len = strcspn(it, " "); if (len != 3 || 0 != strncmp(it, "101", 3)) goto abort; /* reads the rest of the response until empty line */ clen = 0; haserr = 0; for(;;) { rc = receive_line(fd, line, (int)sizeof(line)); if (rc < 0) goto error; if (rc == 0) break; len = strcspn(line, ": "); if (len != 0 && line[len] == ':') { /* checks the headers values */ it = line + len + 1; it += strspn(it, " ,"); it[strcspn(it, " ,")] = 0; if (isheader(line, len, "Sec-WebSocket-Accept")) { if (strcmp(it, ack) != 0) haserr = 1; } else if (isheader(line, len, "Sec-WebSocket-Protocol")) { result = 0; while(protocols[result] != NULL && strcmp(it, protocols[result]) != 0) result++; } else if (isheader(line, len, "Upgrade")) { if (strcmp(it, "websocket") != 0) haserr = 1; } else if (isheader(line, len, "Content-Length")) { clen = atol(it); } } } /* skips the remaining of the message */ while (clen >= sizeof line) { while (read(fd, line, sizeof line) < 0 && errno == EINTR); clen -= sizeof line; } if (clen > 0) { while (read(fd, line, len) < 0 && errno == EINTR); } if (haserr != 0 || result < 0) goto abort; return result; abort: errno = ECONNABORTED; error: return -1; } static int negociate(int fd, const char **protocols, const char *path, const char *host) { const char *ack = send_request(fd, protocols, path, host); return ack == NULL ? -1 : receive_response(fd, protocols, ack); } /* tiny parse a "standard" websock uri ws://host:port/path... */ static int parse_uri(const char *uri, char **host, char **service, const char **path) { const char *h, *p; size_t hlen, plen; /* the scheme */ if (strncmp(uri, "ws://", 5) == 0) uri += 5; /* the host */ h = uri; hlen = strcspn(h, ":/"); if (hlen == 0) goto invalid; uri += hlen; /* the port (optional) */ if (*uri == ':') { p = ++uri; plen = strcspn(p, "/"); if (plen == 0) goto invalid; uri += plen; } else { p = NULL; plen = 0; } /* the path */ if (*uri != '/') goto invalid; /* make the result */ *host = strndup(h, hlen); if (*host != NULL) { *service = plen ? strndup(p, plen) : strdup("http"); if (*service != NULL) { *path = uri; return 0; } free(*host); } errno = ENOMEM; goto error; invalid: errno = EINVAL; error: return -1; } static const char *proto_json1[2] = { "x-afb-ws-json1", NULL }; struct afb_wsj1 *afb_ws_client_connect_wsj1(struct sd_event *eloop, const char *uri, struct afb_wsj1_itf *itf, void *closure) { int rc, fd; char *host, *service, xhost[32]; const char *path; struct addrinfo hint, *rai, *iai; struct afb_wsj1 *result; struct fdev *fdev; /* scan the uri */ rc = parse_uri(uri, &host, &service, &path); if (rc < 0) return NULL; /* get addr */ memset(&hint, 0, sizeof hint); hint.ai_family = AF_INET; hint.ai_socktype = SOCK_STREAM; rc = getaddrinfo(host, service, &hint, &rai); free(host); free(service); if (rc != 0) { errno = EINVAL; return NULL; } /* get the socket */ result = NULL; iai = rai; while (iai != NULL) { struct sockaddr_in *a = (struct sockaddr_in*)(iai->ai_addr); unsigned char *ipv4 = (unsigned char*)&(a->sin_addr.s_addr); unsigned char *port = (unsigned char*)&(a->sin_port); sprintf(xhost, "%d.%d.%d.%d:%d", (int)ipv4[0], (int)ipv4[1], (int)ipv4[2], (int)ipv4[3], (((int)port[0]) << 8)|(int)port[1]); fd = socket(iai->ai_family, iai->ai_socktype, iai->ai_protocol); if (fd >= 0) { rc = connect(fd, iai->ai_addr, iai->ai_addrlen); if (rc == 0) { rc = negociate(fd, proto_json1, path, xhost); if (rc == 0) { fdev = fdev_systemd_create(eloop, fd); if (fdev) { result = afb_wsj1_create(fdev, itf, closure); if (result != NULL) { fcntl(fd, F_SETFL, O_NONBLOCK); break; } } } } close(fd); } iai = iai->ai_next; } freeaddrinfo(rai); return result; } #if 0 /* compute the queried path */ static char *makequery(const char *path, const char *uuid, const char *token) { char *result; int rc; while(*path == '/') path++; if (uuid == NULL) { if (token == NULL) rc = asprintf(&result, "/%s", path); else rc = asprintf(&result, "/%s?x-afb-token=%s", path, token); } else { if (token == NULL) rc = asprintf(&result, "/%s?x-afb-uuid=%s", path, uuid); else rc = asprintf(&result, "/%s?x-afb-uuid=%s&x-afb-token=%s", path, uuid, token); } if (rc < 0) { errno = ENOMEM; return NULL; } return result; } #endif /*****************************************************************************************************************************/ #include <sys/un.h> #include "afb-proto-ws.h" static int get_socket_unix(const char *uri) { int fd, rc; struct sockaddr_un addr; size_t length; length = strlen(uri); if (length >= 108) { errno = ENAMETOOLONG; return -1; } fd = socket(AF_UNIX, SOCK_STREAM, 0); if (fd < 0) return fd; memset(&addr, 0, sizeof addr); addr.sun_family = AF_UNIX; strcpy(addr.sun_path, uri); if (addr.sun_path[0] == '@') addr.sun_path[0] = 0; /* implement abstract sockets */ rc = connect(fd, (struct sockaddr *) &addr, (socklen_t)(sizeof addr)); if (rc < 0) { close(fd); return rc; } return fd; } static int get_socket_inet(const char *uri) { int rc, fd; const char *service, *host, *api; struct addrinfo hint, *rai, *iai; /* scan the uri */ api = strrchr(uri, '/'); service = strrchr(uri, ':'); if (api == NULL || service == NULL || api < service) { errno = EINVAL; return -1; } host = strndupa(uri, service++ - uri); service = strndupa(service, api - service); /* get addr */ memset(&hint, 0, sizeof hint); hint.ai_family = AF_INET; hint.ai_socktype = SOCK_STREAM; rc = getaddrinfo(host, service, &hint, &rai); if (rc != 0) { errno = EINVAL; return -1; } /* get the socket */ iai = rai; while (iai != NULL) { fd = socket(iai->ai_family, iai->ai_socktype, iai->ai_protocol); if (fd >= 0) { rc = connect(fd, iai->ai_addr, iai->ai_addrlen); if (rc == 0) { freeaddrinfo(rai); return fd; } close(fd); } iai = iai->ai_next; } freeaddrinfo(rai); return -1; } static int get_socket(const char *uri) { int fd; /* check for unix socket */ if (0 == strncmp(uri, "unix:", 5)) /* unix socket */ fd = get_socket_unix(uri + 5); else /* inet socket */ fd = get_socket_inet(uri); /* configure the socket */ if (fd >= 0) { fcntl(fd, F_SETFD, FD_CLOEXEC); fcntl(fd, F_SETFL, O_NONBLOCK); } return fd; } /* * Establish a websocket-like client connection to the API of 'uri' and if successful * instantiate a client afb_proto_ws websocket for this API using 'itf' and 'closure'. * (see afb_proto_ws_create_client). * The systemd event loop 'eloop' is used to handle the websocket. * Returns NULL in case of failure with errno set appropriately. */ struct afb_proto_ws *afb_ws_client_connect_api(struct sd_event *eloop, const char *uri, struct afb_proto_ws_client_itf *itf, void *closure) { int fd; struct afb_proto_ws *pws; struct fdev *fdev; fd = get_socket(uri); if (fd >= 0) { fdev = fdev_systemd_create(eloop, fd); if (fdev) { pws = afb_proto_ws_create_client(fdev, itf, closure); if (pws) return pws; } close(fd); } return NULL; }