From owner-svn-soc-all@FreeBSD.ORG Sun Jul 27 05:33:40 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 49683443 for ; Sun, 27 Jul 2014 05:33:40 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 364862733 for ; Sun, 27 Jul 2014 05:33:40 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.8/8.14.8) with ESMTP id s6R5Xe9S016724 for ; Sun, 27 Jul 2014 05:33:40 GMT (envelope-from seiya@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.8/8.14.8/Submit) id s6R5XdmE016611 for svn-soc-all@FreeBSD.org; Sun, 27 Jul 2014 05:33:39 GMT (envelope-from seiya@FreeBSD.org) Date: Sun, 27 Jul 2014 05:33:39 GMT Message-Id: <201407270533.s6R5XdmE016611@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to seiya@FreeBSD.org using -f From: seiya@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271437 - soc2014/seiya/bootsplash/sys/dev/fb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Jul 2014 05:33:40 -0000 Author: seiya Date: Sun Jul 27 05:33:39 2014 New Revision: 271437 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271437 Log: fix a bug Modified: soc2014/seiya/bootsplash/sys/dev/fb/bmp.c Modified: soc2014/seiya/bootsplash/sys/dev/fb/bmp.c ============================================================================== --- soc2014/seiya/bootsplash/sys/dev/fb/bmp.c Sat Jul 26 21:33:17 2014 (r271436) +++ soc2014/seiya/bootsplash/sys/dev/fb/bmp.c Sun Jul 27 05:33:39 2014 (r271437) @@ -262,8 +262,8 @@ /* * range check to avoid explosions */ - if ((x_origin < 0) || (x_origin + count >= info->swidth) || - (y < 0) || (y >= info->sheight)) + if ((x_origin < 0) || (x_origin + count > info->swidth) || + (y < 0) || (y > info->sheight)) return; /* @@ -467,11 +467,12 @@ * two colour indexes to alternate between for the run */ if (*info->index) { - count = min(sx + width - x, *info->index); - bmp_draw_line(info, y, x, count, *(info->index+1)); - x += count; + if(sx + width - x > 0) { + count = min(sx + width - x, *info->index); + bmp_draw_line(info, y, x, count, *(info->index+1)); + x += count; + } info->index += 2; - /* * A leading zero is an escape; it may signal the end of the * bitmap, a cursor move, or some absolute data. @@ -494,7 +495,6 @@ i++, x++){ bmp_SetPix(info, x, y, *(info->index + 2 + i)); } - info->index += 2 + i + (i & 1); break; } From owner-svn-soc-all@FreeBSD.ORG Mon Jul 28 10:51:20 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2211DD38 for ; Mon, 28 Jul 2014 10:51:20 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0DED52520 for ; Mon, 28 Jul 2014 10:51:20 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.8/8.14.8) with ESMTP id s6SApKed005233 for ; Mon, 28 Jul 2014 10:51:20 GMT (envelope-from zkorchev@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s6SApGwj004535 for svn-soc-all@FreeBSD.org; Mon, 28 Jul 2014 10:51:16 GMT (envelope-from zkorchev@FreeBSD.org) Date: Mon, 28 Jul 2014 10:51:16 GMT Message-Id: <201407281051.s6SApGwj004535@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zkorchev@FreeBSD.org using -f From: zkorchev@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271471 - soc2014/zkorchev/freebsd_head/sbin/ifconfig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jul 2014 10:51:20 -0000 Author: zkorchev Date: Mon Jul 28 10:51:16 2014 New Revision: 271471 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271471 Log: ifconfig partial support for libsol Modified: soc2014/zkorchev/freebsd_head/sbin/ifconfig/Makefile soc2014/zkorchev/freebsd_head/sbin/ifconfig/af_inet.c soc2014/zkorchev/freebsd_head/sbin/ifconfig/af_inet6.c soc2014/zkorchev/freebsd_head/sbin/ifconfig/af_link.c soc2014/zkorchev/freebsd_head/sbin/ifconfig/af_nd6.c soc2014/zkorchev/freebsd_head/sbin/ifconfig/carp.c soc2014/zkorchev/freebsd_head/sbin/ifconfig/ifconfig.c soc2014/zkorchev/freebsd_head/sbin/ifconfig/ifconfig.h soc2014/zkorchev/freebsd_head/sbin/ifconfig/ifmac.c soc2014/zkorchev/freebsd_head/sbin/ifconfig/ifmedia.c Modified: soc2014/zkorchev/freebsd_head/sbin/ifconfig/Makefile ============================================================================== --- soc2014/zkorchev/freebsd_head/sbin/ifconfig/Makefile Mon Jul 28 08:22:08 2014 (r271470) +++ soc2014/zkorchev/freebsd_head/sbin/ifconfig/Makefile Mon Jul 28 10:51:16 2014 (r271471) @@ -58,6 +58,9 @@ LDADD+= -ljail .endif +LDADD+= -lsol +CFLAGS+= -DSOL_ON -I/usr/local/include + MAN= ifconfig.8 CFLAGS+= -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wnested-externs Modified: soc2014/zkorchev/freebsd_head/sbin/ifconfig/af_inet.c ============================================================================== --- soc2014/zkorchev/freebsd_head/sbin/ifconfig/af_inet.c Mon Jul 28 08:22:08 2014 (r271470) +++ soc2014/zkorchev/freebsd_head/sbin/ifconfig/af_inet.c Mon Jul 28 10:51:16 2014 (r271471) @@ -50,6 +50,9 @@ #include #include #include +#if defined(SOL_ON) +# include +#endif #include "ifconfig.h" @@ -67,6 +70,41 @@ if (sin == NULL) return; +#if defined(SOL_ON) + if (sol_format) { + const char *inet = inet_ntoa(sin->sin_addr); + + SOL_MAP_KEYL(&sol_stream, "inet"); + sol_string(&sol_stream, inet, strlen(inet)); + + if (ifa->ifa_flags & IFF_POINTOPOINT) { + sin = ifa->ifa_dstaddr ? + (struct sockaddr_in *)ifa->ifa_dstaddr : &null_sin; + inet = inet_ntoa(sin->sin_addr); + SOL_MAP_KEYL(&sol_stream, "-->"); + sol_string(&sol_stream, inet, strlen(inet)); + } + + sin = ifa->ifa_netmask ? + (struct sockaddr_in *)ifa->ifa_netmask : &null_sin; + SOL_MAP_KEYL(&sol_stream, "netmask"); + sol_uinteger(&sol_stream, ntohl(sin->sin_addr.s_addr)); + + if (ifa->ifa_flags & IFF_BROADCAST) { + sin = (struct sockaddr_in *)ifa->ifa_broadaddr; + if (sin != NULL && sin->sin_addr.s_addr != 0) { + inet = inet_ntoa(sin->sin_addr); + SOL_MAP_KEYL(&sol_stream, "broadcast"); + sol_string(&sol_stream, inet, strlen(inet)); + } + } + + print_vhid(ifa, " "); + + return; + } +#endif + printf("\tinet %s ", inet_ntoa(sin->sin_addr)); if (ifa->ifa_flags & IFF_POINTOPOINT) { @@ -170,7 +208,16 @@ if (getnameinfo(sa, sa->sa_len, dst, sizeof(dst), 0, 0, NI_NUMERICHOST) != 0) dst[0] = '\0'; - printf("\ttunnel inet %s --> %s\n", src, dst); +#if defined(SOL_ON) + if (sol_format) { + SOL_MAP_KEYL(&sol_stream, "tunnel inet src"); + sol_string(&sol_stream, src, strlen(src)); + SOL_MAP_KEYL(&sol_stream, "tunnel inet dst"); + sol_string(&sol_stream, dst, strlen(dst)); + } + else +#endif + printf("\ttunnel inet %s --> %s\n", src, dst); } static void Modified: soc2014/zkorchev/freebsd_head/sbin/ifconfig/af_inet6.c ============================================================================== --- soc2014/zkorchev/freebsd_head/sbin/ifconfig/af_inet6.c Mon Jul 28 08:22:08 2014 (r271470) +++ soc2014/zkorchev/freebsd_head/sbin/ifconfig/af_inet6.c Mon Jul 28 10:51:16 2014 (r271471) @@ -51,6 +51,9 @@ #include #include #include +#if defined(SOL_ON) +# include +#endif #include /* Define ND6_INFINITE_LIFETIME */ @@ -208,7 +211,14 @@ if (error != 0) inet_ntop(AF_INET6, &sin->sin6_addr, addr_buf, sizeof(addr_buf)); - printf("\tinet6 %s ", addr_buf); +#if defined(SOL_ON) + if (sol_format) { + SOL_MAP_KEYL(&sol_stream, "inet6"); + sol_string(&sol_stream, addr_buf, strlen(addr_buf)); + } + else +#endif + printf("\tinet6 %s ", addr_buf); if (ifa->ifa_flags & IFF_POINTOPOINT) { sin = (struct sockaddr_in6 *)ifa->ifa_dstaddr; @@ -226,15 +236,78 @@ if (error != 0) inet_ntop(AF_INET6, &sin->sin6_addr, addr_buf, sizeof(addr_buf)); - printf("--> %s ", addr_buf); +#if defined(SOL_ON) + if (sol_format) { + SOL_MAP_KEYL(&sol_stream, "-->"); + sol_string(&sol_stream, addr_buf, strlen(addr_buf)); + } + else +#endif + printf("--> %s ", addr_buf); } } sin = (struct sockaddr_in6 *)ifa->ifa_netmask; if (sin == NULL) sin = &null_sin; - printf("prefixlen %d ", prefix(&sin->sin6_addr, - sizeof(struct in6_addr))); +#if defined(SOL_ON) + if (sol_format) { + SOL_MAP_KEYL(&sol_stream, "prefixlen"); + sol_integer(&sol_stream, prefix(&sin->sin6_addr, + sizeof(struct in6_addr))); + } + else +#endif + printf("prefixlen %d ", prefix(&sin->sin6_addr, + sizeof(struct in6_addr))); + +#if defined(SOL_ON) +# define S(s) sol_string(&sol_stream, s, sizeof(s) - 1) + if (sol_format) + { + SOL_MAP_KEYL(&sol_stream, "inet6 iff"); + sol_array_start(&sol_stream); + if ((flags6 & IN6_IFF_ANYCAST) != 0) S("anycast"); + if ((flags6 & IN6_IFF_TENTATIVE) != 0) S("tentative"); + if ((flags6 & IN6_IFF_DUPLICATED) != 0) S("duplicated"); + if ((flags6 & IN6_IFF_DETACHED) != 0) S("detached"); + if ((flags6 & IN6_IFF_DEPRECATED) != 0) S("deprecated"); + if ((flags6 & IN6_IFF_AUTOCONF) != 0) S("autoconf"); + if ((flags6 & IN6_IFF_TEMPORARY) != 0) S("temporary"); + sol_array_end(&sol_stream); + + if (((struct sockaddr_in6 *)(ifa->ifa_addr))->sin6_scope_id) { + SOL_MAP_KEYL(&sol_stream, "scopeid"); + sol_uinteger(&sol_stream, + ((struct sockaddr_in6 *)(ifa->ifa_addr))->sin6_scope_id); + } + + if (ip6lifetime && (lifetime.ia6t_preferred || lifetime.ia6t_expire)) { + SOL_MAP_KEYL(&sol_stream, "pltime"); + if (lifetime.ia6t_preferred) { + const char *pltime = lifetime.ia6t_preferred < t + ? "0" : sec2str(lifetime.ia6t_preferred - t); + + sol_string(&sol_stream, pltime, strlen(pltime)); + } else + S("infty"); + + SOL_MAP_KEYL(&sol_stream, "vltime"); + if (lifetime.ia6t_expire) { + const char *vltime = lifetime.ia6t_expire < t + ? "0" : sec2str(lifetime.ia6t_expire - t); + + sol_string(&sol_stream, vltime, strlen(vltime)); + } else + S("infty"); + } + + print_vhid(ifa, " "); + + return; + } +# undef S +#endif if ((flags6 & IN6_IFF_ANYCAST) != 0) printf("anycast "); @@ -253,7 +326,7 @@ if (((struct sockaddr_in6 *)(ifa->ifa_addr))->sin6_scope_id) printf("scopeid 0x%x ", - ((struct sockaddr_in6 *)(ifa->ifa_addr))->sin6_scope_id); + ((struct sockaddr_in6 *)(ifa->ifa_addr))->sin6_scope_id); if (ip6lifetime && (lifetime.ia6t_preferred || lifetime.ia6t_expire)) { printf("pltime "); @@ -434,7 +507,16 @@ NI_NUMERICHOST) != 0) dst[0] = '\0'; - printf("\ttunnel inet6 %s --> %s\n", src, dst); +#if defined(SOL_ON) + if (sol_format) { + SOL_MAP_KEYL(&sol_stream, "tunnel inet6 src"); + sol_string(&sol_stream, src, strlen(src)); + SOL_MAP_KEYL(&sol_stream, "tunnel inet6 dst"); + sol_string(&sol_stream, dst, strlen(dst)); + } + else +#endif + printf("\ttunnel inet6 %s --> %s\n", src, dst); } static void Modified: soc2014/zkorchev/freebsd_head/sbin/ifconfig/af_link.c ============================================================================== --- soc2014/zkorchev/freebsd_head/sbin/ifconfig/af_link.c Mon Jul 28 08:22:08 2014 (r271470) +++ soc2014/zkorchev/freebsd_head/sbin/ifconfig/af_link.c Mon Jul 28 10:51:16 2014 (r271471) @@ -46,6 +46,9 @@ #include #include #include +#if defined(SOL_ON) +# include +#endif #include "ifconfig.h" @@ -56,18 +59,36 @@ { /* XXX no const 'cuz LLADDR is defined wrong */ struct sockaddr_dl *sdl = (struct sockaddr_dl *) ifa->ifa_addr; + const char *address; if (sdl != NULL && sdl->sdl_alen > 0) { if ((sdl->sdl_type == IFT_ETHER || sdl->sdl_type == IFT_L2VLAN || sdl->sdl_type == IFT_BRIDGE) && - sdl->sdl_alen == ETHER_ADDR_LEN) - printf("\tether %s\n", - ether_ntoa((struct ether_addr *)LLADDR(sdl))); + sdl->sdl_alen == ETHER_ADDR_LEN) { +#if defined(SOL_ON) + if (sol_format) { + address = ether_ntoa((struct ether_addr *)LLADDR(sdl)); + SOL_MAP_KEYL(&sol_stream, "ether"); + sol_string(&sol_stream, address, strlen(address)); + } + else +#endif + printf("\tether %s\n", + ether_ntoa((struct ether_addr *)LLADDR(sdl))); + } else { int n = sdl->sdl_nlen > 0 ? sdl->sdl_nlen + 1 : 0; - printf("\tlladdr %s\n", link_ntoa(sdl) + n); +#if defined(SOL_ON) + if (sol_format) { + address = link_ntoa(sdl) + n; + SOL_MAP_KEYL(&sol_stream, "lladdr"); + sol_string(&sol_stream, address, strlen(address)); + } + else +#endif + printf("\tlladdr %s\n", link_ntoa(sdl) + n); } } } Modified: soc2014/zkorchev/freebsd_head/sbin/ifconfig/af_nd6.c ============================================================================== --- soc2014/zkorchev/freebsd_head/sbin/ifconfig/af_nd6.c Mon Jul 28 08:22:08 2014 (r271470) +++ soc2014/zkorchev/freebsd_head/sbin/ifconfig/af_nd6.c Mon Jul 28 10:51:16 2014 (r271471) @@ -52,6 +52,9 @@ #include #include +#if defined(SOL_ON) +# include +#endif #include "ifconfig.h" @@ -163,7 +166,15 @@ close(s6); if (nd.ndi.flags == 0 && !isdefif) return; - printb("\tnd6 options", - (unsigned int)(nd.ndi.flags | (isdefif << 15)), ND6BITS); - putchar('\n'); +#if defined(SOL_ON) + if (sol_format) + printb("nd6 options", + (unsigned int)(nd.ndi.flags | (isdefif << 15)), ND6BITS); + else +#endif + { + printb("\tnd6 options", + (unsigned int)(nd.ndi.flags | (isdefif << 15)), ND6BITS); + putchar('\n'); + } } Modified: soc2014/zkorchev/freebsd_head/sbin/ifconfig/carp.c ============================================================================== --- soc2014/zkorchev/freebsd_head/sbin/ifconfig/carp.c Mon Jul 28 08:22:08 2014 (r271470) +++ soc2014/zkorchev/freebsd_head/sbin/ifconfig/carp.c Mon Jul 28 10:51:16 2014 (r271471) @@ -48,6 +48,9 @@ #include #include #include +#if defined(SOL_ON) +# include +#endif #include "ifconfig.h" @@ -79,6 +82,33 @@ if (ioctl(s, SIOCGVH, (caddr_t)&ifr) == -1) return; +#if defined(SOL_ON) + if (sol_format) { + SOL_MAP_KEYL(&sol_stream, "carp"); + sol_array_start(&sol_stream); + for (i = 0; i < carpr[0].carpr_count; i++) { + sol_map_start(&sol_stream); + SOL_MAP_KEYL(&sol_stream, "state"); + sol_string(&sol_stream, carp_states[carpr[i].carpr_state], + strlen(carp_states[carpr[i].carpr_state])); + SOL_MAP_KEYL(&sol_stream, "vhid"); + sol_integer(&sol_stream, carpr[i].carpr_vhid); + SOL_MAP_KEYL(&sol_stream, "advbase"); + sol_integer(&sol_stream, carpr[i].carpr_advbase); + SOL_MAP_KEYL(&sol_stream, "advskew"); + sol_integer(&sol_stream, carpr[i].carpr_advskew); + if (printkeys && carpr[i].carpr_key[0] != '\0') { + SOL_MAP_KEYL(&sol_stream, "key"); + sol_string(&sol_stream, carpr[i].carpr_key, strlen(carpr[i].carpr_key)); + } + sol_map_end(&sol_stream); + } + sol_array_end(&sol_stream); + + return; + } +#endif + for (i = 0; i < carpr[0].carpr_count; i++) { printf("\tcarp: %s vhid %d advbase %d advskew %d", carp_states[carpr[i].carpr_state], carpr[i].carpr_vhid, Modified: soc2014/zkorchev/freebsd_head/sbin/ifconfig/ifconfig.c ============================================================================== --- soc2014/zkorchev/freebsd_head/sbin/ifconfig/ifconfig.c Mon Jul 28 08:22:08 2014 (r271470) +++ soc2014/zkorchev/freebsd_head/sbin/ifconfig/ifconfig.c Mon Jul 28 10:51:16 2014 (r271471) @@ -73,6 +73,9 @@ #include #include #include +#if defined(SOL_ON) +# include +#endif #include "ifconfig.h" @@ -94,6 +97,11 @@ int verbose; int noload; +#if defined(SOL_ON) +struct sol_stream sol_stream; +#endif +int sol_format; + int supmedia = 0; int printkeys = 0; /* Print keying material for interfaces. */ @@ -287,6 +295,10 @@ err(EXIT_FAILURE, "getifaddrs"); cp = NULL; ifindex = 0; +#if defined(SOL_ON) + sol_format = sol_init(&sol_stream); + if (sol_format) sol_map_start(&sol_stream); +#endif for (ifa = ifap; ifa; ifa = ifa->ifa_next) { memset(&paifr, 0, sizeof(paifr)); strncpy(paifr.ifr_name, ifa->ifa_name, sizeof(paifr.ifr_name)); @@ -351,8 +363,15 @@ else status(afp, sdl, ifa); } - if (namesonly) - printf("\n"); +#if defined(SOL_ON) + if (sol_format) { + sol_map_end(&sol_stream); + sol_term(&sol_stream); + } + else +#endif + if (namesonly) + printf("\n"); freeifaddrs(ifap); exit(0); @@ -931,13 +950,32 @@ if (s < 0) err(1, "socket(family %u,SOCK_DGRAM)", ifr.ifr_addr.sa_family); - printf("%s: ", name); - printb("flags", ifa->ifa_flags, IFFBITS); - if (ioctl(s, SIOCGIFMETRIC, &ifr) != -1) - printf(" metric %d", ifr.ifr_metric); - if (ioctl(s, SIOCGIFMTU, &ifr) != -1) - printf(" mtu %d", ifr.ifr_mtu); - putchar('\n'); +#if defined(SOL_ON) + if (sol_format) + { + sol_map_key(&sol_stream, name, strlen(name)); + sol_map_start(&sol_stream); + printb("flags", ifa->ifa_flags, IFFBITS); + if (ioctl(s, SIOCGIFMETRIC, &ifr) != -1) { + SOL_MAP_KEYL(&sol_stream, "metric"); + sol_integer(&sol_stream, ifr.ifr_metric); + } + if (ioctl(s, SIOCGIFMTU, &ifr) != -1) { + SOL_MAP_KEYL(&sol_stream, "mtu"); + sol_integer(&sol_stream, ifr.ifr_mtu); + } + } + else +#endif + { + printf("%s: ", name); + printb("flags", ifa->ifa_flags, IFFBITS); + if (ioctl(s, SIOCGIFMETRIC, &ifr) != -1) + printf(" metric %d", ifr.ifr_metric); + if (ioctl(s, SIOCGIFMTU, &ifr) != -1) + printf(" mtu %d", ifr.ifr_mtu); + putchar('\n'); + } for (;;) { if ((descr = reallocf(descr, descrlen)) != NULL) { @@ -945,9 +983,18 @@ ifr.ifr_buffer.length = descrlen; if (ioctl(s, SIOCGIFDESCR, &ifr) == 0) { if (ifr.ifr_buffer.buffer == descr) { - if (strlen(descr) > 0) - printf("\tdescription: %s\n", - descr); + size_t len = strlen(descr); + + if (len > 0) { +#if defined(SOL_ON) + if (sol_format) { + SOL_MAP_KEYL(&sol_stream, "description"); + sol_string(&sol_stream, descr, len); + } + else +#endif + printf("\tdescription: %s\n", descr); + } } else if (ifr.ifr_buffer.length > descrlen) { descrlen = ifr.ifr_buffer.length; continue; @@ -960,13 +1007,25 @@ } if (ioctl(s, SIOCGIFCAP, (caddr_t)&ifr) == 0) { - if (ifr.ifr_curcap != 0) { - printb("\toptions", ifr.ifr_curcap, IFCAPBITS); - putchar('\n'); - } - if (supmedia && ifr.ifr_reqcap != 0) { - printb("\tcapabilities", ifr.ifr_reqcap, IFCAPBITS); - putchar('\n'); +#if defined(SOL_ON) + if (sol_format) + { + if (ifr.ifr_curcap != 0) + printb("options", ifr.ifr_curcap, IFCAPBITS); + if (supmedia && ifr.ifr_reqcap != 0) + printb("capabilities", ifr.ifr_reqcap, IFCAPBITS); + } + else +#endif + { + if (ifr.ifr_curcap != 0) { + printb("\toptions", ifr.ifr_curcap, IFCAPBITS); + putchar('\n'); + } + if (supmedia && ifr.ifr_reqcap != 0) { + printb("\tcapabilities", ifr.ifr_reqcap, IFCAPBITS); + putchar('\n'); + } } } @@ -1011,6 +1070,10 @@ if (ioctl(s, SIOCGIFSTATUS, &ifs) == 0) printf("%s", ifs.ascii); +#if defined(SOL_ON) + if (sol_format) sol_map_end(&sol_stream); +#endif + close(s); return; } @@ -1048,6 +1111,34 @@ int i, any = 0; char c; +#if defined(SOL_ON) + if (sol_format) { + sol_map_key(&sol_stream, s, strlen(s)); + sol_map_start(&sol_stream); + SOL_MAP_KEYL(&sol_stream, "value"); + sol_integer(&sol_stream, v); + SOL_MAP_KEYL(&sol_stream, "list"); + if (++bits) { + const char *start; + + sol_array_start(&sol_stream); + while ((i = *bits++) != '\0') { + if (v & (1 << (i-1))) { + start = bits; + while ((c = *bits) > 32) + bits++; + sol_string(&sol_stream, start, bits - start); + } else + for (; *bits > 32; bits++) + ; + } + sol_array_end(&sol_stream); + } + sol_map_end(&sol_stream); + return; + } +#endif + if (bits && *bits == 8) printf("%s=%o", s, v); else @@ -1081,8 +1172,15 @@ ifd = ifa->ifa_data; if (ifd->ifi_vhid == 0) return; - - printf("vhid %d ", ifd->ifi_vhid); + +#if defined(SOL_ON) + if (sol_format) { + SOL_MAP_KEYL(&sol_stream, "vhid"); + sol_integer(&sol_stream, ifd->ifi_vhid); + } + else +#endif + printf("vhid %d ", ifd->ifi_vhid); } void Modified: soc2014/zkorchev/freebsd_head/sbin/ifconfig/ifconfig.h ============================================================================== --- soc2014/zkorchev/freebsd_head/sbin/ifconfig/ifconfig.h Mon Jul 28 08:22:08 2014 (r271470) +++ soc2014/zkorchev/freebsd_head/sbin/ifconfig/ifconfig.h Mon Jul 28 10:51:16 2014 (r271471) @@ -36,6 +36,11 @@ #define __constructor __attribute__((constructor)) +#if defined(SOL_ON) +extern struct sol_stream sol_stream; +#endif +extern int sol_format; + struct afswtch; struct cmd; Modified: soc2014/zkorchev/freebsd_head/sbin/ifconfig/ifmac.c ============================================================================== --- soc2014/zkorchev/freebsd_head/sbin/ifconfig/ifmac.c Mon Jul 28 08:22:08 2014 (r271470) +++ soc2014/zkorchev/freebsd_head/sbin/ifconfig/ifmac.c Mon Jul 28 10:51:16 2014 (r271471) @@ -46,6 +46,9 @@ #include #include #include +#if defined(SOL_ON) +# include +#endif #include "ifconfig.h" @@ -55,6 +58,7 @@ struct ifreq ifr; mac_t label; char *label_text; + size_t len; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); @@ -69,8 +73,17 @@ if (mac_to_text(label, &label_text) == -1) goto mac_free; - if (strlen(label_text) != 0) - printf("\tmaclabel %s\n", label_text); + len = strlen(label_text); + if (len != 0) { +#if defined(SOL_ON) + if (sol_format) { + SOL_MAP_KEYL(&sol_stream, "maclabel"); + sol_string(&sol_stream, label_text, len); + } + else +#endif + printf("\tmaclabel %s\n", label_text); + } free(label_text); mac_free: Modified: soc2014/zkorchev/freebsd_head/sbin/ifconfig/ifmedia.c ============================================================================== --- soc2014/zkorchev/freebsd_head/sbin/ifconfig/ifmedia.c Mon Jul 28 08:22:08 2014 (r271470) +++ soc2014/zkorchev/freebsd_head/sbin/ifconfig/ifmedia.c Mon Jul 28 10:51:16 2014 (r271471) @@ -82,6 +82,9 @@ #include #include #include +#if defined(SOL_ON) +# include +#endif #include "ifconfig.h" @@ -133,56 +136,111 @@ if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) err(1, "SIOCGIFMEDIA"); - printf("\tmedia: "); - print_media_word(ifmr.ifm_current, 1); - if (ifmr.ifm_active != ifmr.ifm_current) { - putchar(' '); - putchar('('); - print_media_word(ifmr.ifm_active, 0); - putchar(')'); +#if defined(SOL_ON) + if (sol_format) + { + SOL_MAP_KEYL(&sol_stream, "media"); + sol_map_start(&sol_stream); + print_media_word(ifmr.ifm_current, 1); + if (ifmr.ifm_active != ifmr.ifm_current) { + SOL_MAP_KEYL(&sol_stream, "active"); + sol_map_start(&sol_stream); + print_media_word(ifmr.ifm_active, 0); + sol_map_end(&sol_stream); + } + sol_map_end(&sol_stream); } + else +#endif + { + printf("\tmedia: "); + print_media_word(ifmr.ifm_current, 1); + if (ifmr.ifm_active != ifmr.ifm_current) { + putchar(' '); + putchar('('); + print_media_word(ifmr.ifm_active, 0); + putchar(')'); + } - putchar('\n'); + putchar('\n'); + } if (ifmr.ifm_status & IFM_AVALID) { - printf("\tstatus: "); + const char *status = 0; + size_t status_len; + +#define set(s) do { \ + status = s; \ + status_len = sizeof(s) - 1; \ +} while (0) + +#if defined(SOL_ON) + if (!sol_format) +#endif + printf("\tstatus: "); switch (IFM_TYPE(ifmr.ifm_active)) { case IFM_ETHER: case IFM_ATM: if (ifmr.ifm_status & IFM_ACTIVE) - printf("active"); + set("active"); else - printf("no carrier"); + set("no carrier"); break; case IFM_FDDI: case IFM_TOKEN: if (ifmr.ifm_status & IFM_ACTIVE) - printf("inserted"); + set("inserted"); else - printf("no ring"); + set("no ring"); break; case IFM_IEEE80211: if (ifmr.ifm_status & IFM_ACTIVE) { /* NB: only sta mode associates */ if (IFM_OPMODE(ifmr.ifm_active) == IFM_IEEE80211_STA) - printf("associated"); + set("associated"); else - printf("running"); + set("running"); } else - printf("no carrier"); + set("no carrier"); break; } - putchar('\n'); +#if defined(SOL_ON) + if (sol_format) { + SOL_MAP_KEYL(&sol_stream, "status"); + if (status_len) + sol_string(&sol_stream, status, status_len); + } + else +#endif + putchar('\n'); + +#undef set } if (ifmr.ifm_count > 0 && supmedia) { - printf("\tsupported media:\n"); - for (i = 0; i < ifmr.ifm_count; i++) { - printf("\t\t"); - print_media_word_ifconfig(media_list[i]); - putchar('\n'); +#if defined(SOL_ON) + if (sol_format) + { + SOL_MAP_KEYL(&sol_stream, "supported media"); + sol_array_start(&sol_stream); + for (i = 0; i < ifmr.ifm_count; i++) { + sol_map_start(&sol_stream); + print_media_word_ifconfig(media_list[i]); + sol_map_end(&sol_stream); + } + sol_array_end(&sol_stream); + } + else +#endif + { + printf("\tsupported media:\n"); + for (i = 0; i < ifmr.ifm_count; i++) { + printf("\t\t"); + print_media_word_ifconfig(media_list[i]); + putchar('\n'); + } } } @@ -703,10 +761,20 @@ desc = get_toptype_desc(ifmw); ttos = get_toptype_ttos(ifmw); if (desc->ifmt_string == NULL) { - printf(""); +#if defined(SOL_ON) + if (!sol_format) +#endif + printf(""); return; } else if (print_toptype) { - printf("%s", desc->ifmt_string); +#if defined(SOL_ON) + if (sol_format) { + SOL_MAP_KEYL(&sol_stream, "type"); + sol_string(&sol_stream, desc->ifmt_string, strlen(desc->ifmt_string)); + } + else +#endif + printf("%s", desc->ifmt_string); } /* @@ -717,39 +785,87 @@ /* Find subtype. */ desc = get_subtype_desc(ifmw, ttos); if (desc == NULL) { - printf(""); +#if defined(SOL_ON) + if (!sol_format) +#endif + printf(""); return; } - if (print_toptype) - putchar(' '); - - printf("%s", desc->ifmt_string); +#if defined(SOL_ON) + if (!sol_format) +#endif + if (print_toptype) + putchar(' '); + +#if defined(SOL_ON) + if (sol_format) { + SOL_MAP_KEYL(&sol_stream, "subtype"); + sol_string(&sol_stream, desc->ifmt_string, strlen(desc->ifmt_string)); + } + else +#endif + printf("%s", desc->ifmt_string); if (print_toptype) { desc = get_mode_desc(ifmw, ttos); - if (desc != NULL && strcasecmp("autoselect", desc->ifmt_string)) - printf(" mode %s", desc->ifmt_string); + if (desc != NULL && strcasecmp("autoselect", desc->ifmt_string)) { +#if defined(SOL_ON) + if (sol_format) { + SOL_MAP_KEYL(&sol_stream, "mode"); + sol_string(&sol_stream, desc->ifmt_string, strlen(desc->ifmt_string)); + } + else +#endif + printf(" mode %s", desc->ifmt_string); + } } /* Find options. */ +#if defined(SOL_ON) + if (sol_format) { + SOL_MAP_KEYL(&sol_stream, "options"); + sol_array_start(&sol_stream); + } +#endif for (i = 0; ttos->options[i].desc != NULL; i++) { if (ttos->options[i].alias) continue; for (desc = ttos->options[i].desc; desc->ifmt_string != NULL; desc++) { if (ifmw & desc->ifmt_word) { - if (seen_option == 0) - printf(" <"); - printf("%s%s", seen_option++ ? "," : "", - desc->ifmt_string); +#if defined(SOL_ON) + if (sol_format) + sol_string(&sol_stream, + desc->ifmt_string, strlen(desc->ifmt_string)); + else +#endif + { + if (seen_option == 0) + printf(" <"); + printf("%s%s", seen_option++ ? "," : "", + desc->ifmt_string); + } } } } - printf("%s", seen_option ? ">" : ""); - - if (print_toptype && IFM_INST(ifmw) != 0) - printf(" instance %d", IFM_INST(ifmw)); +#if defined(SOL_ON) + if (sol_format) + sol_array_end(&sol_stream); + else +#endif + printf("%s", seen_option ? ">" : ""); + + if (print_toptype && IFM_INST(ifmw) != 0) { +#if defined(SOL_ON) + if (sol_format) { + SOL_MAP_KEYL(&sol_stream, "instance"); + sol_integer(&sol_stream, IFM_INST(ifmw)); + } + else +#endif + printf(" instance %d", IFM_INST(ifmw)); + } } static void @@ -763,7 +879,10 @@ desc = get_toptype_desc(ifmw); ttos = get_toptype_ttos(ifmw); if (desc->ifmt_string == NULL) { - printf(""); +#if defined(SOL_ON) + if (!sol_format) +#endif + printf(""); return; } @@ -775,33 +894,76 @@ /* Find subtype. */ desc = get_subtype_desc(ifmw, ttos); if (desc == NULL) { - printf(""); +#if defined(SOL_ON) + if (!sol_format) +#endif + printf(""); return; } - printf("media %s", desc->ifmt_string); +#if defined(SOL_ON) + if (sol_format) { + SOL_MAP_KEYL(&sol_stream, "media"); + sol_string(&sol_stream, desc->ifmt_string, strlen(desc->ifmt_string)); + } + else +#endif + printf("media %s", desc->ifmt_string); desc = get_mode_desc(ifmw, ttos); - if (desc != NULL) - printf(" mode %s", desc->ifmt_string); + if (desc != NULL) { +#if defined(SOL_ON) + if (sol_format) { + SOL_MAP_KEYL(&sol_stream, "mode"); + sol_string(&sol_stream, desc->ifmt_string, strlen(desc->ifmt_string)); + } + else +#endif + printf(" mode %s", desc->ifmt_string); + } /* Find options. */ +#if defined(SOL_ON) + if (sol_format) { + SOL_MAP_KEYL(&sol_stream, "options"); + sol_array_start(&sol_stream); + } +#endif for (i = 0; ttos->options[i].desc != NULL; i++) { if (ttos->options[i].alias) continue; for (desc = ttos->options[i].desc; desc->ifmt_string != NULL; desc++) { if (ifmw & desc->ifmt_word) { - if (seen_option == 0) - printf(" mediaopt "); - printf("%s%s", seen_option++ ? "," : "", - desc->ifmt_string); +#if defined(SOL_ON) + if (sol_format) + sol_string(&sol_stream, + desc->ifmt_string, strlen(desc->ifmt_string)); + else +#endif + { + if (seen_option == 0) + printf(" mediaopt "); + printf("%s%s", seen_option++ ? "," : "", + desc->ifmt_string); + } } } } - - if (IFM_INST(ifmw) != 0) - printf(" instance %d", IFM_INST(ifmw)); +#if defined(SOL_ON) + if (sol_format) sol_array_end(&sol_stream); +#endif + + if (IFM_INST(ifmw) != 0) { +#if defined(SOL_ON) + if (sol_format) { + SOL_MAP_KEYL(&sol_stream, "instance"); + sol_integer(&sol_stream, IFM_INST(ifmw)); + } + else +#endif + printf(" instance %d", IFM_INST(ifmw)); + } } /********************************************************************** From owner-svn-soc-all@FreeBSD.ORG Mon Jul 28 19:13:20 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5F0B71AF for ; Mon, 28 Jul 2014 19:13:20 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 315D8260D for ; Mon, 28 Jul 2014 19:13:20 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.8/8.14.8) with ESMTP id s6SJDKUn031899 for ; Mon, 28 Jul 2014 19:13:20 GMT (envelope-from kczekirda@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s6SJDJ7W031896 for svn-soc-all@FreeBSD.org; Mon, 28 Jul 2014 19:13:19 GMT (envelope-from kczekirda@FreeBSD.org) Date: Mon, 28 Jul 2014 19:13:19 GMT Message-Id: <201407281913.s6SJDJ7W031896@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to kczekirda@FreeBSD.org using -f From: kczekirda@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271486 - in soc2014/kczekirda/pxe-fai-head: head/usr.sbin/bsdinstall/scripts others MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jul 2014 19:13:20 -0000 Author: kczekirda Date: Mon Jul 28 19:13:19 2014 New Revision: 271486 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271486 Log: mentor's comments Modified: soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/scripts/zfsboot soc2014/kczekirda/pxe-fai-head/others/zfspressed Modified: soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/scripts/zfsboot ============================================================================== --- soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/scripts/zfsboot Mon Jul 28 14:41:22 2014 (r271485) +++ soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/scripts/zfsboot Mon Jul 28 19:13:19 2014 (r271486) @@ -171,9 +171,7 @@ ############################################################ PRESSED -if [ -f "$1" ]; then - . "$1" - fi +[ -f "$1"] && . "$1" ############################################################ GLOBALS @@ -1395,7 +1393,7 @@ # Loop over the main menu until we've accomplished what we came here to do # while :; do - if [ ! f_interactive ] || [ "$ZFSBOOT_PRESSED_CONFIRM" = "YES" ]; then + if ! f_interactive || [ "$ZFSBOOT_PRESSED_CONFIRM" = "YES" ]; then retval=$DIALOG_OK mtag=">>> $msg_install" else @@ -1459,7 +1457,7 @@ # # Last Chance! # - if [ f_interactive] && [ ! $ZFSBOOT_PRESSED_CONFIRM ] ; then + if f_interactive && [ ! $ZFSBOOT_PRESSED_CONFIRM ] ; then dialog_last_chance $ZFSBOOT_DISKS || continue fi Modified: soc2014/kczekirda/pxe-fai-head/others/zfspressed ============================================================================== --- soc2014/kczekirda/pxe-fai-head/others/zfspressed Mon Jul 28 14:41:22 2014 (r271485) +++ soc2014/kczekirda/pxe-fai-head/others/zfspressed Mon Jul 28 19:13:19 2014 (r271486) @@ -6,7 +6,7 @@ # # Default options to use when creating zroot pool # -ZFSBOOT_POOL_CREATE_OPTIONS:="-O compress=lz4 -O atime=off" +ZFSBOOT_POOL_CREATE_OPTIONS="-O compress=lz4 -O atime=off" # # Default name for the boot environment parent dataset From owner-svn-soc-all@FreeBSD.ORG Mon Jul 28 19:13:29 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D077E1C9 for ; Mon, 28 Jul 2014 19:13:29 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BD7592612 for ; Mon, 28 Jul 2014 19:13:29 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.8/8.14.8) with ESMTP id s6SJDTvx031964 for ; Mon, 28 Jul 2014 19:13:29 GMT (envelope-from kczekirda@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s6SJDT0S031962 for svn-soc-all@FreeBSD.org; Mon, 28 Jul 2014 19:13:29 GMT (envelope-from kczekirda@FreeBSD.org) Date: Mon, 28 Jul 2014 19:13:29 GMT Message-Id: <201407281913.s6SJDT0S031962@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to kczekirda@FreeBSD.org using -f From: kczekirda@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271487 - soc2014/kczekirda/pxe-fai-head/others MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jul 2014 19:13:29 -0000 Author: kczekirda Date: Mon Jul 28 19:13:28 2014 New Revision: 271487 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271487 Log: variable name fix Modified: soc2014/kczekirda/pxe-fai-head/others/template.input Modified: soc2014/kczekirda/pxe-fai-head/others/template.input ============================================================================== --- soc2014/kczekirda/pxe-fai-head/others/template.input Mon Jul 28 19:13:19 2014 (r271486) +++ soc2014/kczekirda/pxe-fai-head/others/template.input Mon Jul 28 19:13:28 2014 (r271487) @@ -21,7 +21,7 @@ #IPV6="NO" #SLAAC="YES" #ADDRESSV6="2001:db8:4672:6565:2026:5043:2d42:5344" -#PREFIXV="64" +#PREFIXV6="64" #GWV6="2001:db8:4672:6565::1" #DNS1V6="2001:4860:4860::8888" #DNS2V6="2001:4860:4860::8844" From owner-svn-soc-all@FreeBSD.ORG Tue Jul 29 10:50:00 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 12F3C895 for ; Tue, 29 Jul 2014 10:50:00 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E7F0B292E for ; Tue, 29 Jul 2014 10:49:59 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s6TAnxwW079942 for ; Tue, 29 Jul 2014 10:49:59 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s6TAnwcw079903 for svn-soc-all@FreeBSD.org; Tue, 29 Jul 2014 10:49:58 GMT (envelope-from dpl@FreeBSD.org) Date: Tue, 29 Jul 2014 10:49:58 GMT Message-Id: <201407291049.s6TAnwcw079903@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271525 - soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Jul 2014 10:50:00 -0000 Author: dpl Date: Tue Jul 29 10:49:57 2014 New Revision: 271525 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271525 Log: Added a first version of lockcheckvnet() Added: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.c Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.h Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c ============================================================================== --- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c Tue Jul 29 09:46:08 2014 (r271524) +++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c Tue Jul 29 10:49:57 2014 (r271525) @@ -128,7 +128,6 @@ static unsigned int default_fw_tables = IPFW_TABLES_DEFAULT; /* JIT compiling API */ -void ipfw_jit_init(); funcptr compile_code(); /* Pointer to the actual compiled code */ @@ -266,7 +265,7 @@ ipfw_chk(struct ip_fw_args *args) { if (compiledfuncptr == 0) - compiledfuncptr = compile_code(); + compiledfuncptr = compile_code(args); if ((int)compiledfuncptr != 0) { return compiledfuncptr(); @@ -655,11 +654,9 @@ args->f_id.dst_port = dst_port = ntohs(dst_port); } - IPFW_PF_RLOCK(chain); - if (! V_ipfw_vnet_ready) { /* shutting down, leave NOW. */ - IPFW_PF_RUNLOCK(chain); - return (IP_FW_PASS); /* accept */ - } + /* Returns -1 on error */ + if (lockcheckvnet(chain)) + return (IP_FW_PASS); if (args->rule.slot) { /* * Packet has already been tagged as a result of a previous @@ -1230,9 +1227,6 @@ ipfw_log_bpf(1); /* init */ - /* Start JIT */ - ipfw_jit_init(); - return (error); } Added: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.c Tue Jul 29 10:49:57 2014 (r271525) @@ -0,0 +1,7 @@ +/* + * This is the file that gets compiled when + * generating bitcode. + */ + + #define IPFW_RULES_INLINE __unused + #include "ip_fw_rules.h" Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h ============================================================================== --- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h Tue Jul 29 09:46:08 2014 (r271524) +++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h Tue Jul 29 10:49:57 2014 (r271525) @@ -1921,3 +1921,19 @@ } *done = 1; /* exit outer loop */ } + +/* + * From here on, there's ip_fw2 code, so that + * we can add this to our jit compiled code. + */ +static IPFW_RULES_INLINE int +lockcheckvnet(struct ip_fw_chain *chain) +{ + IPFW_PF_RLOCK(chain); + if (! V_ipfw_vnet_ready) { /* shutting down, leave NOW. */ + IPFW_PF_RUNLOCK(chain); + return (-1); /* accept */ + } + return 0; +} + Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc ============================================================================== --- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc Tue Jul 29 09:46:08 2014 (r271524) +++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc Tue Jul 29 10:49:57 2014 (r271525) @@ -1,15 +1,21 @@ /* JIT compilation code */ +#include + #include #include #include #include #include +#include #include #include #include #include +#include "ip_fw_private.h" +#include "ip_fw_private.h" + typedef int (*funcptr)(); using namespace llvm; @@ -19,6 +25,7 @@ LLVMContext con; LLVMContext &c = con; OwningPtr buffer; + //IRBuilder<> irb; public: jitCompiler(std::string name) { @@ -37,14 +44,27 @@ } mod = ptr.get(); } -} ; -extern "C" void -ipfw_jit_init() + int + loadStub(std::string funcname) + { + return 0; + } +}; + +extern "C" funcptr +compile_code(struct ip_fw_args *args) { jitCompiler("ip_fw_rules.bc"); - /* XXX - We have to understand what we have to here. + int f_pos = 0; /* index of current rule in the array */ + + // Now I have to load the stubs of the loaded rules. + // For that, I need a table: RULE, "functname", #args + + // Iterate through the rules. + + /* // Get the stub (prototype) for the cell function F = Mod->getFunction("cell"); // Set it to have private linkage, so that it can be removed after being @@ -85,11 +105,5 @@ } */ -} - -/* The mother of all functions! */ -extern "C" funcptr -compile_code() -{ return 0; } Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.h ============================================================================== --- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.h Tue Jul 29 09:46:08 2014 (r271524) +++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.h Tue Jul 29 10:49:57 2014 (r271525) @@ -1,4 +1,5 @@ +#include "ip_fw_private.h" + typedef int (*funcptr)(); -void ipfw_jit_init(); -funcptr compile_code(); +funcptr compile_code(struct ip_fw_args *); From owner-svn-soc-all@FreeBSD.ORG Tue Jul 29 17:14:16 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B3E2FA38 for ; Tue, 29 Jul 2014 17:14:16 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9F00D29FB for ; Tue, 29 Jul 2014 17:14:16 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s6THEGCJ074992 for ; Tue, 29 Jul 2014 17:14:16 GMT (envelope-from shonali@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s6THEDsP074942 for svn-soc-all@FreeBSD.org; Tue, 29 Jul 2014 17:14:13 GMT (envelope-from shonali@FreeBSD.org) Date: Tue, 29 Jul 2014 17:14:13 GMT Message-Id: <201407291714.s6THEDsP074942@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to shonali@FreeBSD.org using -f From: shonali@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271539 - soc2014/shonali/head/contrib/bsnmp/snmpd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Jul 2014 17:14:16 -0000 Author: shonali Date: Tue Jul 29 17:14:13 2014 New Revision: 271539 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271539 Log: Added ipv6 code for trap.c and made changes in other files. Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/config.c soc2014/shonali/head/contrib/bsnmp/snmpd/main.c soc2014/shonali/head/contrib/bsnmp/snmpd/snmpd.config soc2014/shonali/head/contrib/bsnmp/snmpd/snmpd.h soc2014/shonali/head/contrib/bsnmp/snmpd/snmpmod.h soc2014/shonali/head/contrib/bsnmp/snmpd/trans_lsock.c soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udp.c soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udpv6.c soc2014/shonali/head/contrib/bsnmp/snmpd/trap.c soc2014/shonali/head/contrib/bsnmp/snmpd/tree.def Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/config.c ============================================================================== --- soc2014/shonali/head/contrib/bsnmp/snmpd/config.c Tue Jul 29 16:42:34 2014 (r271538) +++ soc2014/shonali/head/contrib/bsnmp/snmpd/config.c Tue Jul 29 17:14:13 2014 (r271539) @@ -811,7 +811,7 @@ unsigned char tmp[16]; /* ipv6 implementation of network to host byte order function */ - + /* May be unnecessary - check */ if (BYTE_ORDER == LITTLE_ENDIAN) { tmp[3] = (sain->sin6_addr.s6_addr[0] << 24) | (sain->sin6_addr.s6_addr[1] << 16) | (sain->sin6_addr.s6_addr[2] << 8) | sain->sin6_addr.s6_addr[3]; tmp[2] = (sain->sin6_addr.s6_addr[4] << 24) | (sain->sin6_addr.s6_addr[5] << 16) | (sain->sin6_addr.s6_addr[6] << 8) | sain->sin6_addr.s6_addr[7]; Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/main.c ============================================================================== --- soc2014/shonali/head/contrib/bsnmp/snmpd/main.c Tue Jul 29 16:42:34 2014 (r271538) +++ soc2014/shonali/head/contrib/bsnmp/snmpd/main.c Tue Jul 29 17:14:13 2014 (r271539) @@ -1104,79 +1104,6 @@ } /* - * Input from a datagram socket. - * Each receive should return one datagram. - */ -static int -recv_dgram(struct port_input *pi, struct in6_addr *laddr) -{ - u_char embuf[1000]; - char cbuf[CMSG_SPACE(SOCKCREDSIZE(CMGROUP_MAX)) + - CMSG_SPACE(sizeof(struct in6_addr))]; - struct msghdr msg; - struct iovec iov[1]; - ssize_t len; - struct cmsghdr *cmsg; - struct sockcred *cred = NULL; - - if (pi->buf == NULL) { - /* no buffer yet - allocate one */ - if ((pi->buf = buf_alloc(0)) == NULL) { - /* ups - could not get buffer. Read away input - * and drop it */ - (void)recvfrom(pi->fd, embuf, sizeof(embuf), - 0, NULL, NULL); - /* return error */ - return (-1); - } - pi->buflen = buf_size(0); - } - - /* try to get a message */ - msg.msg_name = pi->peer; - msg.msg_namelen = pi->peerlen; - msg.msg_iov = iov; - msg.msg_iovlen = 1; - memset(cbuf, 0, sizeof(cbuf)); - msg.msg_control = cbuf; - msg.msg_controllen = sizeof(cbuf); - msg.msg_flags = 0; - - iov[0].iov_base = pi->buf; - iov[0].iov_len = pi->buflen; - - len = recvmsg(pi->fd, &msg, 0); - - if (len == -1 || len == 0) - /* receive error */ - return (-1); - - if (msg.msg_flags & MSG_TRUNC) { - /* truncated - drop */ - snmpd_stats.silentDrops++; - snmpd_stats.inTooLong++; - return (-1); - } - - pi->length = (size_t)len; - - for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; - cmsg = CMSG_NXTHDR(&msg, cmsg)) { - if (cmsg->cmsg_level == IPPROTO_IPV6 && - cmsg->cmsg_type == IP_RECVDSTADDR) /* Check for ipv6 alternative */ - memcpy(laddr, CMSG_DATA(cmsg), sizeof(struct in6_addr)); - if (cmsg->cmsg_level == SOL_SOCKET && - cmsg->cmsg_type == SCM_CREDS) - cred = (struct sockcred *)CMSG_DATA(cmsg); - } - - if (pi->cred) - check_priv_dgram(pi, cred); - - return (0); -} - -/* * Input from a socket */ int @@ -1193,10 +1120,7 @@ #ifdef USE_TCPWRAPPERS char client[16]; #endif - struct msghdr msg; struct iovec iov[1]; - char cbuf[CMSG_SPACE(sizeof(struct in6_addr))]; - struct cmsghdr *cmsgp; /* get input depending on the transport */ if (pi->stream) { @@ -1205,23 +1129,7 @@ ret = recv_stream(pi); } else { - struct in6_addr *laddr; - - memset(cbuf, 0, CMSG_SPACE(sizeof(struct in6_addr))); - msg.msg_control = cbuf; - msg.msg_controllen = CMSG_SPACE(sizeof(struct in6_addr)); - cmsgp = CMSG_FIRSTHDR(&msg); - cmsgp->cmsg_len = CMSG_LEN(sizeof(struct in6_addr)); - cmsgp->cmsg_level = IPPROTO_IPV6; - cmsgp->cmsg_type = IP_SENDSRCADDR; /* Check for ipv6 alternative */ - laddr = (struct in6_addr *)CMSG_DATA(cmsgp); - - ret = recv_dgram(pi, laddr); - - if (laddr->s6_addr == 0) { - msg.msg_control = NULL; - msg.msg_controllen = 0; - } + ret = tport->transport->vtab->recv(tp, pi); } if (ret == -1) @@ -1233,7 +1141,7 @@ */ if (pi->peer->sa_family != AF_LOCAL && inet_ntop(pi->peer->sa_family, - &((const struct sockaddr_in6 *)(const void *)pi->peer)->sin6_addr, + &((const struct sockaddr_in *)(const void *)pi->peer)->sin_addr, client, sizeof(client)) != NULL) { request_set(&req, RQ_CLIENT_ADDR, client, 0); if (hosts_access(&req) == 0) { Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/snmpd.config ============================================================================== --- soc2014/shonali/head/contrib/bsnmp/snmpd/snmpd.config Tue Jul 29 16:42:34 2014 (r271538) +++ soc2014/shonali/head/contrib/bsnmp/snmpd/snmpd.config Tue Jul 29 17:14:13 2014 (r271539) @@ -71,8 +71,8 @@ begemotSnmpdCommunityDisable = 1 # open standard SNMP ports -begemotSnmpdPortStatus.::.161.2 = 1 -begemotSnmpdPortStatus.::1.161.2 = 1 +begemotSnmpdPortStatus.0:0:0:0:0:0:0:0.161.2 = 1 +begemotSnmpdPortStatus.0:0:0:0:0:0:0:1.161.2 = 1 # open a unix domain socket begemotSnmpdLocalPortStatus."/var/run/snmpd.sock" = 1 Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/snmpd.h ============================================================================== --- soc2014/shonali/head/contrib/bsnmp/snmpd/snmpd.h Tue Jul 29 16:42:34 2014 (r271538) +++ soc2014/shonali/head/contrib/bsnmp/snmpd/snmpd.h Tue Jul 29 17:14:13 2014 (r271539) @@ -193,6 +193,7 @@ ssize_t (*send)(struct tport *, const u_char *, size_t, const struct sockaddr *, size_t); + ssize_t (*recv)(struct tport *, struct port_input *); }; struct transport { struct asn_oid index; /* transport table index */ Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/snmpmod.h ============================================================================== --- soc2014/shonali/head/contrib/bsnmp/snmpd/snmpmod.h Tue Jul 29 16:42:34 2014 (r271538) +++ soc2014/shonali/head/contrib/bsnmp/snmpd/snmpmod.h Tue Jul 29 17:14:13 2014 (r271539) @@ -471,6 +471,7 @@ }; #define SNMP_UDP_ADDR_SIZ 6 +#define SNMP_UDP_ADDRv6_SIZ 18 #define SNMP_TAG_SIZ (255 + 1) struct target_address { Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/trans_lsock.c ============================================================================== --- soc2014/shonali/head/contrib/bsnmp/snmpd/trans_lsock.c Tue Jul 29 16:42:34 2014 (r271538) +++ soc2014/shonali/head/contrib/bsnmp/snmpd/trans_lsock.c Tue Jul 29 17:14:13 2014 (r271539) @@ -58,6 +58,7 @@ static int lsock_init_port(struct tport *); static ssize_t lsock_send(struct tport *, const u_char *, size_t, const struct sockaddr *, size_t); +static ssize_t lsock_recv(struct tport *, struct port_input *); /* exported */ const struct transport_def lsock_trans = { @@ -68,6 +69,7 @@ lsock_close_port, lsock_init_port, lsock_send + lsock_recv }; static struct transport *my_trans; @@ -422,6 +424,110 @@ } /* + * Receive something + */ +static ssize_t +lsock_recv(struct tport *tp, struct port_input *pi) +{ + struct in_addr *laddr; + int ret; + struct msghdr msg; + char cbuf[CMSG_SPACE(sizeof(struct in_addr))]; + struct cmsghdr *cmsgp; + + memset(cbuf, 0, CMSG_SPACE(sizeof(struct in_addr))); + msg.msg_control = cbuf; + msg.msg_controllen = CMSG_SPACE(sizeof(struct in_addr)); + cmsgp = CMSG_FIRSTHDR(&msg); + cmsgp->cmsg_len = CMSG_LEN(sizeof(struct in_addr)); + cmsgp->cmsg_level = IPPROTO_IP; + cmsgp->cmsg_type = IP_SENDSRCADDR; + laddr = (struct in_addr *)CMSG_DATA(cmsgp); + + ret = recv_dgram(pi, laddr); + + if (laddr->s_addr == 0) { + msg.msg_control = NULL; + msg.msg_controllen = 0; + } + + return (ret); +} + +/* + * Input from a datagram socket. + * Each receive should return one datagram. + */ +static int +recv_dgram(struct port_input *pi, struct in_addr *laddr) +{ + u_char embuf[1000]; + char cbuf[CMSG_SPACE(SOCKCREDSIZE(CMGROUP_MAX)) + + CMSG_SPACE(sizeof(struct in_addr))]; + struct msghdr msg; + struct iovec iov[1]; + ssize_t len; + struct cmsghdr *cmsg; + struct sockcred *cred = NULL; + + if (pi->buf == NULL) { + /* no buffer yet - allocate one */ + if ((pi->buf = buf_alloc(0)) == NULL) { + /* ups - could not get buffer. Read away input + * and drop it */ + (void)recvfrom(pi->fd, embuf, sizeof(embuf), + 0, NULL, NULL); + /* return error */ + return (-1); + } + pi->buflen = buf_size(0); + } + + /* try to get a message */ + msg.msg_name = pi->peer; + msg.msg_namelen = pi->peerlen; + msg.msg_iov = iov; + msg.msg_iovlen = 1; + memset(cbuf, 0, sizeof(cbuf)); + msg.msg_control = cbuf; + msg.msg_controllen = sizeof(cbuf); + msg.msg_flags = 0; + + iov[0].iov_base = pi->buf; + iov[0].iov_len = pi->buflen; + + len = recvmsg(pi->fd, &msg, 0); + + if (len == -1 || len == 0) + /* receive error */ + return (-1); + + if (msg.msg_flags & MSG_TRUNC) { + /* truncated - drop */ + snmpd_stats.silentDrops++; + snmpd_stats.inTooLong++; + return (-1); + } + + pi->length = (size_t)len; + + for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; + cmsg = CMSG_NXTHDR(&msg, cmsg)) { + if (cmsg->cmsg_level == IPPROTO_IP && + cmsg->cmsg_type == IP_RECVDSTADDR) + memcpy(laddr, CMSG_DATA(cmsg), sizeof(struct in_addr)); + if (cmsg->cmsg_level == SOL_SOCKET && + cmsg->cmsg_type == SCM_CREDS) + cred = (struct sockcred *)CMSG_DATA(cmsg); + } + + if (pi->cred) + check_priv_dgram(pi, cred); + + return (0); +} + +/* * Dependency to create a lsock port */ struct lsock_dep { Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udp.c ============================================================================== --- soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udp.c Tue Jul 29 16:42:34 2014 (r271538) +++ soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udp.c Tue Jul 29 17:14:13 2014 (r271539) @@ -54,6 +54,7 @@ static int udp_init_port(struct tport *); static ssize_t udp_send(struct tport *, const u_char *, size_t, const struct sockaddr *, size_t); +static ssize_t udp_recv(struct tport *, struct port_input *); /* exported */ const struct transport_def udp_trans = { @@ -64,6 +65,7 @@ udp_close_port, udp_init_port, udp_send + udp_recv }; static struct transport *my_trans; @@ -219,6 +221,111 @@ } /* + * Receive something + */ +static ssize_t +udp_recv(struct tport *tp, struct port_input *pi) +{ + struct in_addr *laddr; + int ret; + struct msghdr msg; + char cbuf[CMSG_SPACE(sizeof(struct in_addr))]; + struct cmsghdr *cmsgp; + + memset(cbuf, 0, CMSG_SPACE(sizeof(struct in_addr))); + msg.msg_control = cbuf; + msg.msg_controllen = CMSG_SPACE(sizeof(struct in_addr)); + cmsgp = CMSG_FIRSTHDR(&msg); + cmsgp->cmsg_len = CMSG_LEN(sizeof(struct in_addr)); + cmsgp->cmsg_level = IPPROTO_IP; + cmsgp->cmsg_type = IP_SENDSRCADDR; + laddr = (struct in_addr *)CMSG_DATA(cmsgp); + + ret = recv_dgram(pi, laddr); + + if (laddr->s_addr == 0) { + msg.msg_control = NULL; + msg.msg_controllen = 0; + } + + return (ret); +} + +/* + * Input from a datagram socket. + * Each receive should return one datagram. + */ +static int +recv_dgram(struct port_input *pi, struct in_addr *laddr) +{ + u_char embuf[1000]; + char cbuf[CMSG_SPACE(SOCKCREDSIZE(CMGROUP_MAX)) + + CMSG_SPACE(sizeof(struct in_addr))]; + struct msghdr msg; + struct iovec iov[1]; + ssize_t len; + struct cmsghdr *cmsg; + struct sockcred *cred = NULL; + + if (pi->buf == NULL) { + /* no buffer yet - allocate one */ + if ((pi->buf = buf_alloc(0)) == NULL) { + /* ups - could not get buffer. Read away input + * and drop it */ + (void)recvfrom(pi->fd, embuf, sizeof(embuf), + 0, NULL, NULL); + /* return error */ + return (-1); + } + pi->buflen = buf_size(0); + } + + /* try to get a message */ + msg.msg_name = pi->peer; + msg.msg_namelen = pi->peerlen; + msg.msg_iov = iov; + msg.msg_iovlen = 1; + memset(cbuf, 0, sizeof(cbuf)); + msg.msg_control = cbuf; + msg.msg_controllen = sizeof(cbuf); + msg.msg_flags = 0; + + iov[0].iov_base = pi->buf; + iov[0].iov_len = pi->buflen; + + len = recvmsg(pi->fd, &msg, 0); + + if (len == -1 || len == 0) + /* receive error */ + return (-1); + + + if (msg.msg_flags & MSG_TRUNC) { + /* truncated - drop */ + snmpd_stats.silentDrops++; + snmpd_stats.inTooLong++; + return (-1); + } + + pi->length = (size_t)len; + + for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; + cmsg = CMSG_NXTHDR(&msg, cmsg)) { + if (cmsg->cmsg_level == IPPROTO_IP && + cmsg->cmsg_type == IP_RECVDSTADDR) + memcpy(laddr, CMSG_DATA(cmsg), sizeof(struct in_addr)); + if (cmsg->cmsg_level == SOL_SOCKET && + cmsg->cmsg_type == SCM_CREDS) + cred = (struct sockcred *)CMSG_DATA(cmsg); + } + + if (pi->cred) + check_priv_dgram(pi, cred); + + return (0); +} + +/* * Port table */ int Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udpv6.c ============================================================================== --- soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udpv6.c Tue Jul 29 16:42:34 2014 (r271538) +++ soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udpv6.c Tue Jul 29 17:14:13 2014 (r271539) @@ -54,6 +54,7 @@ static int udpv6_init_port(struct tport *); static ssize_t udpv6_send(struct tport *, const u_char *, size_t, const struct sockaddr *, size_t); +static ssize_t udpv6_recv(struct tport *, struct port_input *); /* exported */ const struct transport_def udpv6_trans = { @@ -64,6 +65,7 @@ udpv6_close_port, udpv6_init_port, udpv6_send + udpv6_recv }; static struct transport *my_trans; @@ -225,6 +227,110 @@ } /* + * Receive something + */ +static ssize_t +udpv6_recv(struct tport *tp, struct port_input *pi) +{ + struct in6_addr *laddr; + int ret; + struct msghdr msg; + char cbuf[CMSG_SPACE(sizeof(struct in6_addr))]; + struct cmsghdr *cmsgp; + + memset(cbuf, 0, CMSG_SPACE(sizeof(struct in6_addr))); + msg.msg_control = cbuf; + msg.msg_controllen = CMSG_SPACE(sizeof(struct in6_addr)); + cmsgp = CMSG_FIRSTHDR(&msg); + cmsgp->cmsg_len = CMSG_LEN(sizeof(struct in6_addr)); + cmsgp->cmsg_level = IPPROTO_IPV6; + cmsgp->cmsg_type = IP_SENDSRCADDR; /* Check for ipv6 alternative */ + laddr = (struct in6_addr *)CMSG_DATA(cmsgp); + + ret = recv_v6dgram(pi, laddr); + + if (laddr->s6_addr == 0) { + msg.msg_control = NULL; + msg.msg_controllen = 0; + } + + return (ret); +} + +/* + * Input from a datagram socket. + * Each receive should return one datagram. + */ +static int +recv_v6dgram(struct port_input *pi, struct in6_addr *laddr) +{ + u_char embuf[1000]; + char cbuf[CMSG_SPACE(SOCKCREDSIZE(CMGROUP_MAX)) + + CMSG_SPACE(sizeof(struct in6_addr))]; + struct msghdr msg; + struct iovec iov[1]; + ssize_t len; + struct cmsghdr *cmsg; + struct sockcred *cred = NULL; + + if (pi->buf == NULL) { + /* no buffer yet - allocate one */ + if ((pi->buf = buf_alloc(0)) == NULL) { + /* ups - could not get buffer. Read away input + * and drop it */ + (void)recvfrom(pi->fd, embuf, sizeof(embuf), + 0, NULL, NULL); + /* return error */ + return (-1); + } + pi->buflen = buf_size(0); + } + + /* try to get a message */ + msg.msg_name = pi->peer; + msg.msg_namelen = pi->peerlen; + msg.msg_iov = iov; + msg.msg_iovlen = 1; + memset(cbuf, 0, sizeof(cbuf)); + msg.msg_control = cbuf; + msg.msg_controllen = sizeof(cbuf); + msg.msg_flags = 0; + + iov[0].iov_base = pi->buf; + iov[0].iov_len = pi->buflen; + + len = recvmsg(pi->fd, &msg, 0); + + if (len == -1 || len == 0) + /* receive error */ + return (-1); + + if (msg.msg_flags & MSG_TRUNC) { + /* truncated - drop */ + snmpd_stats.silentDrops++; + snmpd_stats.inTooLong++; + return (-1); + } + + pi->length = (size_t)len; + + for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; + cmsg = CMSG_NXTHDR(&msg, cmsg)) { + if (cmsg->cmsg_level == IPPROTO_IPV6 && + cmsg->cmsg_type == IP_RECVDSTADDR) /* Check for ipv6 alternative */ + memcpy(laddr, CMSG_DATA(cmsg), sizeof(struct in6_addr)); + if (cmsg->cmsg_level == SOL_SOCKET && + cmsg->cmsg_type == SCM_CREDS) + cred = (struct sockcred *)CMSG_DATA(cmsg); + } + + if (pi->cred) + check_priv_dgram(pi, cred); + + return (0); +} + +/* * Port table */ int Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/trap.c ============================================================================== --- soc2014/shonali/head/contrib/bsnmp/snmpd/trap.c Tue Jul 29 16:42:34 2014 (r271538) +++ soc2014/shonali/head/contrib/bsnmp/snmpd/trap.c Tue Jul 29 17:14:13 2014 (r271539) @@ -104,7 +104,6 @@ trapsink_create(struct trapsink_dep *tdep) { struct trapsink *t; - struct sockaddr_in sa; if ((t = malloc(sizeof(*t))) == NULL) return (SNMP_ERR_RES_UNAVAIL); @@ -114,28 +113,19 @@ t->comm[0] = '\0'; t->version = TRAPSINK_V2; - if ((t->socket = socket(PF_INET, SOCK_DGRAM, 0)) == -1) { - syslog(LOG_ERR, "socket(UDP): %m"); - free(t); - return (SNMP_ERR_RES_UNAVAIL); - } - (void)shutdown(t->socket, SHUT_RD); - memset(&sa, 0, sizeof(sa)); - sa.sin_len = sizeof(sa); - sa.sin_family = AF_INET; - sa.sin_addr.s_addr = htonl((t->index.subs[0] << 24) | - (t->index.subs[1] << 16) | (t->index.subs[2] << 8) | - (t->index.subs[3] << 0)); - sa.sin_port = htons(t->index.subs[4]); - - if (connect(t->socket, (struct sockaddr *)&sa, sa.sin_len) == -1) { - syslog(LOG_ERR, "connect(%s,%u): %m", - inet_ntoa(sa.sin_addr), ntohs(sa.sin_port)); - (void)close(t->socket); - free(t); - return (SNMP_ERR_GENERR); - } - + switch (sizeof(t->index.subs)) { + /* IPv4 - Check if there is a better way of determining address type */ + case 6: + trapsink_create_sock(t); + + /* IPv6 - Check if there is a better way of determining address type */ + case 18: + trapsink_create_sockv6(t); + + default: + return (NULL); + } + if (tdep->set & TDEP_VERSION) t->version = tdep->version; if (tdep->set & TDEP_COMM) @@ -162,6 +152,67 @@ return (SNMP_ERR_NOERROR); } +static void +trapsink_create_sock(struct trapsink *t) +{ + struct sockaddr_in sa; + if ((t->socket = socket(PF_INET, SOCK_DGRAM, 0)) == -1) { + syslog(LOG_ERR, "socket(UDP): %m"); + free(t); + return (SNMP_ERR_RES_UNAVAIL); + } + (void)shutdown(t->socket, SHUT_RD); + memset(&sa, 0, sizeof(sa)); + sa.sin_len = sizeof(sa); + sa.sin_family = AF_INET; + sa.sin_addr.s_addr = htonl((t->index.subs[0] << 24) | + (t->index.subs[1] << 16) | (t->index.subs[2] << 8) | + (t->index.subs[3] << 0)); + sa.sin_port = htons(t->index.subs[4]); + + if (connect(t->socket, (struct sockaddr *)&sa, sa.sin_len) == -1) { + syslog(LOG_ERR, "connect(%s,%u): %m", + inet_ntoa(sa.sin_addr), ntohs(sa.sin_port)); + (void)close(t->socket); + free(t); + return (SNMP_ERR_GENERR); + } + + +} + +static void +trapsink_create_sockv6(struct trapsink *t) +{ + struct sockaddr_in6 sa; + if ((t->socket = socket(PF_INET6, SOCK_DGRAM, 0)) == -1) { + syslog(LOG_ERR, "socket(UDP): %m"); + free(t); + return (SNMP_ERR_RES_UNAVAIL); + } + (void)shutdown(t->socket, SHUT_RD); + memset(&sa, 0, sizeof(sa)); + sa.sin6_len = sizeof(sa); + sa.sin6_family = AF_INET6; + /* Host to network byte order not reqd - check */ + sa.sin6_addr.s6_addr = (t->index.subs[0] << 120) | (t->index.subs[1] << 112) | (t->index.subs[2] << 104) | (t->index.subs[3] << 96) | (t->index.subs[4] << 88) | + (t->index.subs[5] << 80) | (t->index.subs[6] << 72) | (t->index.subs[7] << 64) | (t->index.subs[8] << 56) | + (t->index.subs[9] << 48) | (t->index.subs[10] << 40) | (t->index.subs[11] << 32) | (t->index.subs[12] << 24) | + (t->index.subs[13] << 16) | (t->index.subs[14] << 8) | t->index.subs[15]; + sa.sin6_port = htons(t->index.subs[16]); + + if (connect(t->socket, (struct sockaddr *)&sa, sa.sin6_len) == -1) { + syslog(LOG_ERR, "connect(%s,%u): %m", + inet_ntoa(sa.sin6_addr), ntohs(sa.sin6_port)); + (void)close(t->socket); + free(t); + return (SNMP_ERR_GENERR); + } + + + +} + static void trapsink_free(struct trapsink *t) { @@ -720,31 +771,69 @@ int target_activate_address(struct target_address *addrs) { - struct sockaddr_in sa; - - if ((addrs->socket = socket(PF_INET, SOCK_DGRAM, 0)) == -1) { - syslog(LOG_ERR, "socket(UDP): %m"); - return (SNMP_ERR_RES_UNAVAIL); - } - - (void)shutdown(addrs->socket, SHUT_RD); - memset(&sa, 0, sizeof(sa)); - sa.sin_len = sizeof(sa); - sa.sin_family = AF_INET; - - sa.sin_addr.s_addr = htonl((addrs->address[0] << 24) | - (addrs->address[1] << 16) | (addrs->address[2] << 8) | - (addrs->address[3] << 0)); - sa.sin_port = htons(addrs->address[4]) << 8 | - htons(addrs->address[5]) << 0; - - if (connect(addrs->socket, (struct sockaddr *)&sa, sa.sin_len) == -1) { - syslog(LOG_ERR, "connect(%s,%u): %m", - inet_ntoa(sa.sin_addr), ntohs(sa.sin_port)); - (void)close(addrs->socket); - return (SNMP_ERR_GENERR); - } - + /* IPv4/IPv6 - Check if there is a better way of determining address type */ + switch (sizeof(*addrs)) { + + case 6: + struct sockaddr_in sa; + + if ((addrs->socket = socket(PF_INET, SOCK_DGRAM, 0)) == -1) { + syslog(LOG_ERR, "socket(UDP): %m"); + return (SNMP_ERR_RES_UNAVAIL); + } + + (void)shutdown(addrs->socket, SHUT_RD); + memset(&sa, 0, sizeof(sa)); + sa.sin_len = sizeof(sa); + sa.sin_family = AF_INET; + + sa.sin_addr.s_addr = htonl((addrs->address[0] << 24) | + (addrs->address[1] << 16) | (addrs->address[2] << 8) | + (addrs->address[3] << 0)); + sa.sin_port = htons(addrs->address[4]) << 8 | + htons(addrs->address[5]) << 0; + + if (connect(addrs->socket, (struct sockaddr *)&sa, sa.sin_len) == -1) { + syslog(LOG_ERR, "connect(%s,%u): %m", + inet_ntoa(sa.sin_addr), ntohs(sa.sin_port)); + (void)close(addrs->socket); + return (SNMP_ERR_GENERR); + } + + + case 18: + struct sockaddr_in6 sa; + + if ((addrs->socket = socket(PF_INET6, SOCK_DGRAM, 0)) == -1) { + syslog(LOG_ERR, "socket(UDP): %m"); + return (SNMP_ERR_RES_UNAVAIL); + } + + (void)shutdown(addrs->socket, SHUT_RD); + memset(&sa, 0, sizeof(sa)); + sa.sin6_len = sizeof(sa); + sa.sin6_family = AF_INET6; + /* Host to network byte order not reqd - check */ + sa.sin6_addr.s6_addr = (addrs->address[0] << 120) | (addrs->address[1] << 112) | (addrs->address[2] << 104) | (addrs->address[3] << 96) | (addrs->address[4] << 88) | + (addrs->address[5] << 80) | (addrs->address[6] << 72) | (addrs->address[7] << 64) | (addrs->address[8] << 56) | + (addrs->address[9] << 48) | (addrs->address[10] << 40) | (addrs->address[11] << 32) | (addrs->address[12] << 24) | + (addrs->address[13] << 16) | (addrs->address[14] << 8) | addrs->address[15]; + sa.sin6_port = htons(addrs->address[16]) << 8 | + htons(addrs->address[17]) << 0; + + if (connect(addrs->socket, (struct sockaddr *)&sa, sa.sin6_len) == -1) { + syslog(LOG_ERR, "connect(%s,%u): %m", + inet_ntoa(sa.sin6_addr), ntohs(sa.sin6_port)); + (void)close(addrs->socket); + return (SNMP_ERR_GENERR); + } + + + default: + return (NULL); + } + + addrs->status = RowStatus_active; return (SNMP_ERR_NOERROR); Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/tree.def ============================================================================== --- soc2014/shonali/head/contrib/bsnmp/snmpd/tree.def Tue Jul 29 16:42:34 2014 (r271538) +++ soc2014/shonali/head/contrib/bsnmp/snmpd/tree.def Tue Jul 29 17:14:13 2014 (r271539) @@ -32,7 +32,12 @@ # #include "tc.def" - +typedef InetAddressType ENUM ( + 0 unknown + 1 ipv4 + 2 ipv6 + 16 dnsi + ) typedef RowStatus ENUM ( 1 active 2 notInService @@ -121,11 +126,11 @@ # Port table # (4 begemotSnmpdPortTable - (1 begemotSnmpdPortEntry : InetAddress InetAddressType INTEGER op_snmp_port + (1 begemotSnmpdPortEntry : InetAddress INTEGER op_snmp_port InetAddressType (1 begemotSnmpdPortAddress InetAddress) - (4 begemotSnmpdPortAddressType InetAddressType) (2 begemotSnmpdPortPort UNSIGNED32) (3 begemotSnmpdPortStatus INTEGER GET SET) + (4 begemotSnmpdPortAddressType InetAddressType) )) # # Community table From owner-svn-soc-all@FreeBSD.ORG Tue Jul 29 17:17:59 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 56FE4B53 for ; Tue, 29 Jul 2014 17:17:59 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 28FE82A3E for ; Tue, 29 Jul 2014 17:17:59 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s6THHxYG078524 for ; Tue, 29 Jul 2014 17:17:59 GMT (envelope-from shonali@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s6THHwB8078521 for svn-soc-all@FreeBSD.org; Tue, 29 Jul 2014 17:17:58 GMT (envelope-from shonali@FreeBSD.org) Date: Tue, 29 Jul 2014 17:17:58 GMT Message-Id: <201407291717.s6THHwB8078521@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to shonali@FreeBSD.org using -f From: shonali@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271540 - soc2014/shonali/head/usr.sbin/bsnmpd/tools/bsnmptools MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Jul 2014 17:17:59 -0000 Author: shonali Date: Tue Jul 29 17:17:58 2014 New Revision: 271540 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271540 Log: Added code to support ipv6 in bsnmpget.c. Modified: soc2014/shonali/head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c Modified: soc2014/shonali/head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c ============================================================================== --- soc2014/shonali/head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c Tue Jul 29 17:14:13 2014 (r271539) +++ soc2014/shonali/head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c Tue Jul 29 17:17:58 2014 (r271540) @@ -608,16 +608,33 @@ char *endptr, *str; str = val; - for (i = 0; i < 4; i++) { - v = strtoul(str, &endptr, 10); - if (v > 0xff) - return (-1); - if (*endptr != '.' && *endptr != '\0' && i != 3) - break; - str = endptr + 1; - value->v.ipaddress[i] = (uint8_t) v; - } + + switch (sizeof(*addrs)) { + case 4: + for (i = 0; i < 4; i++) { + v = strtoul(str, &endptr, 10); + if (v > 0xff) + return (-1); + if (*endptr != '.' && *endptr != '\0' && i != 3) + break; + str = endptr + 1; + value->v.ipaddress[i] = (uint8_t) v; + } + case 16: + for (i = 0; i < 16; i++) { + v = strtoul(str, &endptr, 16); + if (v > 0xff) + return (-1); + if (*endptr != ':' && *endptr != '\0' && i != 15) + break; + str = endptr + 1; + value->v.ipaddress[i] = (uint8_t) v; + } + + default: + return (NULL); + } value->syntax = SNMP_SYNTAX_IPADDRESS; return (0); } @@ -946,9 +963,18 @@ int8_t i; dst->syntax = SNMP_SYNTAX_IPADDRESS; - for (i = 0; i < 4; i++) - dst->v.ipaddress[i] = src->v.ipaddress[i]; + + switch (sizeof(src->v.ipaddress)) { + case 4: + for (i = 0; i < 4; i++) + dst->v.ipaddress[i] = src->v.ipaddress[i]; + case 16: + for (i = 0; i < 16; i++) + dst->v.ipaddress[i] = src->v.ipaddress[i]; + default: + return (NULL); + } return (1); } From owner-svn-soc-all@FreeBSD.ORG Tue Jul 29 17:18:47 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E471CB6C for ; Tue, 29 Jul 2014 17:18:46 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D04892A43 for ; Tue, 29 Jul 2014 17:18:46 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s6THIkQk078823 for ; Tue, 29 Jul 2014 17:18:46 GMT (envelope-from shonali@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s6THIkpM078820 for svn-soc-all@FreeBSD.org; Tue, 29 Jul 2014 17:18:46 GMT (envelope-from shonali@FreeBSD.org) Date: Tue, 29 Jul 2014 17:18:46 GMT Message-Id: <201407291718.s6THIkpM078820@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to shonali@FreeBSD.org using -f From: shonali@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271541 - soc2014/shonali/head/usr.sbin/bsnmpd/tools/libbsnmptools MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Jul 2014 17:18:47 -0000 Author: shonali Date: Tue Jul 29 17:18:46 2014 New Revision: 271541 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271541 Log: Added code to support ipv6 code in bsnmptools.c Modified: soc2014/shonali/head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Modified: soc2014/shonali/head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c ============================================================================== --- soc2014/shonali/head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Tue Jul 29 17:17:58 2014 (r271540) +++ soc2014/shonali/head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Tue Jul 29 17:18:46 2014 (r271541) @@ -1097,17 +1097,35 @@ char *endptr, *ptr; ptr = str; - for (i = 0; i < 4; i++) { - v = strtoul(ptr, &endptr, 10); - if (v > 0xff) - return (NULL); - if (*endptr != '.' && strchr("],\0", *endptr) == NULL && i != 3) - return (NULL); - if (snmp_suboid_append(oid, (asn_subid_t) v) < 0) - return (NULL); - ptr = endptr + 1; - } + + switch (sizeof(*str)) { + case 4: + for (i = 0; i < 4; i++) { + v = strtoul(ptr, &endptr, 10); + if (v > 0xff) + return (NULL); + if (*endptr != '.' && strchr("],\0", *endptr) == NULL && i != 3) + return (NULL); + if (snmp_suboid_append(oid, (asn_subid_t) v) < 0) + return (NULL); + ptr = endptr + 1; + } + case 16: + for (i = 0; i < 16; i++) { + v = strtoul(ptr, &endptr, 16); + if (v > 0xff) + return (NULL); + if (*endptr != ':' && strchr("],\0", *endptr) == NULL && i != 15) + return (NULL); + if (snmp_suboid_append(oid, (asn_subid_t) v) < 0) + return (NULL); + ptr = endptr + 1; + } + + default: + return (NULL); + } return (endptr); } @@ -1741,8 +1759,15 @@ if (GET_OUTPUT(snmptoolctx) == OUTPUT_VERBOSE) fprintf(stdout, "%s : ", syntax_strings[SNMP_SYNTAX_IPADDRESS].str); - - fprintf(stdout, "%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]); + + switch (sizeof(*ip)) { + case 4: + fprintf(stdout, "%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]); + case 16: + fprintf(stdout, "%u.%u.%u.%u.%u.%u.%u.%u.%u.%u.%u.%u.%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3], ip[4], ip[5], ip[6], ip[7], ip[8], ip[9], ip[10], ip[11], ip[12], ip[13], ip[14], ip[15]); + default: + return (NULL); + } } static void @@ -1896,7 +1921,6 @@ snmp_output_index(struct snmp_toolinfo *snmptoolctx, struct index *stx, struct asn_oid *oid) { - uint8_t ip[4]; uint32_t bytes = 1; uint64_t cnt64; struct asn_oid temp, out; @@ -1934,11 +1958,24 @@ case SNMP_SYNTAX_IPADDRESS: if (temp.len < 4) return (-1); - for (bytes = 0; bytes < 4; bytes++) - ip[bytes] = temp.subs[bytes]; - - snmp_output_ipaddress(snmptoolctx, ip); - bytes = 4; + + switch (sizeof(temp.len)) { + case 4: + uint8_t ip[4]; + for (bytes = 0; bytes < 4; bytes++) + ip[bytes] = temp.subs[bytes]; + snmp_output_ipaddress(snmptoolctx, ip); + bytes = 4; + case 16: + uint8_t ip[16]; + for (bytes = 0; bytes < 16; bytes++) + ip[bytes] = temp.subs[bytes]; + snmp_output_ipaddress(snmptoolctx, ip); + bytes = 16; + + default: + return (NULL); + } break; case SNMP_SYNTAX_COUNTER: From owner-svn-soc-all@FreeBSD.ORG Tue Jul 29 18:20:08 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id F0DC4D6 for ; Tue, 29 Jul 2014 18:20:07 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DCECE21E0 for ; Tue, 29 Jul 2014 18:20:07 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s6TIK7Al036992 for ; Tue, 29 Jul 2014 18:20:07 GMT (envelope-from shonali@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s6TIK7mn036827 for svn-soc-all@FreeBSD.org; Tue, 29 Jul 2014 18:20:07 GMT (envelope-from shonali@FreeBSD.org) Date: Tue, 29 Jul 2014 18:20:07 GMT Message-Id: <201407291820.s6TIK7mn036827@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to shonali@FreeBSD.org using -f From: shonali@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271542 - soc2014/shonali/head/contrib/bsnmp/snmpd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Jul 2014 18:20:08 -0000 Author: shonali Date: Tue Jul 29 18:20:06 2014 New Revision: 271542 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271542 Log: Added ipv6 support for target_address(trap) Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/snmpmod.h soc2014/shonali/head/contrib/bsnmp/snmpd/trap.c Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/snmpmod.h ============================================================================== --- soc2014/shonali/head/contrib/bsnmp/snmpd/snmpmod.h Tue Jul 29 17:18:46 2014 (r271541) +++ soc2014/shonali/head/contrib/bsnmp/snmpd/snmpmod.h Tue Jul 29 18:20:06 2014 (r271542) @@ -477,6 +477,7 @@ struct target_address { char name[SNMP_ADM_STR32_SIZ]; uint8_t address[SNMP_UDP_ADDR_SIZ]; + uint8_t address6[SNMP_UDP_ADDRv6_SIZ]; int32_t timeout; int32_t retry; char taglist[SNMP_TAG_SIZ]; Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/trap.c ============================================================================== --- soc2014/shonali/head/contrib/bsnmp/snmpd/trap.c Tue Jul 29 17:18:46 2014 (r271541) +++ soc2014/shonali/head/contrib/bsnmp/snmpd/trap.c Tue Jul 29 18:20:06 2014 (r271542) @@ -771,8 +771,9 @@ int target_activate_address(struct target_address *addrs) { - /* IPv4/IPv6 - Check if there is a better way of determining address type */ - switch (sizeof(*addrs)) { + /* XXX - IPv4/IPv6 - Check if there is a better way of determining address type - Change switch code */ + + switch (sizeof(*addrs->address)) { case 6: struct sockaddr_in sa; @@ -814,16 +815,16 @@ sa.sin6_len = sizeof(sa); sa.sin6_family = AF_INET6; /* Host to network byte order not reqd - check */ - sa.sin6_addr.s6_addr = (addrs->address[0] << 120) | (addrs->address[1] << 112) | (addrs->address[2] << 104) | (addrs->address[3] << 96) | (addrs->address[4] << 88) | - (addrs->address[5] << 80) | (addrs->address[6] << 72) | (addrs->address[7] << 64) | (addrs->address[8] << 56) | - (addrs->address[9] << 48) | (addrs->address[10] << 40) | (addrs->address[11] << 32) | (addrs->address[12] << 24) | - (addrs->address[13] << 16) | (addrs->address[14] << 8) | addrs->address[15]; - sa.sin6_port = htons(addrs->address[16]) << 8 | - htons(addrs->address[17]) << 0; - + sa.sin6_addr.s6_addr = (addrs->address6[0] << 120) | (addrs->address6[1] << 112) | (addrs->address6[2] << 104) | (addrs->address6[3] << 96) | (addrs->address6[4] << 88) | + (addrs->address6[5] << 80) | (addrs->address6[6] << 72) | (addrs->address6[7] << 64) | (addrs->address6[8] << 56) | + (addrs->address6[9] << 48) | (addrs->address6[10] << 40) | (addrs->address6[11] << 32) | (addrs->address6[12] << 24) | + (addrs->address6[13] << 16) | (addrs->address6[14] << 8) | addrs->address6[15]; + sa.sin6_port = htons(addrs->address6[16]) << 8 | + htons(addrs->address6[17]) << 0; + char dst[INET6_ADDRSTRLEN]; + inet_ntop(AF_INET6,&(sa.sin6_addr), dst, INET6_ADDRSTRLEN); if (connect(addrs->socket, (struct sockaddr *)&sa, sa.sin6_len) == -1) { - syslog(LOG_ERR, "connect(%s,%u): %m", - inet_ntoa(sa.sin6_addr), ntohs(sa.sin6_port)); + syslog(LOG_ERR, "connect(%s,%u): %m", dst, ntohs(sa.sin6_port)); (void)close(addrs->socket); return (SNMP_ERR_GENERR); } From owner-svn-soc-all@FreeBSD.ORG Tue Jul 29 20:10:11 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 28F3091A for ; Tue, 29 Jul 2014 20:10:11 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 152402F1C for ; Tue, 29 Jul 2014 20:10:11 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s6TKAAfX031455 for ; Tue, 29 Jul 2014 20:10:10 GMT (envelope-from pedrosouza@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s6TKAA2q031451 for svn-soc-all@FreeBSD.org; Tue, 29 Jul 2014 20:10:10 GMT (envelope-from pedrosouza@FreeBSD.org) Date: Tue, 29 Jul 2014 20:10:10 GMT Message-Id: <201407292010.s6TKAA2q031451@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to pedrosouza@FreeBSD.org using -f From: pedrosouza@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271551 - soc2014/pedrosouza/lua_loader/head/sys/boot/lua MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Jul 2014 20:10:11 -0000 Author: pedrosouza Date: Tue Jul 29 20:10:09 2014 New Revision: 271551 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271551 Log: Added brand & logo drawing to boot menu Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua ============================================================================== --- soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua Tue Jul 29 19:49:38 2014 (r271550) +++ soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua Tue Jul 29 20:10:09 2014 (r271551) @@ -1,5 +1,6 @@ include("/boot/core.lua"); include("/boot/screen.lua"); +include("/boot/drawer.lua"); menu = {}; @@ -26,6 +27,8 @@ screen.clear(); menu.draw(6, 11, opts); menu.drawbox(4, 10, 40, 10); + drawer.drawbrand(); + drawer.drawlogo(); local ch = string.char(io.getchar()); if (opts[ch] ~= nil) then local ret = opts[ch].func(); @@ -66,15 +69,14 @@ ["2"] = {index = 2, name = "Boot Single user", func = function () core.setSingleUser(true); loader.perform("boot"); end}, ["3"] = {index = 3, name = "Escape to lua interpreter", func = function () return true; end}, ["4"] = {index = 4, name = "Reboot", func = function () loader.perform("reboot"); end}, - ["5"] = {index = 5, name = "Boot Options", func = function () menu.run(boot_options); return false; end} , - ["6"] = {index = 6, name = "Load zfs", func = function () loader.perform("load zfs"); return false; end} + ["5"] = {index = 5, name = "Boot Options", func = function () menu.run(boot_options); return false; end} }; function OnOff(str, b) if (b) then - return str .. ": On"; + return str .. color.escapef(color.GREEN)..": On"..color.escapef(color.WHITE); else - return str .. ": Off"; + return str .. color.escapef(color.RED)..": Off"..color.escapef(color.WHITE); end end Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua ============================================================================== --- soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua Tue Jul 29 19:49:38 2014 (r271550) +++ soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua Tue Jul 29 20:10:09 2014 (r271551) @@ -1,4 +1,36 @@ screen = {}; +color = {}; + +color.BLACK = 0; +color.RED = 1; +color.GREEN = 2; +color.YELLOW = 3; +color.BLUE = 4; +color.MAGENTA = 5; +color.CYAN = 6; +color.WHITE = 7; + +color.DEFAULT = 0; +color.BRIGHT = 1; +color.DIM = 2; + + +function color.escapef(c) + return "\027[3"..c.."m"; +end + +function color.escapeb(c) + return "\027[4"..c.."m"; +end + +function color.escape(fg, bg, att) + if not att then att = "" else att = att..";"; end + return "\027["..att.."3"..fg..";4"..bg.."m"; +end + +function color.default() + return "\027[0;37;40m"; +end function screen.clear() print("\027[H\027[J"); @@ -14,4 +46,12 @@ function screen.setbackground(c) print("\027[4"..c.."m"); +end + +function screen.defcolor() + print(color.default()); +end + +function screen.defcursor() + print("\027[24;0H"); end \ No newline at end of file From owner-svn-soc-all@FreeBSD.ORG Wed Jul 30 11:06:01 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4E9F8D74 for ; Wed, 30 Jul 2014 11:06:01 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3AFB22CF4 for ; Wed, 30 Jul 2014 11:06:01 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s6UB61Iv004343 for ; Wed, 30 Jul 2014 11:06:01 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s6UB60KA004332 for svn-soc-all@FreeBSD.org; Wed, 30 Jul 2014 11:06:00 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 30 Jul 2014 11:06:00 GMT Message-Id: <201407301106.s6UB60KA004332@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271600 - soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jul 2014 11:06:01 -0000 Author: dpl Date: Wed Jul 30 11:05:59 2014 New Revision: 271600 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271600 Log: Refactored some of the ip_fw2.c code, to be compiled to bitcode and used by the JIT Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c ============================================================================== --- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c Wed Jul 30 09:17:40 2014 (r271599) +++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c Wed Jul 30 11:05:59 2014 (r271600) @@ -105,7 +105,7 @@ */ /* ipfw_vnet_ready controls when we are open for business */ -static VNET_DEFINE(int, ipfw_vnet_ready) = 0; +VNET_DEFINE(int, ipfw_vnet_ready) = 0; #define V_ipfw_vnet_ready VNET(ipfw_vnet_ready) static VNET_DEFINE(int, fw_deny_unknown_exthdrs); @@ -657,21 +657,7 @@ /* Returns -1 on error */ if (lockcheckvnet(chain)) return (IP_FW_PASS); - if (args->rule.slot) { - /* - * Packet has already been tagged as a result of a previous - * match on rule args->rule aka args->rule_id (PIPE, QUEUE, - * REASS, NETGRAPH, DIVERT/TEE...) - * Validate the slot and continue from the next one - * if still present, otherwise do a lookup. - */ - f_pos = (args->rule.chain_id == chain->id) ? - args->rule.slot : - ipfw_find_rule(chain, args->rule.rulenum, - args->rule.rule_id); - } else { - f_pos = 0; - } + getfpos(args, chain, &f_pos); /* * Now scan the rules, and parse microinstructions for each rule. @@ -1139,7 +1125,7 @@ retval = IP_FW_DENY; printf("ipfw: ouch!, skip past end of rules, denying packet\n"); } - IPFW_PF_RUNLOCK(chain); + unlockvnet(chain); #ifdef __FreeBSD__ if (ucred_cache != NULL) crfree(ucred_cache); Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h ============================================================================== --- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h Wed Jul 30 09:17:40 2014 (r271599) +++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h Wed Jul 30 11:05:59 2014 (r271600) @@ -45,6 +45,9 @@ /* This macro needs the calling function to have a tablearg argument */ #define IP_FW_ARG_TABLEARG(a) (((a) == IP_FW_TABLEARG) ? tablearg : (a)) +/* Needed vars defined at ip_fw2.c */ +VNET_DECLARE(int, V_ipfw_vnet_ready); + /* * Auxiliar functions. */ @@ -1937,3 +1940,32 @@ return 0; } +static IPFW_RULES_INLINE void +unlockvnet(struct ip_fw_chain *chain) +{ + IPFW_PF_RUNLOCK(chain); +} + +/* + * Function to be called just after + * lockcheckvnet(); + */ +static IPFW_RULES_INLINE int +getfpos(struct ip_fw_args *args, struct ip_fw_chain *chain, int *f_pos) +{ + if (args->rule.slot) { + /* + * Packet has already been tagged as a result of a previous + * match on rule args->rule aka args->rule_id (PIPE, QUEUE, + * REASS, NETGRAPH, DIVERT/TEE...) + * Validate the slot and continue from the next one + * if still present, otherwise do a lookup. + */ + *f_pos = (args->rule.chain_id == chain->id) ? + args->rule.slot : + ipfw_find_rule(chain, args->rule.rulenum, + args->rule.rule_id); + } else { + *f_pos = 0; + } +} Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc ============================================================================== --- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc Wed Jul 30 09:17:40 2014 (r271599) +++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc Wed Jul 30 11:05:59 2014 (r271600) @@ -48,22 +48,32 @@ int loadStub(std::string funcname) { - return 0; + return (0); + } + + int + setVars() + { + return (0); } }; extern "C" funcptr compile_code(struct ip_fw_args *args) { - jitCompiler("ip_fw_rules.bc"); + struct ip_fw_chain *chain = &V_layer3_chain; - int f_pos = 0; /* index of current rule in the array */ + auto comp = jitCompiler("ip_fw_rules.bc"); - // Now I have to load the stubs of the loaded rules. + // XXX Now I have to load the stubs of the loaded rules. // For that, I need a table: RULE, "functname", #args + lockcheckvnet(chain); // Iterate through the rules. + /* When we're done, or if there's an error. */ + unlockvnet(chain); + /* // Get the stub (prototype) for the cell function F = Mod->getFunction("cell"); @@ -105,5 +115,5 @@ } */ - return 0; + return (0); } From owner-svn-soc-all@FreeBSD.ORG Wed Jul 30 14:25:30 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2A32FB7A for ; Wed, 30 Jul 2014 14:25:30 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 16D4725B1 for ; Wed, 30 Jul 2014 14:25:30 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s6UEPTqZ075472 for ; Wed, 30 Jul 2014 14:25:29 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s6UEPTEF075468 for svn-soc-all@FreeBSD.org; Wed, 30 Jul 2014 14:25:29 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 30 Jul 2014 14:25:29 GMT Message-Id: <201407301425.s6UEPTEF075468@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271602 - soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jul 2014 14:25:30 -0000 Author: dpl Date: Wed Jul 30 14:25:28 2014 New Revision: 271602 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271602 Log: Sorted out how to lock and unlock correctly Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c ============================================================================== --- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c Wed Jul 30 12:39:49 2014 (r271601) +++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c Wed Jul 30 14:25:28 2014 (r271602) @@ -264,12 +264,16 @@ int ipfw_chk(struct ip_fw_args *args) { - if (compiledfuncptr == 0) + if (compiledfuncptr == 0) { + IPFW_PF_RLOCK(chain); + if (! V_ipfw_vnet_ready) { /* shutting down, leave NOW. */ + IPFW_PF_RUNLOCK(chain); + return (IP_FW_PASS); /* accept */ + } compiledfuncptr = compile_code(args); - - if ((int)compiledfuncptr != 0) { + IPFW_PF_RUNLOCK(chain); + } else return compiledfuncptr(); - } /* * Local variables holding state while processing a packet: @@ -654,9 +658,11 @@ args->f_id.dst_port = dst_port = ntohs(dst_port); } - /* Returns -1 on error */ - if (lockcheckvnet(chain)) - return (IP_FW_PASS); + IPFW_PF_RLOCK(chain); + if (! V_ipfw_vnet_ready) { /* shutting down, leave NOW. */ + IPFW_PF_RUNLOCK(chain); + return (IP_FW_PASS); /* accept */ + } getfpos(args, chain, &f_pos); /* @@ -1125,7 +1131,7 @@ retval = IP_FW_DENY; printf("ipfw: ouch!, skip past end of rules, denying packet\n"); } - unlockvnet(chain); + IPFW_PF_RUNLOCK(chain); #ifdef __FreeBSD__ if (ucred_cache != NULL) crfree(ucred_cache); Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h ============================================================================== --- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h Wed Jul 30 12:39:49 2014 (r271601) +++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h Wed Jul 30 14:25:28 2014 (r271602) @@ -1926,27 +1926,6 @@ } /* - * From here on, there's ip_fw2 code, so that - * we can add this to our jit compiled code. - */ -static IPFW_RULES_INLINE int -lockcheckvnet(struct ip_fw_chain *chain) -{ - IPFW_PF_RLOCK(chain); - if (! V_ipfw_vnet_ready) { /* shutting down, leave NOW. */ - IPFW_PF_RUNLOCK(chain); - return (-1); /* accept */ - } - return 0; -} - -static IPFW_RULES_INLINE void -unlockvnet(struct ip_fw_chain *chain) -{ - IPFW_PF_RUNLOCK(chain); -} - -/* * Function to be called just after * lockcheckvnet(); */ @@ -1968,4 +1947,5 @@ } else { *f_pos = 0; } + return (*f_pos); } Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc ============================================================================== --- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc Wed Jul 30 12:39:49 2014 (r271601) +++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc Wed Jul 30 14:25:28 2014 (r271602) @@ -14,9 +14,9 @@ #include #include "ip_fw_private.h" -#include "ip_fw_private.h" typedef int (*funcptr)(); + using namespace llvm; class jitCompiler { @@ -67,13 +67,8 @@ // XXX Now I have to load the stubs of the loaded rules. // For that, I need a table: RULE, "functname", #args - lockcheckvnet(chain); - // Iterate through the rules. - /* When we're done, or if there's an error. */ - unlockvnet(chain); - /* // Get the stub (prototype) for the cell function F = Mod->getFunction("cell"); From owner-svn-soc-all@FreeBSD.ORG Wed Jul 30 15:58:44 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 48091374 for ; Wed, 30 Jul 2014 15:58:44 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1B9E021AD for ; Wed, 30 Jul 2014 15:58:44 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s6UFwhAr035675 for ; Wed, 30 Jul 2014 15:58:43 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s6UFwh4M035657 for svn-soc-all@FreeBSD.org; Wed, 30 Jul 2014 15:58:43 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 30 Jul 2014 15:58:43 GMT Message-Id: <201407301558.s6UFwh4M035657@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271606 - soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jul 2014 15:58:44 -0000 Author: dpl Date: Wed Jul 30 15:58:42 2014 New Revision: 271606 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271606 Log: Removed unneeded rule. Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c ============================================================================== --- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c Wed Jul 30 14:52:26 2014 (r271605) +++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c Wed Jul 30 15:58:42 2014 (r271606) @@ -663,7 +663,21 @@ IPFW_PF_RUNLOCK(chain); return (IP_FW_PASS); /* accept */ } - getfpos(args, chain, &f_pos); + if (args->rule.slot) { + /* + * Packet has already been tagged as a result of a previous + * match on rule args->rule aka args->rule_id (PIPE, QUEUE, + * REASS, NETGRAPH, DIVERT/TEE...) + * Validate the slot and continue from the next one + * if still present, otherwise do a lookup. + */ + f_pos = (args->rule.chain_id == chain->id) ? + args->rule.slot : + ipfw_find_rule(chain, args->rule.rulenum, + args->rule.rule_id); + } else { + f_pos = 0; + } /* * Now scan the rules, and parse microinstructions for each rule. Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h ============================================================================== --- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h Wed Jul 30 14:52:26 2014 (r271605) +++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h Wed Jul 30 15:58:42 2014 (r271606) @@ -1924,28 +1924,3 @@ } *done = 1; /* exit outer loop */ } - -/* - * Function to be called just after - * lockcheckvnet(); - */ -static IPFW_RULES_INLINE int -getfpos(struct ip_fw_args *args, struct ip_fw_chain *chain, int *f_pos) -{ - if (args->rule.slot) { - /* - * Packet has already been tagged as a result of a previous - * match on rule args->rule aka args->rule_id (PIPE, QUEUE, - * REASS, NETGRAPH, DIVERT/TEE...) - * Validate the slot and continue from the next one - * if still present, otherwise do a lookup. - */ - *f_pos = (args->rule.chain_id == chain->id) ? - args->rule.slot : - ipfw_find_rule(chain, args->rule.rulenum, - args->rule.rule_id); - } else { - *f_pos = 0; - } - return (*f_pos); -} From owner-svn-soc-all@FreeBSD.ORG Wed Jul 30 16:06:47 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E64BB4A8 for ; Wed, 30 Jul 2014 16:06:47 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D27F62282 for ; Wed, 30 Jul 2014 16:06:47 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s6UG6l7F053322 for ; Wed, 30 Jul 2014 16:06:47 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s6UG6lig053320 for svn-soc-all@FreeBSD.org; Wed, 30 Jul 2014 16:06:47 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 30 Jul 2014 16:06:47 GMT Message-Id: <201407301606.s6UG6lig053320@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271610 - soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jul 2014 16:06:48 -0000 Author: dpl Date: Wed Jul 30 16:06:47 2014 New Revision: 271610 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271610 Log: Added the loop, to be refined, to iterate through the ruleset in order to get the rules to be compiled. Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc ============================================================================== --- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc Wed Jul 30 15:43:17 2014 (r271609) +++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc Wed Jul 30 16:06:47 2014 (r271610) @@ -17,6 +17,11 @@ typedef int (*funcptr)(); +extern "C" { +VNET_DECLARE(struct ip_fw_chain, layer3_chain); +#define V_layer3_chain VNET(layer3_chain) +} + using namespace llvm; class jitCompiler { @@ -68,6 +73,463 @@ // XXX Now I have to load the stubs of the loaded rules. // For that, I need a table: RULE, "functname", #args // Iterate through the rules. + if (args->rule.slot) { + /* + * Packet has already been tagged as a result of a previous + * match on rule args->rule aka args->rule_id (PIPE, QUEUE, + * REASS, NETGRAPH, DIVERT/TEE...) + * Validate the slot and continue from the next one + * if still present, otherwise do a lookup. + */ + f_pos = (args->rule.chain_id == chain->id) ? + args->rule.slot : + ipfw_find_rule(chain, args->rule.rulenum, + args->rule.rule_id); + } else { + f_pos = 0; + } + + // Iterate through the rules. + for (; f_pos < chain->n_rules; f_pos++) { + ipfw_insn *cmd; + uint32_t tablearg = 0; + int l, cmdlen, skip_or; /* skip rest of OR block */ + struct ip_fw *f; + + f = chain->map[f_pos]; + if (V_set_disable & (1 << f->set) ) + continue; + + skip_or = 0; + for (l = f->cmd_len, cmd = f->cmd ; l > 0 ; + l -= cmdlen, cmd += cmdlen) { + int match; + /* + * check_body is a jump target used when we find a + * CHECK_STATE, and need to jump to the body of + * the target rule. + */ + +/* check_body: */ + cmdlen = F_LEN(cmd); + /* + * An OR block (insn_1 || .. || insn_n) has the + * F_OR bit set in all but the last instruction. + * The first match will set "skip_or", and cause + * the following instructions to be skipped until + * past the one with the F_OR bit clear. + */ + if (skip_or) { /* skip this instruction */ + if ((cmd->len & F_OR) == 0) + skip_or = 0; /* next one is good */ + continue; + } + match = 0; /* set to 1 if we succeed */ + + switch (cmd->opcode) { + case O_NOP: + rule_nop(&match); + break; + + case O_FORWARD_MAC: + rule_forward_mac(cmd->opcode); + break; + + case O_GID: + case O_UID: + case O_JAIL: + rule_jail(&match, offset, proto, cmd, args, ucred_lookup, ucred_cache); + break; + + case O_RECV: + rule_recv(&match, cmd, m, chain, &tablearg); + break; + + case O_XMIT: + rule_xmit(&match, oif, cmd, chain, &tablearg); + break; + + case O_VIA: + rule_via(&match, oif, m, cmd, chain, &tablearg); + break; + + case O_MACADDR2: + rule_macaddr2(&match, args, cmd); + break; + + case O_MAC_TYPE: + rule_mac_type(&match, args, cmd, cmdlen, etype); + break; + + case O_FRAG: + rule_frag(&match, offset); + break; + + case O_IN: + rule_in(&match, oif); + break; + + case O_LAYER2: + rule_layer2(&match, args); + break; + + case O_DIVERTED: + rule_diverted(&match, args, cmd); + break; + + case O_PROTO: + rule_proto(&match, proto, cmd); + break; + + case O_IP_SRC: + rule_ip_src(&match, is_ipv4, cmd, &src_ip); + break; + + case O_IP_SRC_LOOKUP: + case O_IP_DST_LOOKUP: + rule_ip_dst_lookup(&match, cmd, cmdlen, args, &tablearg, is_ipv4, is_ipv6, ip, &dst_ip, &src_ip, dst_port, src_port, offset, proto, ucred_lookup, ucred_cache, chain); + break; + + case O_IP_SRC_MASK: + case O_IP_DST_MASK: + rule_ip_dst_mask(&match, is_ipv4, cmd, cmdlen, &dst_ip, &src_ip); + break; + + case O_IP_SRC_ME: + rule_ip_src_me(&match, is_ipv4, is_ipv6, &src_ip, args); +#ifdef INET6 + /* FALLTHROUGH */ + case O_IP6_SRC_ME: + rule_ip6_src_me(&match, is_ipv6, args); +#endif + break; + + case O_IP_DST_SET: + case O_IP_SRC_SET: + rule_ip_src_set(&match, is_ipv4, cmd, args); + break; + + case O_IP_DST: + rule_ip_dst(&match, is_ipv4, cmd, &dst_ip); + break; + + case O_IP_DST_ME: + rule_ip_dst_me(&match, args, is_ipv4, is_ipv6, &dst_ip); + +#ifdef INET6 + /* FALLTHROUGH */ + case O_IP6_DST_ME: + rule_ip6_dst_me(&match, args, is_ipv6); +#endif + break; + + + case O_IP_SRCPORT: + case O_IP_DSTPORT: + rule_ip_dstport(&match, proto, offset, cmd, cmdlen, dst_port, src_port); + break; + + case O_ICMPTYPE: + rule_icmptype(&match, offset, proto, ulp, cmd); + break; + +#ifdef INET6 + case O_ICMP6TYPE: + rule_icmp6type(&match, offset, is_ipv6, proto, ulp, cmd); + break; +#endif /* INET6 */ + + case O_IPOPT: + rule_ipopt(&match, is_ipv4, ip, cmd); + break; + + case O_IPVER: + rule_ipver(&match, is_ipv4, cmd, ip); + break; + + case O_IPID: + case O_IPLEN: + case O_IPTTL: + rule_ipttl(&match, is_ipv4, cmd, cmdlen, ip, iplen); + break; + + case O_IPPRECEDENCE: + rule_ipprecedence(&match, is_ipv4, cmd, ip); + break; + + case O_IPTOS: + rule_iptos(&match, is_ipv4, cmd, ip); + break; + + case O_DSCP: + rule_dscp(&match, is_ipv4, is_ipv6, cmd, ip); + break; + + case O_TCPDATALEN: + rule_tcpdatalen(&match, proto, offset, ulp, iplen, cmdlen, cmd, ip); + break; + + case O_TCPFLAGS: + rule_tcpflags(&match, proto, offset, cmd, ulp); + break; + + case O_TCPOPTS: + if (rule_tcpopts(&match, hlen, ulp, proto, offset, cmd, m, args)) + goto pullup_failed; + break; + + case O_TCPSEQ: + rule_tcpseq(&match, proto, offset, cmd, ulp); + break; + + case O_TCPACK: + rule_tcpack(&match, proto, offset, cmd, ulp); + break; + + case O_TCPWIN: + rule_tcpwin(&match, proto, offset, cmd, cmdlen, ulp); + break; + + case O_ESTAB: + rule_estab(&match, proto, offset, ulp); + break; + + case O_ALTQ: + rule_altq(&match, cmd, m, ip); + break; + + case O_LOG: + rule_log(&match, f, hlen, args, m, oif, offset, ip6f_mf, tablearg, ip); + break; + + case O_PROB: + rule_prob(&match, cmd); + break; + + case O_VERREVPATH: + rule_verrevpath(&match, oif, m, is_ipv6, args, &src_ip); + break; + + case O_VERSRCREACH: + rule_versrcreach(&match, hlen, oif, is_ipv6, args, &src_ip); + break; + + case O_ANTISPOOF: + rule_antispoof(&match, oif, hlen, is_ipv4, is_ipv6, &src_ip, args, m); + break; + + case O_IPSEC: +#ifdef IPSEC + rule_ipsec(&match, m); +#endif + /* otherwise no match */ + break; + +#ifdef INET6 + case O_IP6_SRC: + rule_ip6_src(&match, is_ipv6, args, cmd); + break; + + case O_IP6_DST: + rule_ip6_dst(&match, is_ipv6, args, cmd); + break; + + case O_IP6_SRC_MASK: + case O_IP6_DST_MASK: + rule_ip6_dst_mask(&match, args, cmd, cmdlen, is_ipv6); + break; + + case O_FLOW6ID: + rule_flow6id(&match, is_ipv6, args, cmd); + break; + + case O_EXT_HDR: + rule_ext_hdr(&match, is_ipv6, ext_hd, cmd); + break; + + case O_IP6: + rule_ip6(&match, is_ipv6); + break; +#endif + + case O_IP4: + rule_ip4(&match, is_ipv4); + break; + + case O_TAG: + rule_tag(&match, cmd, m, tablearg); + break; + + case O_FIB: /* try match the specified fib */ + rule_fib(&match, args, cmd); + break; + + case O_SOCKARG: + rule_sockarg(&match, is_ipv6, proto, &dst_ip, &src_ip, dst_port, src_port, args, &tablearg); + break; + + case O_TAGGED: + rule_tagged(&match, cmd, cmdlen, m, tablearg); + break; + + /* + * The second set of opcodes represents 'actions', + * i.e. the terminal part of a rule once the packet + * matches all previous patterns. + * Typically there is only one action for each rule, + * and the opcode is stored at the end of the rule + * (but there are exceptions -- see below). + * + * In general, here we set retval and terminate the + * outer loop (would be a 'break 3' in some language, + * but we need to set l=0, done=1) + * + * Exceptions: + * O_COUNT and O_SKIPTO actions: + * instead of terminating, we jump to the next rule + * (setting l=0), or to the SKIPTO target (setting + * f/f_len, cmd and l as needed), respectively. + * + * O_TAG, O_LOG and O_ALTQ action parameters: + * perform some action and set match = 1; + * + * O_LIMIT and O_KEEP_STATE: these opcodes are + * not real 'actions', and are stored right + * before the 'action' part of the rule. + * These opcodes try to install an entry in the + * state tables; if successful, we continue with + * the next opcode (match=1; break;), otherwise + * the packet must be dropped (set retval, + * break loops with l=0, done=1) + * + * O_PROBE_STATE and O_CHECK_STATE: these opcodes + * cause a lookup of the state table, and a jump + * to the 'action' part of the parent rule + * if an entry is found, or + * (CHECK_STATE only) a jump to the next rule if + * the entry is not found. + * The result of the lookup is cached so that + * further instances of these opcodes become NOPs. + * The jump to the next rule is done by setting + * l=0, cmdlen=0. + */ + case O_LIMIT: + case O_KEEP_STATE: + rule_keep_state(&match, f, cmd, args, tablearg, &retval, &l, &done); + break; + + case O_PROBE_STATE: + case O_CHECK_STATE: + rule_check_state(&match, &dyn_dir, q, args, proto, ulp, pktlen, f, &f_pos, chain, cmd, &cmdlen, &l); + break; + + case O_ACCEPT: + rule_accept(&retval, &l, &done); + break; + + case O_PIPE: + case O_QUEUE: + rule_queue(args, f_pos, chain, cmd, tablearg, &retval, &l, &done); + break; + + case O_DIVERT: + case O_TEE: + rule_tee(&l, &done, &retval, cmd, args, f_pos, tablearg, chain); + break; + + case O_COUNT: + rule_count(&l, f, pktlen); + break; + + case O_SKIPTO: + rule_skipto(&match, &l, cmd, &cmdlen, &skip_or, &f_pos, f, pktlen, chain, tablearg); + continue; + break; /* NOTREACHED */ + + case O_CALLRETURN: + rule_callreturn(cmd, m, f, chain, tablearg, pktlen, &skip_or, &cmdlen, &f_pos, &l); + continue; + break; /* NOTREACHED */ + + case O_REJECT: + rule_reject(hlen, is_ipv4, offset, proto, ulp, m, &dst_ip, args, cmd, iplen, ip); + /* FALLTHROUGH */ +#ifdef INET6 + case O_UNREACH6: + rule_unreach6(hlen, is_ipv6, offset, proto, icmp6_type, m, args, cmd, ip); + /* FALLTHROUGH */ +#endif + case O_DENY: + rule_deny(&l, &done, &retval); + break; + + case O_FORWARD_IP: + rule_forward_ip(args, q, f, dyn_dir, cmd, tablearg, &retval, &l, &done); + break; + +#ifdef INET6 + case O_FORWARD_IP6: + rule_forward_ip6(args, q, f, dyn_dir, cmd, &retval, &l, &done); + break; +#endif + + case O_NETGRAPH: + case O_NGTEE: + rule_ngtee(args, f_pos, chain, cmd, tablearg, &retval, &l, &done); + break; + + case O_SETFIB: + rule_setfib(f, pktlen, tablearg, cmd, m, args, &l); + break; + + case O_SETDSCP: + rule_setdscp(cmd, ip, is_ipv4, is_ipv6, tablearg, f, pktlen, &l); + break; + + case O_NAT: + rule_nat(args, f_pos, chain, cmd, m, tablearg, &retval, &done, &l); + break; + + case O_REASS: + rule_reass(f, f_pos, chain, pktlen, ip, args, m, &retval, &done, &l); + break; + + default: + panic("-- unknown opcode %d\n", cmd->opcode); + } /* end of switch() on opcodes */ + /* + * if we get here with l=0, then match is irrelevant. + */ + + if (cmd->len & F_NOT) + match = !match; + + if (match) { + if (cmd->len & F_OR) + skip_or = 1; + } else { + if (!(cmd->len & F_OR)) /* not an OR block, */ + break; /* try next rule */ + } + + } /* end of inner loop, scan opcodes */ +#undef PULLUP_LEN + + if (done) + break; + +/* next_rule:; */ /* try next rule */ + + } /* end of outer for, scan rules */ + + if (done) { + struct ip_fw *rule = chain->map[f_pos]; + /* Update statistics */ + IPFW_INC_RULE_COUNTER(rule, pktlen); + } else { + retval = IP_FW_DENY; + printf("ipfw: ouch!, skip past end of rules, denying packet\n"); + } /* // Get the stub (prototype) for the cell function From owner-svn-soc-all@FreeBSD.ORG Wed Jul 30 17:40:56 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2268850C for ; Wed, 30 Jul 2014 17:40:56 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 059192E85 for ; Wed, 30 Jul 2014 17:40:56 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s6UHetbC091019 for ; Wed, 30 Jul 2014 17:40:55 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s6UHetSg091014 for svn-soc-all@FreeBSD.org; Wed, 30 Jul 2014 17:40:55 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 30 Jul 2014 17:40:55 GMT Message-Id: <201407301740.s6UHetSg091014@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271612 - soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jul 2014 17:40:56 -0000 Author: dpl Date: Wed Jul 30 17:40:55 2014 New Revision: 271612 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271612 Log: Substitute function calls for stub loading. Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc ============================================================================== --- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc Wed Jul 30 16:08:16 2014 (r271611) +++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc Wed Jul 30 17:40:55 2014 (r271612) @@ -53,6 +53,48 @@ int loadStub(std::string funcname) { + /* + // Get the stub (prototype) for the cell function + F = Mod->getFunction("cell"); + // Set it to have private linkage, so that it can be removed after being + // inlined. + F->setLinkage(GlobalValue::PrivateLinkage); + + // Add an entry basic block to this function and set it + BasicBlock *entry = BasicBlock::Create(C, "entry", F); + B.SetInsertPoint(entry); + // Cache the type of registers + regTy = Type::getInt16Ty(C); + + // Collect the function parameters + auto args = F->arg_begin(); + oldGrid = args++; + newGrid = args++; + width = args++; + height = args++; + x = args++; + y = args++; + + // Create space on the stack for the local registers + for (int i=0 ; i<10 ; i++) + { + a[i] = B.CreateAlloca(regTy); + } + + // Create a space on the stack for the current value. This can be + // assigned to, and will be returned at the end. Store the value passed + // as a parameter in this. + v = B.CreateAlloca(regTy); + B.CreateStore(args++, v); + + // Create a load of pointers to the global registers. + Value *gArg = args; + for (int i=0 ; i<10 ; i++) + { + B.CreateStore(ConstantInt::get(regTy, 0), a[i]); + g[i] = B.CreateConstGEP1_32(gArg, i); + } + */ return (0); } @@ -128,248 +170,247 @@ switch (cmd->opcode) { case O_NOP: - rule_nop(&match); + comp.loadStub("nop"); break; case O_FORWARD_MAC: - rule_forward_mac(cmd->opcode); + comp.loadStub("forward_mac"); break; case O_GID: case O_UID: case O_JAIL: - rule_jail(&match, offset, proto, cmd, args, ucred_lookup, ucred_cache); + comp.loadStub("jail"); break; case O_RECV: - rule_recv(&match, cmd, m, chain, &tablearg); + comp.loadStub("recv"); break; case O_XMIT: - rule_xmit(&match, oif, cmd, chain, &tablearg); + comp.loadStub("xmit"); break; case O_VIA: - rule_via(&match, oif, m, cmd, chain, &tablearg); + comp.loadStub("via"); break; case O_MACADDR2: - rule_macaddr2(&match, args, cmd); + comp.loadStub("macaddr2"); break; case O_MAC_TYPE: - rule_mac_type(&match, args, cmd, cmdlen, etype); + comp.loadStub("mac_type"); break; case O_FRAG: - rule_frag(&match, offset); + comp.loadStub("frag"); break; case O_IN: - rule_in(&match, oif); + comp.loadStub("in"); break; case O_LAYER2: - rule_layer2(&match, args); + comp.loadStub("layer2"); break; case O_DIVERTED: - rule_diverted(&match, args, cmd); + comp.loadStub("diverted"); break; case O_PROTO: - rule_proto(&match, proto, cmd); + comp.loadStub("proto"); break; case O_IP_SRC: - rule_ip_src(&match, is_ipv4, cmd, &src_ip); + comp.loadStub("ip_src"); break; case O_IP_SRC_LOOKUP: case O_IP_DST_LOOKUP: - rule_ip_dst_lookup(&match, cmd, cmdlen, args, &tablearg, is_ipv4, is_ipv6, ip, &dst_ip, &src_ip, dst_port, src_port, offset, proto, ucred_lookup, ucred_cache, chain); + comp.loadStub("ip_dst_lookup"); break; case O_IP_SRC_MASK: case O_IP_DST_MASK: - rule_ip_dst_mask(&match, is_ipv4, cmd, cmdlen, &dst_ip, &src_ip); + comp.loadStub("ip_dst_mask"); break; case O_IP_SRC_ME: - rule_ip_src_me(&match, is_ipv4, is_ipv6, &src_ip, args); + comp.loadStub("ip_src_me"); #ifdef INET6 /* FALLTHROUGH */ case O_IP6_SRC_ME: - rule_ip6_src_me(&match, is_ipv6, args); + comp.loadStub("ip6_src_me"); #endif break; case O_IP_DST_SET: case O_IP_SRC_SET: - rule_ip_src_set(&match, is_ipv4, cmd, args); + comp.loadStub("ip_src_set"); break; case O_IP_DST: - rule_ip_dst(&match, is_ipv4, cmd, &dst_ip); + comp.loadStub("ip_dst"); break; case O_IP_DST_ME: - rule_ip_dst_me(&match, args, is_ipv4, is_ipv6, &dst_ip); + comp.loadStub("ip_dst_me"); #ifdef INET6 /* FALLTHROUGH */ case O_IP6_DST_ME: - rule_ip6_dst_me(&match, args, is_ipv6); + comp.loadStub("ip6_dst_me"); #endif break; case O_IP_SRCPORT: case O_IP_DSTPORT: - rule_ip_dstport(&match, proto, offset, cmd, cmdlen, dst_port, src_port); + comp.loadStub("ip_dstport"); break; case O_ICMPTYPE: - rule_icmptype(&match, offset, proto, ulp, cmd); + comp.loadStub("icmptype"); break; #ifdef INET6 case O_ICMP6TYPE: - rule_icmp6type(&match, offset, is_ipv6, proto, ulp, cmd); + comp.loadStub("icmp6type"); break; #endif /* INET6 */ case O_IPOPT: - rule_ipopt(&match, is_ipv4, ip, cmd); + comp.loadStub("ipopt"); break; case O_IPVER: - rule_ipver(&match, is_ipv4, cmd, ip); + comp.loadStub("ipver"); break; case O_IPID: case O_IPLEN: case O_IPTTL: - rule_ipttl(&match, is_ipv4, cmd, cmdlen, ip, iplen); + comp.loadStub("ipttl"); break; case O_IPPRECEDENCE: - rule_ipprecedence(&match, is_ipv4, cmd, ip); + comp.loadStub("ipprecedence"); break; case O_IPTOS: - rule_iptos(&match, is_ipv4, cmd, ip); + comp.loadStub("iptos"); break; case O_DSCP: - rule_dscp(&match, is_ipv4, is_ipv6, cmd, ip); + comp.loadStub("dscp"); break; case O_TCPDATALEN: - rule_tcpdatalen(&match, proto, offset, ulp, iplen, cmdlen, cmd, ip); + comp.loadStub("tcpdatalen"); break; case O_TCPFLAGS: - rule_tcpflags(&match, proto, offset, cmd, ulp); + comp.loadStub("tcpflags"); break; case O_TCPOPTS: - if (rule_tcpopts(&match, hlen, ulp, proto, offset, cmd, m, args)) - goto pullup_failed; + comp.loadStub("tcpopts"); break; case O_TCPSEQ: - rule_tcpseq(&match, proto, offset, cmd, ulp); + comp.loadStub("tcpseq"); break; case O_TCPACK: - rule_tcpack(&match, proto, offset, cmd, ulp); + comp.loadStub("tcpack"); break; case O_TCPWIN: - rule_tcpwin(&match, proto, offset, cmd, cmdlen, ulp); + comp.loadStub("tcpwin"); break; case O_ESTAB: - rule_estab(&match, proto, offset, ulp); + comp.loadStub("estab"); break; case O_ALTQ: - rule_altq(&match, cmd, m, ip); + comp.loadStub("altq"); break; case O_LOG: - rule_log(&match, f, hlen, args, m, oif, offset, ip6f_mf, tablearg, ip); + comp.loadStub("log"); break; case O_PROB: - rule_prob(&match, cmd); + comp.loadStub("prob"); break; case O_VERREVPATH: - rule_verrevpath(&match, oif, m, is_ipv6, args, &src_ip); + comp.loadStub("verrevpath"); break; case O_VERSRCREACH: - rule_versrcreach(&match, hlen, oif, is_ipv6, args, &src_ip); + comp.loadStub("versrcreach"); break; case O_ANTISPOOF: - rule_antispoof(&match, oif, hlen, is_ipv4, is_ipv6, &src_ip, args, m); + comp.loadStub("antispoof"); break; case O_IPSEC: #ifdef IPSEC - rule_ipsec(&match, m); + comp.loadStub("ipsec"); #endif /* otherwise no match */ break; #ifdef INET6 case O_IP6_SRC: - rule_ip6_src(&match, is_ipv6, args, cmd); + comp.loadStub("ip6_src"); break; case O_IP6_DST: - rule_ip6_dst(&match, is_ipv6, args, cmd); + comp.loadStub("ip6_dst"); break; case O_IP6_SRC_MASK: case O_IP6_DST_MASK: - rule_ip6_dst_mask(&match, args, cmd, cmdlen, is_ipv6); + comp.loadStub("ip6_dst_mask"); break; case O_FLOW6ID: - rule_flow6id(&match, is_ipv6, args, cmd); + comp.loadStub("flow6id"); break; case O_EXT_HDR: - rule_ext_hdr(&match, is_ipv6, ext_hd, cmd); + comp.loadStub("ext_hdr"); break; case O_IP6: - rule_ip6(&match, is_ipv6); + comp.loadStub("ip6"); break; #endif case O_IP4: - rule_ip4(&match, is_ipv4); + comp.loadStub("ip4"); break; case O_TAG: - rule_tag(&match, cmd, m, tablearg); + comp.loadStub("tag"); break; case O_FIB: /* try match the specified fib */ - rule_fib(&match, args, cmd); + comp.loadStub("fib"); break; case O_SOCKARG: - rule_sockarg(&match, is_ipv6, proto, &dst_ip, &src_ip, dst_port, src_port, args, &tablearg); + comp.loadStub("sockarg"); break; case O_TAGGED: - rule_tagged(&match, cmd, cmdlen, m, tablearg); + comp.loadStub("tagged"); break; /* @@ -415,83 +456,83 @@ */ case O_LIMIT: case O_KEEP_STATE: - rule_keep_state(&match, f, cmd, args, tablearg, &retval, &l, &done); + comp.loadStub("keep_state"); break; case O_PROBE_STATE: case O_CHECK_STATE: - rule_check_state(&match, &dyn_dir, q, args, proto, ulp, pktlen, f, &f_pos, chain, cmd, &cmdlen, &l); + comp.loadStub("check_state"); break; case O_ACCEPT: - rule_accept(&retval, &l, &done); + comp.loadStub("accept"); break; case O_PIPE: case O_QUEUE: - rule_queue(args, f_pos, chain, cmd, tablearg, &retval, &l, &done); + comp.loadStub("queue"); break; case O_DIVERT: case O_TEE: - rule_tee(&l, &done, &retval, cmd, args, f_pos, tablearg, chain); + comp.loadStub("tee"); break; case O_COUNT: - rule_count(&l, f, pktlen); + comp.loadStub("count"); break; case O_SKIPTO: - rule_skipto(&match, &l, cmd, &cmdlen, &skip_or, &f_pos, f, pktlen, chain, tablearg); + comp.loadStub("skipto"); continue; break; /* NOTREACHED */ case O_CALLRETURN: - rule_callreturn(cmd, m, f, chain, tablearg, pktlen, &skip_or, &cmdlen, &f_pos, &l); + comp.loadStub("callreturn"); continue; break; /* NOTREACHED */ case O_REJECT: - rule_reject(hlen, is_ipv4, offset, proto, ulp, m, &dst_ip, args, cmd, iplen, ip); + comp.loadStub("reject"); /* FALLTHROUGH */ #ifdef INET6 case O_UNREACH6: - rule_unreach6(hlen, is_ipv6, offset, proto, icmp6_type, m, args, cmd, ip); + comp.loadStub("unreach6"); /* FALLTHROUGH */ #endif case O_DENY: - rule_deny(&l, &done, &retval); + comp.loadStub("deny"); break; case O_FORWARD_IP: - rule_forward_ip(args, q, f, dyn_dir, cmd, tablearg, &retval, &l, &done); + comp.loadStub("forward_ip"); break; #ifdef INET6 case O_FORWARD_IP6: - rule_forward_ip6(args, q, f, dyn_dir, cmd, &retval, &l, &done); + comp.loadStub("forward_ip6"); break; #endif case O_NETGRAPH: case O_NGTEE: - rule_ngtee(args, f_pos, chain, cmd, tablearg, &retval, &l, &done); + comp.loadStub("ngtee"); break; case O_SETFIB: - rule_setfib(f, pktlen, tablearg, cmd, m, args, &l); + comp.loadStub("setfib"); break; case O_SETDSCP: - rule_setdscp(cmd, ip, is_ipv4, is_ipv6, tablearg, f, pktlen, &l); + comp.loadStub("setdscp"); break; case O_NAT: - rule_nat(args, f_pos, chain, cmd, m, tablearg, &retval, &done, &l); + comp.loadStub("nat"); break; case O_REASS: - rule_reass(f, f_pos, chain, pktlen, ip, args, m, &retval, &done, &l); + comp.loadStub("reass"); break; default: @@ -513,7 +554,6 @@ } } /* end of inner loop, scan opcodes */ -#undef PULLUP_LEN if (done) break; @@ -531,46 +571,5 @@ printf("ipfw: ouch!, skip past end of rules, denying packet\n"); } - /* - // Get the stub (prototype) for the cell function - F = Mod->getFunction("cell"); - // Set it to have private linkage, so that it can be removed after being - // inlined. - F->setLinkage(GlobalValue::PrivateLinkage); - // Add an entry basic block to this function and set it - BasicBlock *entry = BasicBlock::Create(C, "entry", F); - B.SetInsertPoint(entry); - // Cache the type of registers - regTy = Type::getInt16Ty(C); - - // Collect the function parameters - auto args = F->arg_begin(); - oldGrid = args++; - newGrid = args++; - width = args++; - height = args++; - x = args++; - y = args++; - - // Create space on the stack for the local registers - for (int i=0 ; i<10 ; i++) - { - a[i] = B.CreateAlloca(regTy); - } - // Create a space on the stack for the current value. This can be - // assigned to, and will be returned at the end. Store the value passed - // as a parameter in this. - v = B.CreateAlloca(regTy); - B.CreateStore(args++, v); - - // Create a load of pointers to the global registers. - Value *gArg = args; - for (int i=0 ; i<10 ; i++) - { - B.CreateStore(ConstantInt::get(regTy, 0), a[i]); - g[i] = B.CreateConstGEP1_32(gArg, i); - } - - */ return (0); } From owner-svn-soc-all@FreeBSD.ORG Wed Jul 30 17:42:15 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4DEC062C for ; Wed, 30 Jul 2014 17:42:15 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3B6AD2E9D for ; Wed, 30 Jul 2014 17:42:15 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s6UHgF3s095591 for ; Wed, 30 Jul 2014 17:42:15 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s6UHgE4P095589 for svn-soc-all@FreeBSD.org; Wed, 30 Jul 2014 17:42:14 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 30 Jul 2014 17:42:14 GMT Message-Id: <201407301742.s6UHgE4P095589@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271613 - soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jul 2014 17:42:15 -0000 Author: dpl Date: Wed Jul 30 17:42:14 2014 New Revision: 271613 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271613 Log: Deleted unneeded variable for loop. Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc ============================================================================== --- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc Wed Jul 30 17:40:55 2014 (r271612) +++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc Wed Jul 30 17:42:14 2014 (r271613) @@ -86,8 +86,7 @@ // as a parameter in this. v = B.CreateAlloca(regTy); B.CreateStore(args++, v); - - // Create a load of pointers to the global registers. +// Create a load of pointers to the global registers. Value *gArg = args; for (int i=0 ; i<10 ; i++) { @@ -134,7 +133,6 @@ // Iterate through the rules. for (; f_pos < chain->n_rules; f_pos++) { ipfw_insn *cmd; - uint32_t tablearg = 0; int l, cmdlen, skip_or; /* skip rest of OR block */ struct ip_fw *f; From owner-svn-soc-all@FreeBSD.ORG Wed Jul 30 19:50:58 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 01DDC6B6 for ; Wed, 30 Jul 2014 19:50:58 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E14972C62 for ; Wed, 30 Jul 2014 19:50:57 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s6UJovVJ023447 for ; Wed, 30 Jul 2014 19:50:57 GMT (envelope-from pedrosouza@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s6UJovS1023444 for svn-soc-all@FreeBSD.org; Wed, 30 Jul 2014 19:50:57 GMT (envelope-from pedrosouza@FreeBSD.org) Date: Wed, 30 Jul 2014 19:50:57 GMT Message-Id: <201407301950.s6UJovS1023444@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to pedrosouza@FreeBSD.org using -f From: pedrosouza@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271623 - soc2014/pedrosouza/lua_loader/head/sys/boot/lua MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jul 2014 19:50:58 -0000 Author: pedrosouza Date: Wed Jul 30 19:50:56 2014 New Revision: 271623 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271623 Log: Added boot menu shortcuts Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua ============================================================================== --- soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua Wed Jul 30 18:47:31 2014 (r271622) +++ soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua Wed Jul 30 19:50:56 2014 (r271623) @@ -8,13 +8,16 @@ screen.setcursor(x, y); print("Boot Menu"); for k, v in pairs(opts) do - screen.setcursor(x, y + v.index); - local name = v.name; - - if (name == nil) then - name = v.getName(); + -- skip alias + if k ~= "alias" then + screen.setcursor(x, y + v.index); + local name = v.name; + + if (name == nil) then + name = v.getName(); + end + print(k .. " - " .. name); end - print(k .. " - " .. name); end end @@ -29,6 +32,7 @@ menu.drawbox(4, 10, 40, 10); drawer.drawbrand(); drawer.drawlogo(); + screen.defcursor(); local ch = string.char(io.getchar()); if (opts[ch] ~= nil) then local ret = opts[ch].func(); @@ -36,6 +40,17 @@ print("Exiting menu!\n"); return; end + else + --try alias key + if opts.alias ~= nil then + if opts.alias[ch] ~= nil then + local ret = opts.alias[ch].func(); + if (ret) then + print("Exiting menu!\n"); + return; + end + end + end end end end @@ -65,26 +80,39 @@ end menu.options = { - ["1"] = {index = 1, name = "Boot Multi user", func = function () core.setSingleUser(false); loader.perform("boot"); end}, - ["2"] = {index = 2, name = "Boot Single user", func = function () core.setSingleUser(true); loader.perform("boot"); end}, - ["3"] = {index = 3, name = "Escape to lua interpreter", func = function () return true; end}, - ["4"] = {index = 4, name = "Reboot", func = function () loader.perform("reboot"); end}, - ["5"] = {index = 5, name = "Boot Options", func = function () menu.run(boot_options); return false; end} + -- Boot multi user + ["1"] = {index = 1, name = color.highlight("B").."oot Multi user", func = function () core.setSingleUser(false); loader.perform("boot"); end}, + -- boot single user + ["2"] = {index = 2, name = "Boot "..color.highlight("S").."ingle user", func = function () core.setSingleUser(true); loader.perform("boot"); end}, + -- escape to interpreter + ["3"] = {index = 3, name = color.highlight("E").."scape to lua interpreter", func = function () return true; end}, + -- reboot + ["4"] = {index = 4, name = color.highlight("R").."eboot", func = function () loader.perform("reboot"); end}, + -- boot options + ["5"] = {index = 5, name = "Boot "..color.highlight("O").."ptions", func = function () menu.run(boot_options); return false; end} +}; + +menu.options.alias = { + ["b"] = menu.options["1"], + ["s"] = menu.options["2"], + ["e"] = menu.options["3"], + ["r"] = menu.options["4"], + ["o"] = menu.options["5"] }; function OnOff(str, b) if (b) then - return str .. color.escapef(color.GREEN)..": On"..color.escapef(color.WHITE); + return str .. color.escapef(color.GREEN).."On"..color.escapef(color.WHITE); else - return str .. color.escapef(color.RED)..": Off"..color.escapef(color.WHITE); + return str .. color.escapef(color.RED).."Off"..color.escapef(color.WHITE); end end boot_options = { ["1"] = {index = 1, name = "Back to menu", func = function () return true; end }, ["2"] = {index = 2, name = "Load System defaults", func = function () core.setDefaults(); return false; end }, - ["3"] = {index = 3, getName = function () return OnOff("ACPI ", core.acpi); end, func = function () core.setACPI(); return false; end }, - ["4"] = {index = 4, getName = function () return OnOff("Safe Mode ", core.sm); end, func = function () core.setSafeMode(); return false; end }, - ["5"] = {index = 5, getName = function () return OnOff("Single user", core.su); end, func = function () core.setSingleUser(); return false; end }, - ["6"] = {index = 6, getName = function () return OnOff("Verbose ", core.verbose); end, func = function () core.setVerbose(); return false; end } + ["3"] = {index = 3, getName = function () return OnOff("ACPI :", core.acpi); end, func = function () core.setACPI(); return false; end }, + ["4"] = {index = 4, getName = function () return OnOff("Safe Mode :", core.sm); end, func = function () core.setSafeMode(); return false; end }, + ["5"] = {index = 5, getName = function () return OnOff("Single user:", core.su); end, func = function () core.setSingleUser(); return false; end }, + ["6"] = {index = 6, getName = function () return OnOff("Verbose :", core.verbose); end, func = function () core.setVerbose(); return false; end } } \ No newline at end of file Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua ============================================================================== --- soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua Wed Jul 30 18:47:31 2014 (r271622) +++ soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua Wed Jul 30 19:50:56 2014 (r271623) @@ -32,6 +32,10 @@ return "\027[0;37;40m"; end +function color.highlight(str) + return "\027[1m"..str.."\027[0m"; +end + function screen.clear() print("\027[H\027[J"); end @@ -53,5 +57,5 @@ end function screen.defcursor() - print("\027[24;0H"); + print("\027[25;0H"); end \ No newline at end of file From owner-svn-soc-all@FreeBSD.ORG Thu Jul 31 14:29:20 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 773A5F12 for ; Thu, 31 Jul 2014 14:29:20 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6349D26A3 for ; Thu, 31 Jul 2014 14:29:20 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s6VETKOD026127 for ; Thu, 31 Jul 2014 14:29:20 GMT (envelope-from shonali@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s6VETIhG026107 for svn-soc-all@FreeBSD.org; Thu, 31 Jul 2014 14:29:18 GMT (envelope-from shonali@FreeBSD.org) Date: Thu, 31 Jul 2014 14:29:18 GMT Message-Id: <201407311429.s6VETIhG026107@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to shonali@FreeBSD.org using -f From: shonali@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271638 - in soc2014/shonali/head: contrib/bsnmp/lib contrib/bsnmp/snmpd usr.sbin/bsnmpd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Jul 2014 14:29:20 -0000 Author: shonali Date: Thu Jul 31 14:29:18 2014 New Revision: 271638 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271638 Log: Added some fixes for trap.c, export.c. Made changes to header files. Modified: soc2014/shonali/head/contrib/bsnmp/lib/snmp.h soc2014/shonali/head/contrib/bsnmp/snmpd/export.c soc2014/shonali/head/contrib/bsnmp/snmpd/snmpd.h soc2014/shonali/head/contrib/bsnmp/snmpd/trap.c soc2014/shonali/head/usr.sbin/bsnmpd/Makefile Modified: soc2014/shonali/head/contrib/bsnmp/lib/snmp.h ============================================================================== --- soc2014/shonali/head/contrib/bsnmp/lib/snmp.h Thu Jul 31 13:02:56 2014 (r271637) +++ soc2014/shonali/head/contrib/bsnmp/lib/snmp.h Thu Jul 31 14:29:18 2014 (r271638) @@ -76,6 +76,7 @@ } octetstring; struct asn_oid oid; u_char ipaddress[4]; + u_char ipaddress6[16]; uint32_t uint32; /* also gauge32, counter32, unsigned32, timeticks */ uint64_t counter64; Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/export.c ============================================================================== --- soc2014/shonali/head/contrib/bsnmp/snmpd/export.c Thu Jul 31 13:02:56 2014 (r271637) +++ soc2014/shonali/head/contrib/bsnmp/snmpd/export.c Thu Jul 31 14:29:18 2014 (r271638) @@ -380,22 +380,31 @@ { u_int8_t *pval; u_int i; + + switch (oid->len) { + + case 4: if (sub + 4 > oid->len) + goto err; + //pval = va_arg(ap, u_int8_t *); + u_int8_t pval[4]; + for (i = 0; i < 4; i++) { + if (oid->subs[sub] > 0xff) + goto err; + pval[i] = oid->subs[sub++]; + } + + case 16: if (sub + 16 > oid->len) + goto err; + //pval = va_arg(ap, u_int8_t *); + u_int8_t pval[16]; + for (i = 0; i < 16; i++) { + pval[i] = oid->subs[sub++]; + } + + default: + return (NULL); + } - if (sub + 16 > oid->len) - goto err; - pval = va_arg(ap, u_int8_t *); - if (sizeof(*pval)== 4) { - for (i = 0; i < 4; i++) { - if (oid->subs[sub] > 0xff) - goto err; - pval[i] = oid->subs[sub++]; - } - } - if (sizeof(*pval)== 16) { - for (i = 0; i < 16; i++) { - pval[i] = oid->subs[sub++]; - } - } break; } Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/snmpd.h ============================================================================== --- soc2014/shonali/head/contrib/bsnmp/snmpd/snmpd.h Thu Jul 31 13:02:56 2014 (r271637) +++ soc2014/shonali/head/contrib/bsnmp/snmpd/snmpd.h Thu Jul 31 14:29:18 2014 (r271638) @@ -241,6 +241,9 @@ /* source address for V1 traps */ u_char trap1addr[4]; + /* ipv6 source address for V1 traps */ + u_char trap1addr6[16]; + /* version enable flags */ uint32_t version_enable; }; Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/trap.c ============================================================================== --- soc2014/shonali/head/contrib/bsnmp/snmpd/trap.c Thu Jul 31 13:02:56 2014 (r271637) +++ soc2014/shonali/head/contrib/bsnmp/snmpd/trap.c Thu Jul 31 14:29:18 2014 (r271638) @@ -113,7 +113,7 @@ t->comm[0] = '\0'; t->version = TRAPSINK_V2; - switch (sizeof(t->index.subs)) { + switch (t->index.len)) { /* IPv4 - Check if there is a better way of determining address type */ case 6: trapsink_create_sock(t); @@ -200,10 +200,11 @@ (t->index.subs[9] << 48) | (t->index.subs[10] << 40) | (t->index.subs[11] << 32) | (t->index.subs[12] << 24) | (t->index.subs[13] << 16) | (t->index.subs[14] << 8) | t->index.subs[15]; sa.sin6_port = htons(t->index.subs[16]); - + + char dst[INET6_ADDRSTRLEN]; + inet_ntop(AF_INET6,&(sa.sin6_addr), dst, INET6_ADDRSTRLEN); if (connect(t->socket, (struct sockaddr *)&sa, sa.sin6_len) == -1) { - syslog(LOG_ERR, "connect(%s,%u): %m", - inet_ntoa(sa.sin6_addr), ntohs(sa.sin6_port)); + syslog(LOG_ERR, "connect(%s,%u): %m", dst, ntohs(sa.sin6_port)); (void)close(t->socket); free(t); return (SNMP_ERR_GENERR); @@ -373,6 +374,7 @@ break; case SNMP_OP_SET: + /* XX - Check, if reqd add ipv6 support for ipa */ if (index_decode(&value->var, sub, iidx, ipa, &port) || port == 0 || port > 65535) return (SNMP_ERR_NO_CREATION); @@ -771,9 +773,15 @@ int target_activate_address(struct target_address *addrs) { - /* XXX - IPv4/IPv6 - Check if there is a better way of determining address type - Change switch code */ - - switch (sizeof(*addrs->address)) { + /* XXX - IPv4/IPv6 - Check if there is a better way of determining address type */ + if(addrs->address == NULL && addrs->address6 != NULL) + int len = 18; + else if (addrs->address != NULL && addrs->address6 == NULL) + int len = 6; + else + syslog(LOG_ERR, "Target address %s does not exist", addrs->name); + + switch (len) { case 6: struct sockaddr_in sa; Modified: soc2014/shonali/head/usr.sbin/bsnmpd/Makefile ============================================================================== --- soc2014/shonali/head/usr.sbin/bsnmpd/Makefile Thu Jul 31 13:02:56 2014 (r271637) +++ soc2014/shonali/head/usr.sbin/bsnmpd/Makefile Thu Jul 31 14:29:18 2014 (r271638) @@ -1,8 +1,13 @@ # $FreeBSD$ -SUBDIR= gensnmptree \ - bsnmpd \ - modules \ - tools - +SUBDIR= gensnmpdef \ gensnmptree \ bsnmpd \ modules \ tools .include + cd usr.sbin/bsnmpd + mkdir gensnmpdef + cd gensnmpdef/ + fetch http://people.freebsd.org/~syrinx/Makefile + cd .. + make + make install + rehash + which gensnmpdef From owner-svn-soc-all@FreeBSD.ORG Thu Jul 31 16:20:43 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 806A8E67 for ; Thu, 31 Jul 2014 16:20:43 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 61CE925D7 for ; Thu, 31 Jul 2014 16:20:43 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s6VGKh0q086281 for ; Thu, 31 Jul 2014 16:20:43 GMT (envelope-from zkorchev@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s6VGKgVu086277 for svn-soc-all@FreeBSD.org; Thu, 31 Jul 2014 16:20:42 GMT (envelope-from zkorchev@FreeBSD.org) Date: Thu, 31 Jul 2014 16:20:42 GMT Message-Id: <201407311620.s6VGKgVu086277@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zkorchev@FreeBSD.org using -f From: zkorchev@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271646 - soc2014/zkorchev/freebsd_head/lib/libsol MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Jul 2014 16:20:43 -0000 Author: zkorchev Date: Thu Jul 31 16:20:42 2014 New Revision: 271646 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271646 Log: draft for human-readable format for libsol Modified: soc2014/zkorchev/freebsd_head/lib/libsol/sol.c soc2014/zkorchev/freebsd_head/lib/libsol/sol.h Modified: soc2014/zkorchev/freebsd_head/lib/libsol/sol.c ============================================================================== --- soc2014/zkorchev/freebsd_head/lib/libsol/sol.c Thu Jul 31 15:40:03 2014 (r271645) +++ soc2014/zkorchev/freebsd_head/lib/libsol/sol.c Thu Jul 31 16:20:42 2014 (r271646) @@ -34,21 +34,42 @@ // TODO track whether a key or a value is expected and generate error when appropriate? -// TODO unsigned type support (used for fstat pipes) +static void padding(const struct sol_stream *restrict stream) +{ +#define T4 "\t\t\t\t" + static const char buf[] = "\n" T4 T4 T4 T4 T4 T4 T4 T4; + printf("%.*s", 1 + stream->ctx.c.depth - stream->ctx.c.stack[0], buf); +#undef T4 +} + +static void separator(struct sol_stream *restrict stream) +{ + if (!stream->ctx.c.depth) return; + if (stream->ctx.c.stack[stream->ctx.c.depth - 1]) return; + + if (stream->ctx.c.first) + stream->ctx.c.first = 0; + else + printf(","); +} int sol_init(struct sol_stream *restrict stream) { char *format = getenv("SOL_FORMAT"); - if (!format) - return 0; + if (!format) return 0; if (!strcmp(format, "json")) + { stream->f = SOL_JSON; - else - return 0; - - //stream->f = format; - stream->ctx.g = yajl_gen_alloc(0); + stream->ctx.g = yajl_gen_alloc(0); + } + else if (!strcmp(format, "configuration")) + { + stream->f = SOL_CONF; + stream->ctx.c.depth = 0; + stream->ctx.c.first = 0; + } + else return 0; return stream->f; } @@ -57,6 +78,7 @@ { const char *buffer; size_t length; + switch (stream->f) { case SOL_JSON: @@ -64,19 +86,45 @@ write(1, buffer, length); yajl_gen_clear(stream->ctx.g); break; + + case SOL_CONF: + fflush(stdout); + break; } } void sol_term(struct sol_stream *restrict stream) { flush(stream); - write(1, "\n", 1); // TODO change this - yajl_gen_free(stream->ctx.g); + switch (stream->f) + { + case SOL_JSON: + write(1, "\n", 1); // TODO change this + yajl_gen_free(stream->ctx.g); + break; + + case SOL_CONF: + write(1, "\n", 1); // TODO change this + break; + } } int sol_array_start(struct sol_stream *restrict stream) { - yajl_gen_array_open(stream->ctx.g); + switch (stream->f) + { + case SOL_JSON: + yajl_gen_array_open(stream->ctx.g); + break; + + case SOL_CONF: + separator(stream); + padding(stream); + printf("["); + stream->ctx.c.stack[stream->ctx.c.depth++] = 0; + stream->ctx.c.first = 1; + break; + } return 0; } @@ -84,14 +132,41 @@ int sol_array_end(struct sol_stream *restrict stream) { flush(stream); - yajl_gen_array_close(stream->ctx.g); + switch (stream->f) + { + case SOL_JSON: + yajl_gen_array_close(stream->ctx.g); + break; + + case SOL_CONF: + stream->ctx.c.depth -= 1; + stream->ctx.c.first = 0; + padding(stream); + printf("]"); + break; + } return 0; } int sol_map_start(struct sol_stream *restrict stream) { - yajl_gen_map_open(stream->ctx.g); + switch (stream->f) + { + case SOL_JSON: + yajl_gen_map_open(stream->ctx.g); + break; + + case SOL_CONF: + if (stream->ctx.c.depth) + { + separator(stream); + padding(stream); + printf("{"); + } + stream->ctx.c.stack[stream->ctx.c.depth++] = 1; + break; + } return 0; } @@ -99,14 +174,39 @@ int sol_map_end(struct sol_stream *restrict stream) { flush(stream); - yajl_gen_map_close(stream->ctx.g); + switch (stream->f) + { + case SOL_JSON: + yajl_gen_map_close(stream->ctx.g); + break; + + case SOL_CONF: + stream->ctx.c.depth -= 1; + if (stream->ctx.c.depth) + { + padding(stream); + printf("}"); + } + stream->ctx.c.first = 0; + break; + } return 0; } int sol_map_key(struct sol_stream *restrict stream, const char *key, size_t length) { - yajl_gen_string(stream->ctx.g, (const unsigned char *)key, length); + switch (stream->f) + { + case SOL_JSON: + yajl_gen_string(stream->ctx.g, (const unsigned char *)key, length); + break; + + case SOL_CONF: + padding(stream); + printf("%s", key); + break; + } return 0; } @@ -117,40 +217,101 @@ size_t len; len = sprintf(buffer, "%" PRIi64, number); - yajl_gen_string(stream->ctx.g, (const unsigned char *)buffer, len); - - return 0; + return sol_map_key(stream, buffer, len); } int sol_string(struct sol_stream *restrict stream, const char *data, size_t length) { - yajl_gen_string(stream->ctx.g, (const unsigned char *)data, length); + switch (stream->f) + { + case SOL_JSON: + yajl_gen_string(stream->ctx.g, (const unsigned char *)data, length); + break; + + case SOL_CONF: + if (stream->ctx.c.stack[stream->ctx.c.depth - 1]) + printf(" = \"%s\";", data); + else + { + separator(stream); + padding(stream); + printf("\"%s\"", data); + } + break; + } return 0; } int sol_boolean(struct sol_stream *restrict stream, unsigned char value) { - yajl_gen_bool(stream->ctx.g, value); + switch (stream->f) + { + case SOL_JSON: + yajl_gen_bool(stream->ctx.g, value); + break; + + case SOL_CONF: + if (stream->ctx.c.stack[stream->ctx.c.depth - 1]) + printf(" = %s;", (value ? "true" : "false")); + else + { + separator(stream); + padding(stream); + printf("%s", (value ? "true" : "false")); + } + break; + } return 0; } int sol_integer(struct sol_stream *restrict stream, int64_t value) { - yajl_gen_integer(stream->ctx.g, value); + switch (stream->f) + { + case SOL_JSON: + yajl_gen_integer(stream->ctx.g, value); + break; + + case SOL_CONF: + if (stream->ctx.c.stack[stream->ctx.c.depth - 1]) + printf(" = %" PRId64 ";", value); + else + { + separator(stream); + padding(stream); + printf("%" PRId64, value); + } + break; + } return 0; } -int sol_uinteger(struct sol_stream *restrict stream, uint64_t value) // TODO better name for this? +int sol_uinteger(struct sol_stream *restrict stream, uint64_t value) { char buffer[20 + 1]; // UINT64_MAX fits in 20 bytes size_t len; - // TODO use hex when supported - len = sprintf(buffer, "%" PRIu64, value); - yajl_gen_number(stream->ctx.g, buffer, len); + switch (stream->f) + { + case SOL_JSON: + len = sprintf(buffer, "%" PRIu64, value); + yajl_gen_number(stream->ctx.g, buffer, len); + break; + + case SOL_CONF: + if (stream->ctx.c.stack[stream->ctx.c.depth - 1]) + printf(" = %" PRIx64 ";", value); + else + { + separator(stream); + padding(stream); + printf("%" PRIx64, value); + } + break; + } return 0; } @@ -158,7 +319,23 @@ int sol_float(struct sol_stream *restrict stream, double value) { // todo round mantissa? - yajl_gen_double(stream->ctx.g, value); + switch (stream->f) + { + case SOL_JSON: + yajl_gen_double(stream->ctx.g, value); + break; + + case SOL_CONF: + if (stream->ctx.c.stack[stream->ctx.c.depth - 1]) + printf(" = %f;", value); + else + { + separator(stream); + padding(stream); + printf("%f", value); + } + break; + } return 0; } Modified: soc2014/zkorchev/freebsd_head/lib/libsol/sol.h ============================================================================== --- soc2014/zkorchev/freebsd_head/lib/libsol/sol.h Thu Jul 31 15:40:03 2014 (r271645) +++ soc2014/zkorchev/freebsd_head/lib/libsol/sol.h Thu Jul 31 16:20:42 2014 (r271646) @@ -29,12 +29,20 @@ #define SOL_MAP_KEYL(stream, key) sol_map_key(stream, key, sizeof(key) - 1) +#define SOL_DEPTH_MAX 32 + struct sol_stream { - enum {SOL_JSON = 1} f; + enum {SOL_JSON = 1, SOL_CONF} f; union { yajl_gen g; + struct + { + unsigned char stack[SOL_DEPTH_MAX]; + unsigned depth; + int first; + } c; } ctx; }; From owner-svn-soc-all@FreeBSD.ORG Thu Jul 31 18:31:02 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 73C84809 for ; Thu, 31 Jul 2014 18:31:02 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5ECF125C5 for ; Thu, 31 Jul 2014 18:31:02 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s6VIV2c4066377 for ; Thu, 31 Jul 2014 18:31:02 GMT (envelope-from shonali@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s6VIV1OB066373 for svn-soc-all@FreeBSD.org; Thu, 31 Jul 2014 18:31:01 GMT (envelope-from shonali@FreeBSD.org) Date: Thu, 31 Jul 2014 18:31:01 GMT Message-Id: <201407311831.s6VIV1OB066373@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to shonali@FreeBSD.org using -f From: shonali@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271653 - soc2014/shonali/head/contrib/bsnmp/snmpd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Jul 2014 18:31:02 -0000 Author: shonali Date: Thu Jul 31 18:31:01 2014 New Revision: 271653 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271653 Log: Added fixes to config.c, export.c and trans_udpv6.c. Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/config.c soc2014/shonali/head/contrib/bsnmp/snmpd/export.c soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udpv6.c Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/config.c ============================================================================== --- soc2014/shonali/head/contrib/bsnmp/snmpd/config.c Thu Jul 31 17:18:40 2014 (r271652) +++ soc2014/shonali/head/contrib/bsnmp/snmpd/config.c Thu Jul 31 18:31:01 2014 (r271653) @@ -791,63 +791,67 @@ report("%s: %s", host, gai_strerror(error)); if (res == NULL) report("%s: unknown hostname", host); + + switch (res->ai_family) { - if(res->ai_family == AF_INET) { - addr_type = AF_INET; - struct sockaddr_in *sain ; - sain = (struct sockaddr_in *)(void *)res->ai_addr; - sain->sin_addr.s_addr = ntohl(sain->sin_addr.s_addr); + case AF_INET : + addr_type = AF_INET; + struct sockaddr_in *sain ; + sain = (struct sockaddr_in *)(void *)res->ai_addr; + sain->sin_addr.s_addr = ntohl(sain->sin_addr.s_addr); - ip[0] = sain->sin_addr.s_addr >> 24; - ip[1] = sain->sin_addr.s_addr >> 16; - ip[2] = sain->sin_addr.s_addr >> 8; - ip[3] = sain->sin_addr.s_addr >> 0; - } - else if(res->ai_family == AF_INET6) { - - addr_type = AF_INET6; - struct sockaddr_in6 *sain ; - sain = (struct sockaddr_in6 *)(void *)res->ai_addr; - unsigned char tmp[16]; + ip[0] = sain->sin_addr.s_addr >> 24; + ip[1] = sain->sin_addr.s_addr >> 16; + ip[2] = sain->sin_addr.s_addr >> 8; + ip[3] = sain->sin_addr.s_addr >> 0; + + case AF_INET6 : + addr_type = AF_INET6; + struct sockaddr_in6 *sain ; + sain = (struct sockaddr_in6 *)(void *)res->ai_addr; + unsigned char tmp[16]; - /* ipv6 implementation of network to host byte order function */ - /* May be unnecessary - check */ - if (BYTE_ORDER == LITTLE_ENDIAN) { - tmp[3] = (sain->sin6_addr.s6_addr[0] << 24) | (sain->sin6_addr.s6_addr[1] << 16) | (sain->sin6_addr.s6_addr[2] << 8) | sain->sin6_addr.s6_addr[3]; - tmp[2] = (sain->sin6_addr.s6_addr[4] << 24) | (sain->sin6_addr.s6_addr[5] << 16) | (sain->sin6_addr.s6_addr[6] << 8) | sain->sin6_addr.s6_addr[7]; - tmp[1] = (sain->sin6_addr.s6_addr[8] << 24) | (sain->sin6_addr.s6_addr[9] << 16) | (sain->sin6_addr.s6_addr[10] << 8) | sain->sin6_addr.s6_addr[11]; - tmp[0] = (sain->sin6_addr.s6_addr[12] << 24) | (sain->sin6_addr.s6_addr[13] << 16) | (sain->sin6_addr.s6_addr[14] << 8) | sain->sin6_addr.s6_addr[15]; - } - - else { - tmp[0] = (sain->sin6_addr.s6_addr[0] << 24) | (sain->sin6_addr.s6_addr[1] << 16) | (sain->sin6_addr.s6_addr[2] << 8) | sain->sin6_addr.s6_addr[3]; - tmp[1] = (sain->sin6_addr.s6_addr[4] << 24) | (sain->sin6_addr.s6_addr[5] << 16) | (sain->sin6_addr.s6_addr[6] << 8) | sain->sin6_addr.s6_addr[7]; - tmp[2] = (sain->sin6_addr.s6_addr[8] << 24) | (sain->sin6_addr.s6_addr[9] << 16) | (sain->sin6_addr.s6_addr[10] << 8) | sain->sin6_addr.s6_addr[11]; - tmp[3] = (sain->sin6_addr.s6_addr[12] << 24) | (sain->sin6_addr.s6_addr[13] << 16) | (sain->sin6_addr.s6_addr[14] << 8) | sain->sin6_addr.s6_addr[15]; - } + /* ipv6 implementation of network to host byte order function */ + /* May be unnecessary - check */ + if (BYTE_ORDER == LITTLE_ENDIAN) { + tmp[3] = (sain->sin6_addr.s6_addr[0] << 24) | (sain->sin6_addr.s6_addr[1] << 16) | (sain->sin6_addr.s6_addr[2] << 8) | sain->sin6_addr.s6_addr[3]; + tmp[2] = (sain->sin6_addr.s6_addr[4] << 24) | (sain->sin6_addr.s6_addr[5] << 16) | (sain->sin6_addr.s6_addr[6] << 8) | sain->sin6_addr.s6_addr[7]; + tmp[1] = (sain->sin6_addr.s6_addr[8] << 24) | (sain->sin6_addr.s6_addr[9] << 16) | (sain->sin6_addr.s6_addr[10] << 8) | sain->sin6_addr.s6_addr[11]; + tmp[0] = (sain->sin6_addr.s6_addr[12] << 24) | (sain->sin6_addr.s6_addr[13] << 16) | (sain->sin6_addr.s6_addr[14] << 8) | sain->sin6_addr.s6_addr[15]; + } + + else { + tmp[0] = (sain->sin6_addr.s6_addr[0] << 24) | (sain->sin6_addr.s6_addr[1] << 16) | (sain->sin6_addr.s6_addr[2] << 8) | sain->sin6_addr.s6_addr[3]; + tmp[1] = (sain->sin6_addr.s6_addr[4] << 24) | (sain->sin6_addr.s6_addr[5] << 16) | (sain->sin6_addr.s6_addr[6] << 8) | sain->sin6_addr.s6_addr[7]; + tmp[2] = (sain->sin6_addr.s6_addr[8] << 24) | (sain->sin6_addr.s6_addr[9] << 16) | (sain->sin6_addr.s6_addr[10] << 8) | sain->sin6_addr.s6_addr[11]; + tmp[3] = (sain->sin6_addr.s6_addr[12] << 24) | (sain->sin6_addr.s6_addr[13] << 16) | (sain->sin6_addr.s6_addr[14] << 8) | sain->sin6_addr.s6_addr[15]; + } - strcpy(sain->sin6_addr.s6_addr, (unsigned char *)tmp) ; - inet_ntop(AF_INET6, &(sain->sin6_addr), *ip, INET6_ADDRSTRLEN); + strcpy(sain->sin6_addr.s6_addr, (unsigned char *)tmp) ; + inet_ntop(AF_INET6, &(sain->sin6_addr), *ip, INET6_ADDRSTRLEN); + + /* incase inet_ntop doesn't work as expected + ip[0] = sain->sin6_addr.s6_addr >> 120; + ip[1] = sain->sin6_addr.s6_addr >> 112; + ip[2] = sain->sin6_addr.s6_addr >> 104; + ip[3] = sain->sin6_addr.s6_addr >> 96; + ip[4] = sain->sin6_addr.s6_addr >> 88; + ip[5] = sain->sin6_addr.s6_addr >> 80; + ip[6] = sain->sin6_addr.s6_addr >> 72; + ip[7] = sain->sin6_addr.s6_addr >> 64; + ip[8] = sain->sin6_addr.s6_addr >> 56; + ip[9] = sain->sin6_addr.s6_addr >> 48; + ip[10] = sain->sin6_addr.s6_addr >> 40; + ip[11] = sain->sin6_addr.s6_addr >> 32; + ip[12] = sain->sin6_addr.s6_addr >> 24; + ip[13] = sain->sin6_addr.s6_addr >> 16; + ip[14] = sain->sin6_addr.s6_addr >> 8; + ip[15] = sain->sin6_addr.s6_addr >> 0; + */ - /* incase inet_ntop doesn't work as expected - ip[0] = sain->sin6_addr.s6_addr >> 120; - ip[1] = sain->sin6_addr.s6_addr >> 112; - ip[2] = sain->sin6_addr.s6_addr >> 104; - ip[3] = sain->sin6_addr.s6_addr >> 96; - ip[4] = sain->sin6_addr.s6_addr >> 88; - ip[5] = sain->sin6_addr.s6_addr >> 80; - ip[6] = sain->sin6_addr.s6_addr >> 72; - ip[7] = sain->sin6_addr.s6_addr >> 64; - ip[8] = sain->sin6_addr.s6_addr >> 56; - ip[9] = sain->sin6_addr.s6_addr >> 48; - ip[10] = sain->sin6_addr.s6_addr >> 40; - ip[11] = sain->sin6_addr.s6_addr >> 32; - ip[12] = sain->sin6_addr.s6_addr >> 24; - ip[13] = sain->sin6_addr.s6_addr >> 16; - ip[14] = sain->sin6_addr.s6_addr >> 8; - ip[15] = sain->sin6_addr.s6_addr >> 0; - */ - } + default: + return (NULL); + } freeaddrinfo(res); } @@ -860,7 +864,7 @@ { struct snmp_node *node; u_int i; - u_char ip[4]; + u_char ip[16]; struct asn_oid str_oid; for (node = tree; node < &tree[tree_size]; node++) @@ -901,15 +905,18 @@ } else if (token == TOK_HOST) { gethost(strval, ip); - if (oid->len + 16 > ASN_MAXOIDLEN) - report("index too long"); + if (addr_type == AF_INET){ + if (oid->len + 4 > ASN_MAXOIDLEN) + report("index too long"); for (i = 0; i < 4; i++) oid->subs[oid->len++] = ip[i]; gettoken(); } if (addr_type == AF_INET6){ + if (oid->len + 16 > ASN_MAXOIDLEN) + report("index too long"); for (i = 0; i < 16; i++) oid->subs[oid->len++] = ip[i]; gettoken(); @@ -1030,41 +1037,41 @@ parse_syntax_ipaddress(struct snmp_value *value) { int i; - u_char ip[4]; + u_char ip[16]; if (token == TOK_NUM) { /* numerical address */ i = 0; for (;;) { if (!isxdigit(numval)) { - if (numval >= 256) - report("ip address part too large"); - value->v.ipaddress[i++] = numval; - if (i == 4) - break; - if (gettoken() != '.') - report("expecting '.' in ip address"); - } - else { - value->v.ipaddress[i++] = numval; - if (i == 16) - break; - if (gettoken() != ':') - report("expecting ':' in ip address"); - } + if (numval >= 256) + report("ip address part too large"); + value->v.ipaddress[i++] = numval; + if (i == 4) + break; + if (gettoken() != '.') + report("expecting '.' in ip address"); + } + + else { + value->v.ipaddress[i++] = numval; + if (i == 16) + break; + if (gettoken() != ':') + report("expecting ':' in ip address"); + } } gettoken(); if (i == 4) { - struct in_addr dst; - if (!inet_pton(AF_INET,value->v.ipaddress[i++],(void *)&dst)) - report("ip address not valid"); + struct in_addr dst; + if (!inet_pton(AF_INET,value->v.ipaddress[i++],(void *)&dst)) + report("ip address not valid"); } else if (i == 16) { - struct in6_addr dst; - if (!inet_pton(AF_INET6,value->v.ipaddress[i++],(void *)&dst)) - report("ipv6 address not valid"); - + struct in6_addr dst; + if (!inet_pton(AF_INET6,value->v.ipaddress[i++],(void *)&dst)) + report("ipv6 address not valid"); } } else if (token == TOK_HOST) { Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/export.c ============================================================================== --- soc2014/shonali/head/contrib/bsnmp/snmpd/export.c Thu Jul 31 17:18:40 2014 (r271652) +++ soc2014/shonali/head/contrib/bsnmp/snmpd/export.c Thu Jul 31 18:31:01 2014 (r271653) @@ -152,37 +152,41 @@ */ int ip_save(struct snmp_value *value, struct snmp_context *ctx, u_char *valp) -{ +{ + /* XX - sizeof of a pointer to an array doesn't give you size of array + Need to find a fix to this or a new way of finding address type */ + if (sizeof(*valp)== 4) { - ctx->scratch->int1 = (valp[0] << 24) | (valp[1] << 16) | (valp[2] << 8) - | valp[3]; + ctx->scratch->int1 = (valp[0] << 24) | (valp[1] << 16) | (valp[2] << 8) + | valp[3]; - valp[0] = value->v.ipaddress[0]; - valp[1] = value->v.ipaddress[1]; - valp[2] = value->v.ipaddress[2]; - valp[3] = value->v.ipaddress[3]; + valp[0] = value->v.ipaddress[0]; + valp[1] = value->v.ipaddress[1]; + valp[2] = value->v.ipaddress[2]; + valp[3] = value->v.ipaddress[3]; } if (sizeof(*valp)== 16) { - ctx->scratch->int1 = (valp[0] << 120) | (valp[1] << 112) | (valp[2] << 104) | (valp[3] << 96) | (valp[4] << 88) | (valp[5] << 80) | (valp[6] << 72) | (valp[7] << 64) | (valp[8] << 56) | - (valp[9] << 48) | (valp[10] << 40) | (valp[11] << 32) | (valp[12] << 24) | (valp[13] << 16) | (valp[14] << 8) | valp[15]; - - valp[0] = value->v.ipaddress[0]; - valp[1] = value->v.ipaddress[1]; - valp[2] = value->v.ipaddress[2]; - valp[3] = value->v.ipaddress[3]; - valp[4] = value->v.ipaddress[4]; - valp[5] = value->v.ipaddress[5]; - valp[6] = value->v.ipaddress[6]; - valp[7] = value->v.ipaddress[7]; - valp[8] = value->v.ipaddress[8]; - valp[9] = value->v.ipaddress[9]; - valp[10] = value->v.ipaddress[10]; - valp[11] = value->v.ipaddress[11]; - valp[12] = value->v.ipaddress[12]; - valp[13] = value->v.ipaddress[13]; - valp[14] = value->v.ipaddress[14]; - valp[15] = value->v.ipaddress[15]; + ctx->scratch->int1 = (valp[0] << 120) | (valp[1] << 112) | (valp[2] << 104) | (valp[3] << 96) | (valp[4] << 88) | + (valp[5] << 80) | (valp[6] << 72) | (valp[7] << 64) | (valp[8] << 56) | (valp[9] << 48) | (valp[10] << 40) | + (valp[11] << 32) | (valp[12] << 24) | (valp[13] << 16) | (valp[14] << 8) | valp[15]; + + valp[0] = value->v.ipaddress6[0]; + valp[1] = value->v.ipaddress6[1]; + valp[2] = value->v.ipaddress6[2]; + valp[3] = value->v.ipaddress6[3]; + valp[4] = value->v.ipaddress6[4]; + valp[5] = value->v.ipaddress6[5]; + valp[6] = value->v.ipaddress6[6]; + valp[7] = value->v.ipaddress6[7]; + valp[8] = value->v.ipaddress6[8]; + valp[9] = value->v.ipaddress6[9]; + valp[10] = value->v.ipaddress6[10]; + valp[11] = value->v.ipaddress6[11]; + valp[12] = value->v.ipaddress6[12]; + valp[13] = value->v.ipaddress6[13]; + valp[14] = value->v.ipaddress6[14]; + valp[15] = value->v.ipaddress6[15]; } @@ -194,7 +198,11 @@ */ void ip_rollback(struct snmp_context *ctx, u_char *valp) -{ if (sizeof(*valp)== 4) { +{ + /* XX - sizeof of a pointer to an array doesn't give you size of array + Need to find a fix to this or a new way of finding address type */ + + if (sizeof(*valp)== 4) { valp[0] = ctx->scratch->int1 >> 24; valp[1] = ctx->scratch->int1 >> 16; valp[2] = ctx->scratch->int1 >> 8; @@ -234,29 +242,33 @@ int ip_get(struct snmp_value *value, u_char *valp) { + /* XX - sizeof of a pointer to an array doesn't give you size of array + Need to find a fix to this or a new way of finding address type */ + if (sizeof(*valp)== 4) { - value->v.ipaddress[0] = valp[0]; - value->v.ipaddress[1] = valp[1]; - value->v.ipaddress[2] = valp[2]; - value->v.ipaddress[3] = valp[3]; + value->v.ipaddress[0] = valp[0]; + value->v.ipaddress[1] = valp[1]; + value->v.ipaddress[2] = valp[2]; + value->v.ipaddress[3] = valp[3]; } + if (sizeof(*valp)== 16) { - value->v.ipaddress[0] = valp[0]; - value->v.ipaddress[1] = valp[1]; - value->v.ipaddress[2] = valp[2]; - value->v.ipaddress[3] = valp[3]; - value->v.ipaddress[4] = valp[4]; - value->v.ipaddress[5] = valp[5]; - value->v.ipaddress[6] = valp[6]; - value->v.ipaddress[7] = valp[7]; - value->v.ipaddress[8] = valp[8]; - value->v.ipaddress[9] = valp[9]; - value->v.ipaddress[10] = valp[10]; - value->v.ipaddress[11] = valp[11]; - value->v.ipaddress[12] = valp[12]; - value->v.ipaddress[13] = valp[13]; - value->v.ipaddress[14] = valp[14]; - value->v.ipaddress[15] = valp[15]; + value->v.ipaddress6[0] = valp[0]; + value->v.ipaddress6[1] = valp[1]; + value->v.ipaddress6[2] = valp[2]; + value->v.ipaddress6[3] = valp[3]; + value->v.ipaddress6[4] = valp[4]; + value->v.ipaddress6[5] = valp[5]; + value->v.ipaddress6[6] = valp[6]; + value->v.ipaddress6[7] = valp[7]; + value->v.ipaddress6[8] = valp[8]; + value->v.ipaddress6[9] = valp[9]; + value->v.ipaddress6[10] = valp[10]; + value->v.ipaddress6[11] = valp[11]; + value->v.ipaddress6[12] = valp[12]; + value->v.ipaddress6[13] = valp[13]; + value->v.ipaddress6[14] = valp[14]; + value->v.ipaddress6[15] = valp[15]; } return (SNMP_ERR_NOERROR); Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udpv6.c ============================================================================== --- soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udpv6.c Thu Jul 31 17:18:40 2014 (r271652) +++ soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udpv6.c Thu Jul 31 18:31:01 2014 (r271653) @@ -104,7 +104,7 @@ { struct udpv6_port *p = (struct udpv6_port *)tp; struct sockaddr_in6 addr; - u_int32_t ip[4]; + u_int8_t ip[16]; const int on = 1; char str[INET6_ADDRSTRLEN]; @@ -113,10 +113,22 @@ return (SNMP_ERR_RES_UNAVAIL); } - ip[0] = htonl((p->addr[0] << 24) | (p->addr[1] << 16) | (p->addr[2] << 8) | p->addr[3]); - ip[1] = htonl((p->addr[4] << 24) | (p->addr[5] << 16) | (p->addr[6] << 8) | p->addr[7]); - ip[2] = htonl((p->addr[8] << 24) | (p->addr[9] << 16) | (p->addr[10] << 8) | p->addr[11]); - ip[3] = htonl((p->addr[12] << 24) | (p->addr[13] << 16) | (p->addr[14] << 8) | p->addr[15]); + ip[0] = p->addr[0] >> 120; + ip[1] = p->addr[1] >> 112; + ip[2] = p->addr[2] >> 104; + ip[3] = p->addr[3] >> 96; + ip[4] = p->addr[4] >> 88; + ip[5] = p->addr[5] >> 80; + ip[6] = p->addr[6] >> 72; + ip[7] = p->addr[7] >> 64; + ip[8] = p->addr[8] >> 56; + ip[9] = p->addr[9] >> 48; + ip[10] = p->addr[10] >> 40; + ip[11] = p->addr[11] >> 32; + ip[12] = p->addr[12] >> 24; + ip[13] = p->addr[13] >> 16; + ip[14] = p->addr[14] >> 8; + ip[15] = p->addr[15] >> 0; /* Need to check - can use getaddrinfo instead to fill up addr structure */ memset(&addr, 0, sizeof(addr)); @@ -125,7 +137,7 @@ addr.sin6_family = AF_INET6; addr.sin6_len = sizeof(addr); if ((addr.sin6_addr.s6_addr == in6addr_any.s6_addr) && - ( setsockopt(p->input.fd, IPPROTO_IPV6, IPV6_V6ONLY, &on, + ( setsockopt(p->input.fd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) == -1)) { syslog(LOG_ERR, "setsockopt(IP_RECVDSTADDR): %m"); close(p->input.fd); From owner-svn-soc-all@FreeBSD.ORG Fri Aug 1 18:09:55 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 52E31CF5 for ; Fri, 1 Aug 2014 18:09:55 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3F73C2186 for ; Fri, 1 Aug 2014 18:09:55 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s71I9tGO047720 for ; Fri, 1 Aug 2014 18:09:55 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s71I9sF7047596 for svn-soc-all@FreeBSD.org; Fri, 1 Aug 2014 18:09:54 GMT (envelope-from dpl@FreeBSD.org) Date: Fri, 1 Aug 2014 18:09:54 GMT Message-Id: <201408011809.s71I9sF7047596@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271699 - soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Aug 2014 18:09:55 -0000 Author: dpl Date: Fri Aug 1 18:09:54 2014 New Revision: 271699 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271699 Log: Move the compiling code to a more sensible place. Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c ============================================================================== --- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c Fri Aug 1 17:24:36 2014 (r271698) +++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c Fri Aug 1 18:09:54 2014 (r271699) @@ -264,17 +264,6 @@ int ipfw_chk(struct ip_fw_args *args) { - if (compiledfuncptr == 0) { - IPFW_PF_RLOCK(chain); - if (! V_ipfw_vnet_ready) { /* shutting down, leave NOW. */ - IPFW_PF_RUNLOCK(chain); - return (IP_FW_PASS); /* accept */ - } - compiledfuncptr = compile_code(args); - IPFW_PF_RUNLOCK(chain); - } else - return compiledfuncptr(); - /* * Local variables holding state while processing a packet: * @@ -404,6 +393,19 @@ proto = args->f_id.proto = 0; /* mark f_id invalid */ /* XXX 0 is a valid proto: IP/IPv6 Hop-by-Hop Option */ + /* If we haven't, JIT-compile the actions to be executed per-rule */ + if (compiledfuncptr == 0) { + IPFW_PF_RLOCK(chain); + if (! V_ipfw_vnet_ready) { /* shutting down, leave NOW. */ + IPFW_PF_RUNLOCK(chain); + return (IP_FW_PASS); /* accept */ + } + compiledfuncptr = compile_code(args, chain); + IPFW_PF_RUNLOCK(chain); + } else + return compiledfuncptr(); + + /* * PULLUP_TO(len, p, T) makes sure that len + sizeof(T) is contiguous, * then it sets p to point at the offset "len" in the mbuf. WARNING: the From owner-svn-soc-all@FreeBSD.ORG Fri Aug 1 18:11:55 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C60BDD65 for ; Fri, 1 Aug 2014 18:11:55 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B2F6F2226 for ; Fri, 1 Aug 2014 18:11:55 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s71IBtaD088962 for ; Fri, 1 Aug 2014 18:11:55 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s71IBt0Q088754 for svn-soc-all@FreeBSD.org; Fri, 1 Aug 2014 18:11:55 GMT (envelope-from dpl@FreeBSD.org) Date: Fri, 1 Aug 2014 18:11:55 GMT Message-Id: <201408011811.s71IBt0Q088754@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271700 - soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Aug 2014 18:11:55 -0000 Author: dpl Date: Fri Aug 1 18:11:54 2014 New Revision: 271700 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271700 Log: Corrected function prototype. Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.h Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.h ============================================================================== --- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.h Fri Aug 1 18:09:54 2014 (r271699) +++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.h Fri Aug 1 18:11:54 2014 (r271700) @@ -2,4 +2,4 @@ typedef int (*funcptr)(); -funcptr compile_code(struct ip_fw_args *); +funcptr compile_code(struct ip_fw_args *, struct ip_fw_chain *); From owner-svn-soc-all@FreeBSD.ORG Fri Aug 1 23:47:04 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 92E6B34A for ; Fri, 1 Aug 2014 23:47:04 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7E57828DD for ; Fri, 1 Aug 2014 23:47:04 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s71Nl4f8075754 for ; Fri, 1 Aug 2014 23:47:04 GMT (envelope-from ghostmansd@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s71Nl30P075735 for svn-soc-all@FreeBSD.org; Fri, 1 Aug 2014 23:47:03 GMT (envelope-from ghostmansd@FreeBSD.org) Date: Fri, 1 Aug 2014 23:47:03 GMT Message-Id: <201408012347.s71Nl30P075735@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ghostmansd@FreeBSD.org using -f From: ghostmansd@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271717 - in soc2014/ghostmansd/head: include lib/libc/string lib/libc/string/coll lib/libc/string/norm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Aug 2014 23:47:04 -0000 Author: ghostmansd Date: Fri Aug 1 23:47:02 2014 New Revision: 271717 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271717 Log: rolled back to r269634 Deleted: soc2014/ghostmansd/head/lib/libc/string/coll/ soc2014/ghostmansd/head/lib/libc/string/coll.h soc2014/ghostmansd/head/lib/libc/string/norm/ soc2014/ghostmansd/head/lib/libc/string/norm.h soc2014/ghostmansd/head/lib/libc/string/strnorm.3 soc2014/ghostmansd/head/lib/libc/string/strnorm.c soc2014/ghostmansd/head/lib/libc/string/wcsnorm.3 soc2014/ghostmansd/head/lib/libc/string/wcsnorm.c Modified: soc2014/ghostmansd/head/include/string.h soc2014/ghostmansd/head/include/wchar.h soc2014/ghostmansd/head/lib/libc/string/Makefile.inc Modified: soc2014/ghostmansd/head/include/string.h ============================================================================== --- soc2014/ghostmansd/head/include/string.h Fri Aug 1 22:56:41 2014 (r271716) +++ soc2014/ghostmansd/head/include/string.h Fri Aug 1 23:47:02 2014 (r271717) @@ -36,7 +36,6 @@ #include #include #include -#include /* * Prototype functions which were historically defined in , but @@ -140,30 +139,6 @@ #if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_) #include #endif - - -/* Unicode Normalization algorithm */ -#ifndef _WCHAR_H_ -#define __NORM_NFD 0 -#define __NORM_NFC 1 -#define __NORM_NFKD 2 -#define __NORM_NFKC 3 -#endif - -size_t __strnorm(char*, size_t, const char*, int); -size_t __strnorm_l(char*, size_t, const char*, int, locale_t); - -#ifdef _UNICODE_ADDENDA -#define strnorm __strnorm -#define strnorn_l __strnorm_l -#endif - -#if !defined(_WCHAR_H_) && defined(_UNICODE_ADDENDA) -#define NORM_NFD __NORM_NFD -#define NORM_NFC __NORM_NFC -#define NORM_NFKD __NORM_NFKD -#define NORM_NFKC __NORM_NFKC -#endif __END_DECLS #endif /* _STRING_H_ */ Modified: soc2014/ghostmansd/head/include/wchar.h ============================================================================== --- soc2014/ghostmansd/head/include/wchar.h Fri Aug 1 22:56:41 2014 (r271716) +++ soc2014/ghostmansd/head/include/wchar.h Fri Aug 1 23:47:02 2014 (r271717) @@ -227,28 +227,6 @@ #if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_) #include #endif - - -/* Unicode Normalization Algorithm */ -#ifndef _STRING_H_ -#define __NORM_NFD 0 -#define __NORM_NFC 1 -#define __NORM_NFKD 2 -#define __NORM_NFKC 3 -#endif - -size_t __wcsnorm(wchar_t*, size_t, const wchar_t*, int); - -#ifdef _UNICODE_ADDENDA -#define wcscoll __wcscoll -#endif - -#if !defined(_STRING_H_) && defined(_UNICODE_ADDENDA) -#define NORM_NFD __NORM_NFD -#define NORM_NFC __NORM_NFC -#define NORM_NFKD __NORM_NFKD -#define NORM_NFKC __NORM_NFKC -#endif __END_DECLS #endif /* !_WCHAR_H_ */ Modified: soc2014/ghostmansd/head/lib/libc/string/Makefile.inc ============================================================================== --- soc2014/ghostmansd/head/lib/libc/string/Makefile.inc Fri Aug 1 22:56:41 2014 (r271716) +++ soc2014/ghostmansd/head/lib/libc/string/Makefile.inc Fri Aug 1 23:47:02 2014 (r271717) @@ -21,7 +21,6 @@ wcsrchr.c wcsspn.c wcsstr.c wcstok.c wcswidth.c wcsxfrm.c wmemchr.c \ wmemcmp.c \ wmemcpy.c wmemmove.c wmemset.c -MISRCS+=strnorm.c wcsnorm.c SYM_MAPS+= ${LIBC_SRCTOP}/string/Symbol.map @@ -29,13 +28,12 @@ # machine-dependent string sources .sinclude "${LIBC_SRCTOP}/${LIBC_ARCH}/string/Makefile.inc" -MAN+=bcmp.3 bcopy.3 bstring.3 bzero.3 ffs.3 index.3 memccpy.3 memchr.3 \ +MAN+= bcmp.3 bcopy.3 bstring.3 bzero.3 ffs.3 index.3 memccpy.3 memchr.3 \ memcmp.3 memcpy.3 memmem.3 memmove.3 memset.3 strcasecmp.3 strcat.3 \ strchr.3 strcmp.3 strcoll.3 strcpy.3 strdup.3 strerror.3 \ string.3 strlcpy.3 strlen.3 strmode.3 strpbrk.3 strsep.3 \ strspn.3 strstr.3 strtok.3 strxfrm.3 swab.3 wcscoll.3 wcstok.3 \ wcswidth.3 wcsxfrm.3 wmemchr.3 -MAN+=strnorm.3 wcsnorm.3 MLINKS+=ffs.3 ffsl.3 \ ffs.3 ffsll.3 \ @@ -93,4 +91,3 @@ wmemchr.3 wmemcpy.3 \ wmemchr.3 wmemmove.3 \ wmemchr.3 wmemset.3 -MLINKS+=strnorm.3 wcsnorm.3 From owner-svn-soc-all@FreeBSD.ORG Sat Aug 2 00:50:35 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 446B0FAE for ; Sat, 2 Aug 2014 00:50:35 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2EBC72F87 for ; Sat, 2 Aug 2014 00:50:35 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s720oZaO052730 for ; Sat, 2 Aug 2014 00:50:35 GMT (envelope-from ghostmansd@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s720oXB8052718 for svn-soc-all@FreeBSD.org; Sat, 2 Aug 2014 00:50:33 GMT (envelope-from ghostmansd@FreeBSD.org) Date: Sat, 2 Aug 2014 00:50:33 GMT Message-Id: <201408020050.s720oXB8052718@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ghostmansd@FreeBSD.org using -f From: ghostmansd@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271723 - in soc2014/ghostmansd/head: include lib/libc/locale lib/libc/string lib/libc/unicode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Aug 2014 00:50:35 -0000 Author: ghostmansd Date: Sat Aug 2 00:50:32 2014 New Revision: 271723 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271723 Log: rewriting and reorganizing the source code; providing collation algorithm Currently the only available collation table is DUCET, though algorithm can already use any other collation table. DUCET is used as fallback. Source code is written in the way that makes it possible to port to any other platform that supports uint32_t. Macro _UNICODE_SOURCE must be defined to get better Unicode support. Added: soc2014/ghostmansd/head/include/unicode.h soc2014/ghostmansd/head/lib/libc/unicode/ soc2014/ghostmansd/head/lib/libc/unicode/ccclass.h soc2014/ghostmansd/head/lib/libc/unicode/ducet.h soc2014/ghostmansd/head/lib/libc/unicode/norm.h soc2014/ghostmansd/head/lib/libc/unicode/uccclass.c soc2014/ghostmansd/head/lib/libc/unicode/uchash.c soc2014/ghostmansd/head/lib/libc/unicode/ucscanon.c soc2014/ghostmansd/head/lib/libc/unicode/ucscoll.c soc2014/ghostmansd/head/lib/libc/unicode/ucsnorm.c soc2014/ghostmansd/head/lib/libc/unicode/ucsxfrm.c Modified: soc2014/ghostmansd/head/lib/libc/locale/xlocale_private.h soc2014/ghostmansd/head/lib/libc/string/wcscoll.c Added: soc2014/ghostmansd/head/include/unicode.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2014/ghostmansd/head/include/unicode.h Sat Aug 2 00:50:32 2014 (r271723) @@ -0,0 +1,66 @@ +/*- + * Copyright (c) 2014 Dmitry Selyutin. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef UNICODE_H +#define UNICODE_H + + +#include +#include +#include + + +/* Unicode canonicalization. */ +int __uccclass(uint32_t); +int __ucscanon(uint32_t*); + + +/* Unicode normalization. */ +#define __UC_NFD 1 +#define __UC_NFKD 2 +#define __UC_NFC 3 +#define __UC_NFKC 4 +size_t __ucsnorm(uint32_t*, const uint32_t*, size_t, int); + + +/* Unicode collation. */ +struct __collation { + uint32_t hash; + size_t count; + const uint8_t *alternate; + const uint32_t *elements; +}; +size_t __ucsxfrm(uint32_t*, const uint32_t*, size_t, + const struct __collation*, size_t); +int __ucscoll(const uint32_t*, const uint32_t*, + const struct __collation*, size_t); + + +/* Various helper functions. */ +uint32_t __uchash(const uint32_t*, size_t); + + +#endif Modified: soc2014/ghostmansd/head/lib/libc/locale/xlocale_private.h ============================================================================== --- soc2014/ghostmansd/head/lib/libc/locale/xlocale_private.h Fri Aug 1 23:45:50 2014 (r271722) +++ soc2014/ghostmansd/head/lib/libc/locale/xlocale_private.h Sat Aug 2 00:50:32 2014 (r271723) @@ -39,6 +39,9 @@ #include #include #include "setlocale.h" +#ifdef _UNICODE_SOURCE +#include +#endif enum { XLC_COLLATE = 0, @@ -85,6 +88,11 @@ struct xlocale_refcounted header; /** Components for the locale. */ struct xlocale_component *components[XLC_LAST]; +#ifdef _UNICODE_SOURCE + /** Collation table (NULL means DUCET). */ + size_t collsize; + struct __collation *colltable; +#endif /** Flag indicating if components[XLC_MONETARY] has changed since the * last call to localeconv_l() with this locale. */ int monetary_locale_changed; Modified: soc2014/ghostmansd/head/lib/libc/string/wcscoll.c ============================================================================== --- soc2014/ghostmansd/head/lib/libc/string/wcscoll.c Fri Aug 1 23:45:50 2014 (r271722) +++ soc2014/ghostmansd/head/lib/libc/string/wcscoll.c Sat Aug 2 00:50:32 2014 (r271723) @@ -7,6 +7,9 @@ * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * + * Copyright (c) 2014 Dmitry Selyutin. + * All rights reserved. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -37,17 +40,46 @@ #include #include #include "collate.h" +#ifdef _UNICODE_SOURCE +#include +#endif -static char *__mbsdup(const wchar_t *); +#ifndef _UNICODE_SOURCE +static char * +__mbsdup(const wchar_t *ws) +{ + static const mbstate_t initial; + mbstate_t st; + const wchar_t *wcp; + size_t len; + char *mbs; + + wcp = ws; + st = initial; + if ((len = wcsrtombs(NULL, &wcp, 0, &st)) == (size_t)-1) + return (NULL); + if ((mbs = malloc(len + 1)) == NULL) + return (NULL); + st = initial; + wcsrtombs(mbs, &ws, len + 1, &st); + + return (mbs); +} +#endif -/* - * Placeholder implementation of wcscoll(). Attempts to use the single-byte - * collation ordering where possible, and falls back on wcscmp() in locales - * with extended character sets. - */ int wcscoll_l(const wchar_t *ws1, const wchar_t *ws2, locale_t locale) { +#ifdef _UNICODE_SOURCE + const __unichar_t *ucs1 = (const __unichar_t*)ws1; + const __unichar_t *ucs2 = (const __unichar_t*)ws2; + const struct __collation *table = + (const struct __collation*)locale->colltable; + size_t count = locale->collsize; + + return __ucscoll(ucs1, ucs2, table, size); + +#else /* !_UNICODE_SOURCE */ char *mbs1, *mbs2; int diff, sverrno; FIX_LOCALE(locale); @@ -82,6 +114,7 @@ errno = sverrno; return (diff); +#endif } int @@ -89,24 +122,3 @@ { return wcscoll_l(ws1, ws2, __get_locale()); } - -static char * -__mbsdup(const wchar_t *ws) -{ - static const mbstate_t initial; - mbstate_t st; - const wchar_t *wcp; - size_t len; - char *mbs; - - wcp = ws; - st = initial; - if ((len = wcsrtombs(NULL, &wcp, 0, &st)) == (size_t)-1) - return (NULL); - if ((mbs = malloc(len + 1)) == NULL) - return (NULL); - st = initial; - wcsrtombs(mbs, &ws, len + 1, &st); - - return (mbs); -} Added: soc2014/ghostmansd/head/lib/libc/unicode/ccclass.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2014/ghostmansd/head/lib/libc/unicode/ccclass.h Sat Aug 2 00:50:32 2014 (r271723) @@ -0,0 +1,227 @@ +/*- + * Copyright (c) 2014 Dmitry Selyutin. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DECOMPOSITION, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + + +#define COMBINING_CLASS_MIN 0x000300 +#define COMBINING_CLASS_MAX 0x01E8D6 +#define COMBINING_CLASS_COUNT 745 + + +static const struct { + uint32_t const code : 24; + uint32_t const ccclass : 8; +} combining_class[COMBINING_CLASS_COUNT + 1] = { + {0x000300, 0xE6}, {0x000301, 0xE6}, {0x000302, 0xE6}, {0x000303, 0xE6}, + {0x000304, 0xE6}, {0x000305, 0xE6}, {0x000306, 0xE6}, {0x000307, 0xE6}, + {0x000308, 0xE6}, {0x000309, 0xE6}, {0x00030A, 0xE6}, {0x00030B, 0xE6}, + {0x00030C, 0xE6}, {0x00030D, 0xE6}, {0x00030E, 0xE6}, {0x00030F, 0xE6}, + {0x000310, 0xE6}, {0x000311, 0xE6}, {0x000312, 0xE6}, {0x000313, 0xE6}, + {0x000314, 0xE6}, {0x000315, 0xE8}, {0x000316, 0xDC}, {0x000317, 0xDC}, + {0x000318, 0xDC}, {0x000319, 0xDC}, {0x00031A, 0xE8}, {0x00031B, 0xD8}, + {0x00031C, 0xDC}, {0x00031D, 0xDC}, {0x00031E, 0xDC}, {0x00031F, 0xDC}, + {0x000320, 0xDC}, {0x000321, 0xCA}, {0x000322, 0xCA}, {0x000323, 0xDC}, + {0x000324, 0xDC}, {0x000325, 0xDC}, {0x000326, 0xDC}, {0x000327, 0xCA}, + {0x000328, 0xCA}, {0x000329, 0xDC}, {0x00032A, 0xDC}, {0x00032B, 0xDC}, + {0x00032C, 0xDC}, {0x00032D, 0xDC}, {0x00032E, 0xDC}, {0x00032F, 0xDC}, + {0x000330, 0xDC}, {0x000331, 0xDC}, {0x000332, 0xDC}, {0x000333, 0xDC}, + {0x000334, 0x01}, {0x000335, 0x01}, {0x000336, 0x01}, {0x000337, 0x01}, + {0x000338, 0x01}, {0x000339, 0xDC}, {0x00033A, 0xDC}, {0x00033B, 0xDC}, + {0x00033C, 0xDC}, {0x00033D, 0xE6}, {0x00033E, 0xE6}, {0x00033F, 0xE6}, + {0x000340, 0xE6}, {0x000341, 0xE6}, {0x000342, 0xE6}, {0x000343, 0xE6}, + {0x000344, 0xE6}, {0x000345, 0xF0}, {0x000346, 0xE6}, {0x000347, 0xDC}, + {0x000348, 0xDC}, {0x000349, 0xDC}, {0x00034A, 0xE6}, {0x00034B, 0xE6}, + {0x00034C, 0xE6}, {0x00034D, 0xDC}, {0x00034E, 0xDC}, {0x000350, 0xE6}, + {0x000351, 0xE6}, {0x000352, 0xE6}, {0x000353, 0xDC}, {0x000354, 0xDC}, + {0x000355, 0xDC}, {0x000356, 0xDC}, {0x000357, 0xE6}, {0x000358, 0xE8}, + {0x000359, 0xDC}, {0x00035A, 0xDC}, {0x00035B, 0xE6}, {0x00035C, 0xE9}, + {0x00035D, 0xEA}, {0x00035E, 0xEA}, {0x00035F, 0xE9}, {0x000360, 0xEA}, + {0x000361, 0xEA}, {0x000362, 0xE9}, {0x000363, 0xE6}, {0x000364, 0xE6}, + {0x000365, 0xE6}, {0x000366, 0xE6}, {0x000367, 0xE6}, {0x000368, 0xE6}, + {0x000369, 0xE6}, {0x00036A, 0xE6}, {0x00036B, 0xE6}, {0x00036C, 0xE6}, + {0x00036D, 0xE6}, {0x00036E, 0xE6}, {0x00036F, 0xE6}, {0x000483, 0xE6}, + {0x000484, 0xE6}, {0x000485, 0xE6}, {0x000486, 0xE6}, {0x000487, 0xE6}, + {0x000591, 0xDC}, {0x000592, 0xE6}, {0x000593, 0xE6}, {0x000594, 0xE6}, + {0x000595, 0xE6}, {0x000596, 0xDC}, {0x000597, 0xE6}, {0x000598, 0xE6}, + {0x000599, 0xE6}, {0x00059A, 0xDE}, {0x00059B, 0xDC}, {0x00059C, 0xE6}, + {0x00059D, 0xE6}, {0x00059E, 0xE6}, {0x00059F, 0xE6}, {0x0005A0, 0xE6}, + {0x0005A1, 0xE6}, {0x0005A2, 0xDC}, {0x0005A3, 0xDC}, {0x0005A4, 0xDC}, + {0x0005A5, 0xDC}, {0x0005A6, 0xDC}, {0x0005A7, 0xDC}, {0x0005A8, 0xE6}, + {0x0005A9, 0xE6}, {0x0005AA, 0xDC}, {0x0005AB, 0xE6}, {0x0005AC, 0xE6}, + {0x0005AD, 0xDE}, {0x0005AE, 0xE4}, {0x0005AF, 0xE6}, {0x0005B0, 0x0A}, + {0x0005B1, 0x0B}, {0x0005B2, 0x0C}, {0x0005B3, 0x0D}, {0x0005B4, 0x0E}, + {0x0005B5, 0x0F}, {0x0005B6, 0x10}, {0x0005B7, 0x11}, {0x0005B8, 0x12}, + {0x0005B9, 0x13}, {0x0005BA, 0x13}, {0x0005BB, 0x14}, {0x0005BC, 0x15}, + {0x0005BD, 0x16}, {0x0005BF, 0x17}, {0x0005C1, 0x18}, {0x0005C2, 0x19}, + {0x0005C4, 0xE6}, {0x0005C5, 0xDC}, {0x0005C7, 0x12}, {0x000610, 0xE6}, + {0x000611, 0xE6}, {0x000612, 0xE6}, {0x000613, 0xE6}, {0x000614, 0xE6}, + {0x000615, 0xE6}, {0x000616, 0xE6}, {0x000617, 0xE6}, {0x000618, 0x1E}, + {0x000619, 0x1F}, {0x00061A, 0x20}, {0x00064B, 0x1B}, {0x00064C, 0x1C}, + {0x00064D, 0x1D}, {0x00064E, 0x1E}, {0x00064F, 0x1F}, {0x000650, 0x20}, + {0x000651, 0x21}, {0x000652, 0x22}, {0x000653, 0xE6}, {0x000654, 0xE6}, + {0x000655, 0xDC}, {0x000656, 0xDC}, {0x000657, 0xE6}, {0x000658, 0xE6}, + {0x000659, 0xE6}, {0x00065A, 0xE6}, {0x00065B, 0xE6}, {0x00065C, 0xDC}, + {0x00065D, 0xE6}, {0x00065E, 0xE6}, {0x00065F, 0xDC}, {0x000670, 0x23}, + {0x0006D6, 0xE6}, {0x0006D7, 0xE6}, {0x0006D8, 0xE6}, {0x0006D9, 0xE6}, + {0x0006DA, 0xE6}, {0x0006DB, 0xE6}, {0x0006DC, 0xE6}, {0x0006DF, 0xE6}, + {0x0006E0, 0xE6}, {0x0006E1, 0xE6}, {0x0006E2, 0xE6}, {0x0006E3, 0xDC}, + {0x0006E4, 0xE6}, {0x0006E7, 0xE6}, {0x0006E8, 0xE6}, {0x0006EA, 0xDC}, + {0x0006EB, 0xE6}, {0x0006EC, 0xE6}, {0x0006ED, 0xDC}, {0x000711, 0x24}, + {0x000730, 0xE6}, {0x000731, 0xDC}, {0x000732, 0xE6}, {0x000733, 0xE6}, + {0x000734, 0xDC}, {0x000735, 0xE6}, {0x000736, 0xE6}, {0x000737, 0xDC}, + {0x000738, 0xDC}, {0x000739, 0xDC}, {0x00073A, 0xE6}, {0x00073B, 0xDC}, + {0x00073C, 0xDC}, {0x00073D, 0xE6}, {0x00073E, 0xDC}, {0x00073F, 0xE6}, + {0x000740, 0xE6}, {0x000741, 0xE6}, {0x000742, 0xDC}, {0x000743, 0xE6}, + {0x000744, 0xDC}, {0x000745, 0xE6}, {0x000746, 0xDC}, {0x000747, 0xE6}, + {0x000748, 0xDC}, {0x000749, 0xE6}, {0x00074A, 0xE6}, {0x0007EB, 0xE6}, + {0x0007EC, 0xE6}, {0x0007ED, 0xE6}, {0x0007EE, 0xE6}, {0x0007EF, 0xE6}, + {0x0007F0, 0xE6}, {0x0007F1, 0xE6}, {0x0007F2, 0xDC}, {0x0007F3, 0xE6}, + {0x000816, 0xE6}, {0x000817, 0xE6}, {0x000818, 0xE6}, {0x000819, 0xE6}, + {0x00081B, 0xE6}, {0x00081C, 0xE6}, {0x00081D, 0xE6}, {0x00081E, 0xE6}, + {0x00081F, 0xE6}, {0x000820, 0xE6}, {0x000821, 0xE6}, {0x000822, 0xE6}, + {0x000823, 0xE6}, {0x000825, 0xE6}, {0x000826, 0xE6}, {0x000827, 0xE6}, + {0x000829, 0xE6}, {0x00082A, 0xE6}, {0x00082B, 0xE6}, {0x00082C, 0xE6}, + {0x00082D, 0xE6}, {0x000859, 0xDC}, {0x00085A, 0xDC}, {0x00085B, 0xDC}, + {0x0008E4, 0xE6}, {0x0008E5, 0xE6}, {0x0008E6, 0xDC}, {0x0008E7, 0xE6}, + {0x0008E8, 0xE6}, {0x0008E9, 0xDC}, {0x0008EA, 0xE6}, {0x0008EB, 0xE6}, + {0x0008EC, 0xE6}, {0x0008ED, 0xDC}, {0x0008EE, 0xDC}, {0x0008EF, 0xDC}, + {0x0008F0, 0x1B}, {0x0008F1, 0x1C}, {0x0008F2, 0x1D}, {0x0008F3, 0xE6}, + {0x0008F4, 0xE6}, {0x0008F5, 0xE6}, {0x0008F6, 0xDC}, {0x0008F7, 0xE6}, + {0x0008F8, 0xE6}, {0x0008F9, 0xDC}, {0x0008FA, 0xDC}, {0x0008FB, 0xE6}, + {0x0008FC, 0xE6}, {0x0008FD, 0xE6}, {0x0008FE, 0xE6}, {0x0008FF, 0xE6}, + {0x00093C, 0x07}, {0x00094D, 0x09}, {0x000951, 0xE6}, {0x000952, 0xDC}, + {0x000953, 0xE6}, {0x000954, 0xE6}, {0x0009BC, 0x07}, {0x0009CD, 0x09}, + {0x000A3C, 0x07}, {0x000A4D, 0x09}, {0x000ABC, 0x07}, {0x000ACD, 0x09}, + {0x000B3C, 0x07}, {0x000B4D, 0x09}, {0x000BCD, 0x09}, {0x000C4D, 0x09}, + {0x000C55, 0x54}, {0x000C56, 0x5B}, {0x000CBC, 0x07}, {0x000CCD, 0x09}, + {0x000D4D, 0x09}, {0x000DCA, 0x09}, {0x000E38, 0x67}, {0x000E39, 0x67}, + {0x000E3A, 0x09}, {0x000E48, 0x6B}, {0x000E49, 0x6B}, {0x000E4A, 0x6B}, + {0x000E4B, 0x6B}, {0x000EB8, 0x76}, {0x000EB9, 0x76}, {0x000EC8, 0x7A}, + {0x000EC9, 0x7A}, {0x000ECA, 0x7A}, {0x000ECB, 0x7A}, {0x000F18, 0xDC}, + {0x000F19, 0xDC}, {0x000F35, 0xDC}, {0x000F37, 0xDC}, {0x000F39, 0xD8}, + {0x000F71, 0x81}, {0x000F72, 0x82}, {0x000F74, 0x84}, {0x000F7A, 0x82}, + {0x000F7B, 0x82}, {0x000F7C, 0x82}, {0x000F7D, 0x82}, {0x000F80, 0x82}, + {0x000F82, 0xE6}, {0x000F83, 0xE6}, {0x000F84, 0x09}, {0x000F86, 0xE6}, + {0x000F87, 0xE6}, {0x000FC6, 0xDC}, {0x001037, 0x07}, {0x001039, 0x09}, + {0x00103A, 0x09}, {0x00108D, 0xDC}, {0x00135D, 0xE6}, {0x00135E, 0xE6}, + {0x00135F, 0xE6}, {0x001714, 0x09}, {0x001734, 0x09}, {0x0017D2, 0x09}, + {0x0017DD, 0xE6}, {0x0018A9, 0xE4}, {0x001939, 0xDE}, {0x00193A, 0xE6}, + {0x00193B, 0xDC}, {0x001A17, 0xE6}, {0x001A18, 0xDC}, {0x001A60, 0x09}, + {0x001A75, 0xE6}, {0x001A76, 0xE6}, {0x001A77, 0xE6}, {0x001A78, 0xE6}, + {0x001A79, 0xE6}, {0x001A7A, 0xE6}, {0x001A7B, 0xE6}, {0x001A7C, 0xE6}, + {0x001A7F, 0xDC}, {0x001AB0, 0xE6}, {0x001AB1, 0xE6}, {0x001AB2, 0xE6}, + {0x001AB3, 0xE6}, {0x001AB4, 0xE6}, {0x001AB5, 0xDC}, {0x001AB6, 0xDC}, + {0x001AB7, 0xDC}, {0x001AB8, 0xDC}, {0x001AB9, 0xDC}, {0x001ABA, 0xDC}, + {0x001ABB, 0xE6}, {0x001ABC, 0xE6}, {0x001ABD, 0xDC}, {0x001B34, 0x07}, + {0x001B44, 0x09}, {0x001B6B, 0xE6}, {0x001B6C, 0xDC}, {0x001B6D, 0xE6}, + {0x001B6E, 0xE6}, {0x001B6F, 0xE6}, {0x001B70, 0xE6}, {0x001B71, 0xE6}, + {0x001B72, 0xE6}, {0x001B73, 0xE6}, {0x001BAA, 0x09}, {0x001BAB, 0x09}, + {0x001BE6, 0x07}, {0x001BF2, 0x09}, {0x001BF3, 0x09}, {0x001C37, 0x07}, + {0x001CD0, 0xE6}, {0x001CD1, 0xE6}, {0x001CD2, 0xE6}, {0x001CD4, 0x01}, + {0x001CD5, 0xDC}, {0x001CD6, 0xDC}, {0x001CD7, 0xDC}, {0x001CD8, 0xDC}, + {0x001CD9, 0xDC}, {0x001CDA, 0xE6}, {0x001CDB, 0xE6}, {0x001CDC, 0xDC}, + {0x001CDD, 0xDC}, {0x001CDE, 0xDC}, {0x001CDF, 0xDC}, {0x001CE0, 0xE6}, + {0x001CE2, 0x01}, {0x001CE3, 0x01}, {0x001CE4, 0x01}, {0x001CE5, 0x01}, + {0x001CE6, 0x01}, {0x001CE7, 0x01}, {0x001CE8, 0x01}, {0x001CED, 0xDC}, + {0x001CF4, 0xE6}, {0x001CF8, 0xE6}, {0x001CF9, 0xE6}, {0x001DC0, 0xE6}, + {0x001DC1, 0xE6}, {0x001DC2, 0xDC}, {0x001DC3, 0xE6}, {0x001DC4, 0xE6}, + {0x001DC5, 0xE6}, {0x001DC6, 0xE6}, {0x001DC7, 0xE6}, {0x001DC8, 0xE6}, + {0x001DC9, 0xE6}, {0x001DCA, 0xDC}, {0x001DCB, 0xE6}, {0x001DCC, 0xE6}, + {0x001DCD, 0xEA}, {0x001DCE, 0xD6}, {0x001DCF, 0xDC}, {0x001DD0, 0xCA}, + {0x001DD1, 0xE6}, {0x001DD2, 0xE6}, {0x001DD3, 0xE6}, {0x001DD4, 0xE6}, + {0x001DD5, 0xE6}, {0x001DD6, 0xE6}, {0x001DD7, 0xE6}, {0x001DD8, 0xE6}, + {0x001DD9, 0xE6}, {0x001DDA, 0xE6}, {0x001DDB, 0xE6}, {0x001DDC, 0xE6}, + {0x001DDD, 0xE6}, {0x001DDE, 0xE6}, {0x001DDF, 0xE6}, {0x001DE0, 0xE6}, + {0x001DE1, 0xE6}, {0x001DE2, 0xE6}, {0x001DE3, 0xE6}, {0x001DE4, 0xE6}, + {0x001DE5, 0xE6}, {0x001DE6, 0xE6}, {0x001DE7, 0xE6}, {0x001DE8, 0xE6}, + {0x001DE9, 0xE6}, {0x001DEA, 0xE6}, {0x001DEB, 0xE6}, {0x001DEC, 0xE6}, + {0x001DED, 0xE6}, {0x001DEE, 0xE6}, {0x001DEF, 0xE6}, {0x001DF0, 0xE6}, + {0x001DF1, 0xE6}, {0x001DF2, 0xE6}, {0x001DF3, 0xE6}, {0x001DF4, 0xE6}, + {0x001DF5, 0xE6}, {0x001DFC, 0xE9}, {0x001DFD, 0xDC}, {0x001DFE, 0xE6}, + {0x001DFF, 0xDC}, {0x0020D0, 0xE6}, {0x0020D1, 0xE6}, {0x0020D2, 0x01}, + {0x0020D3, 0x01}, {0x0020D4, 0xE6}, {0x0020D5, 0xE6}, {0x0020D6, 0xE6}, + {0x0020D7, 0xE6}, {0x0020D8, 0x01}, {0x0020D9, 0x01}, {0x0020DA, 0x01}, + {0x0020DB, 0xE6}, {0x0020DC, 0xE6}, {0x0020E1, 0xE6}, {0x0020E5, 0x01}, + {0x0020E6, 0x01}, {0x0020E7, 0xE6}, {0x0020E8, 0xDC}, {0x0020E9, 0xE6}, + {0x0020EA, 0x01}, {0x0020EB, 0x01}, {0x0020EC, 0xDC}, {0x0020ED, 0xDC}, + {0x0020EE, 0xDC}, {0x0020EF, 0xDC}, {0x0020F0, 0xE6}, {0x002CEF, 0xE6}, + {0x002CF0, 0xE6}, {0x002CF1, 0xE6}, {0x002D7F, 0x09}, {0x002DE0, 0xE6}, + {0x002DE1, 0xE6}, {0x002DE2, 0xE6}, {0x002DE3, 0xE6}, {0x002DE4, 0xE6}, + {0x002DE5, 0xE6}, {0x002DE6, 0xE6}, {0x002DE7, 0xE6}, {0x002DE8, 0xE6}, + {0x002DE9, 0xE6}, {0x002DEA, 0xE6}, {0x002DEB, 0xE6}, {0x002DEC, 0xE6}, + {0x002DED, 0xE6}, {0x002DEE, 0xE6}, {0x002DEF, 0xE6}, {0x002DF0, 0xE6}, + {0x002DF1, 0xE6}, {0x002DF2, 0xE6}, {0x002DF3, 0xE6}, {0x002DF4, 0xE6}, + {0x002DF5, 0xE6}, {0x002DF6, 0xE6}, {0x002DF7, 0xE6}, {0x002DF8, 0xE6}, + {0x002DF9, 0xE6}, {0x002DFA, 0xE6}, {0x002DFB, 0xE6}, {0x002DFC, 0xE6}, + {0x002DFD, 0xE6}, {0x002DFE, 0xE6}, {0x002DFF, 0xE6}, {0x00302A, 0xDA}, + {0x00302B, 0xE4}, {0x00302C, 0xE8}, {0x00302D, 0xDE}, {0x00302E, 0xE0}, + {0x00302F, 0xE0}, {0x003099, 0x08}, {0x00309A, 0x08}, {0x00A66F, 0xE6}, + {0x00A674, 0xE6}, {0x00A675, 0xE6}, {0x00A676, 0xE6}, {0x00A677, 0xE6}, + {0x00A678, 0xE6}, {0x00A679, 0xE6}, {0x00A67A, 0xE6}, {0x00A67B, 0xE6}, + {0x00A67C, 0xE6}, {0x00A67D, 0xE6}, {0x00A69F, 0xE6}, {0x00A6F0, 0xE6}, + {0x00A6F1, 0xE6}, {0x00A806, 0x09}, {0x00A8C4, 0x09}, {0x00A8E0, 0xE6}, + {0x00A8E1, 0xE6}, {0x00A8E2, 0xE6}, {0x00A8E3, 0xE6}, {0x00A8E4, 0xE6}, + {0x00A8E5, 0xE6}, {0x00A8E6, 0xE6}, {0x00A8E7, 0xE6}, {0x00A8E8, 0xE6}, + {0x00A8E9, 0xE6}, {0x00A8EA, 0xE6}, {0x00A8EB, 0xE6}, {0x00A8EC, 0xE6}, + {0x00A8ED, 0xE6}, {0x00A8EE, 0xE6}, {0x00A8EF, 0xE6}, {0x00A8F0, 0xE6}, + {0x00A8F1, 0xE6}, {0x00A92B, 0xDC}, {0x00A92C, 0xDC}, {0x00A92D, 0xDC}, + {0x00A953, 0x09}, {0x00A9B3, 0x07}, {0x00A9C0, 0x09}, {0x00AAB0, 0xE6}, + {0x00AAB2, 0xE6}, {0x00AAB3, 0xE6}, {0x00AAB4, 0xDC}, {0x00AAB7, 0xE6}, + {0x00AAB8, 0xE6}, {0x00AABE, 0xE6}, {0x00AABF, 0xE6}, {0x00AAC1, 0xE6}, + {0x00AAF6, 0x09}, {0x00ABED, 0x09}, {0x00FB1E, 0x1A}, {0x00FE20, 0xE6}, + {0x00FE21, 0xE6}, {0x00FE22, 0xE6}, {0x00FE23, 0xE6}, {0x00FE24, 0xE6}, + {0x00FE25, 0xE6}, {0x00FE26, 0xE6}, {0x00FE27, 0xDC}, {0x00FE28, 0xDC}, + {0x00FE29, 0xDC}, {0x00FE2A, 0xDC}, {0x00FE2B, 0xDC}, {0x00FE2C, 0xDC}, + {0x00FE2D, 0xDC}, {0x0101FD, 0xDC}, {0x0102E0, 0xDC}, {0x010376, 0xE6}, + {0x010377, 0xE6}, {0x010378, 0xE6}, {0x010379, 0xE6}, {0x01037A, 0xE6}, + {0x010A0D, 0xDC}, {0x010A0F, 0xE6}, {0x010A38, 0xE6}, {0x010A39, 0x01}, + {0x010A3A, 0xDC}, {0x010A3F, 0x09}, {0x010AE5, 0xE6}, {0x010AE6, 0xDC}, + {0x011046, 0x09}, {0x01107F, 0x09}, {0x0110B9, 0x09}, {0x0110BA, 0x07}, + {0x011100, 0xE6}, {0x011101, 0xE6}, {0x011102, 0xE6}, {0x011133, 0x09}, + {0x011134, 0x09}, {0x011173, 0x07}, {0x0111C0, 0x09}, {0x011235, 0x09}, + {0x011236, 0x07}, {0x0112E9, 0x07}, {0x0112EA, 0x09}, {0x01133C, 0x07}, + {0x01134D, 0x09}, {0x011366, 0xE6}, {0x011367, 0xE6}, {0x011368, 0xE6}, + {0x011369, 0xE6}, {0x01136A, 0xE6}, {0x01136B, 0xE6}, {0x01136C, 0xE6}, + {0x011370, 0xE6}, {0x011371, 0xE6}, {0x011372, 0xE6}, {0x011373, 0xE6}, + {0x011374, 0xE6}, {0x0114C2, 0x09}, {0x0114C3, 0x07}, {0x0115BF, 0x09}, + {0x0115C0, 0x07}, {0x01163F, 0x09}, {0x0116B6, 0x09}, {0x0116B7, 0x07}, + {0x016AF0, 0x01}, {0x016AF1, 0x01}, {0x016AF2, 0x01}, {0x016AF3, 0x01}, + {0x016AF4, 0x01}, {0x016B30, 0xE6}, {0x016B31, 0xE6}, {0x016B32, 0xE6}, + {0x016B33, 0xE6}, {0x016B34, 0xE6}, {0x016B35, 0xE6}, {0x016B36, 0xE6}, + {0x01BC9E, 0x01}, {0x01D165, 0xD8}, {0x01D166, 0xD8}, {0x01D167, 0x01}, + {0x01D168, 0x01}, {0x01D169, 0x01}, {0x01D16D, 0xE2}, {0x01D16E, 0xD8}, + {0x01D16F, 0xD8}, {0x01D170, 0xD8}, {0x01D171, 0xD8}, {0x01D172, 0xD8}, + {0x01D17B, 0xDC}, {0x01D17C, 0xDC}, {0x01D17D, 0xDC}, {0x01D17E, 0xDC}, + {0x01D17F, 0xDC}, {0x01D180, 0xDC}, {0x01D181, 0xDC}, {0x01D182, 0xDC}, + {0x01D185, 0xE6}, {0x01D186, 0xE6}, {0x01D187, 0xE6}, {0x01D188, 0xE6}, + {0x01D189, 0xE6}, {0x01D18A, 0xDC}, {0x01D18B, 0xDC}, {0x01D1AA, 0xE6}, + {0x01D1AB, 0xE6}, {0x01D1AC, 0xE6}, {0x01D1AD, 0xE6}, {0x01D242, 0xE6}, + {0x01D243, 0xE6}, {0x01D244, 0xE6}, {0x01E8D0, 0xDC}, {0x01E8D1, 0xDC}, + {0x01E8D2, 0xDC}, {0x01E8D3, 0xDC}, {0x01E8D4, 0xDC}, {0x01E8D5, 0xDC}, + {0x01E8D6, 0xDC}, + {(COMBINING_CLASS_MAX + 1), UINT8_MAX} +}; Added: soc2014/ghostmansd/head/lib/libc/unicode/ducet.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2014/ghostmansd/head/lib/libc/unicode/ducet.h Sat Aug 2 00:50:32 2014 (r271723) @@ -0,0 +1,43838 @@ +/*- + * Copyright (c) 2014 Dmitry Selyutin. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DECOMPOSITION, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + + +#define DUCET_MAX 0xFFF99024 +#define DUCET_SIZE 27978 +#define DUCET_SEQ_MAX 3 + + +static const uint8_t ducet_alternate[] = { + 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 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1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, + 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, + 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Sat Aug 2 06:02:14 2014 Return-Path: Delivered-To: svn-soc-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2F1A558E; Sat, 2 Aug 2014 06:02:14 +0000 (UTC) Received: from freebsd.czest.pl (freebsd.czest.pl [212.87.224.105]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 61DA52F76; Sat, 2 Aug 2014 06:02:10 +0000 (UTC) Received-SPF: pass (freebsd.czest.pl: domain of wkoszek@freebsd.czest.pl designates 212.87.224.105 as permitted sender) receiver=freebsd.czest.pl; client-ip=212.87.224.105; helo=freebsd.czest.pl; envelope-from=wkoszek@freebsd.czest.pl; x-software=spfmilter 0.97 http://www.acme.com/software/spfmilter/ with libspf-unknown; Received: from freebsd.czest.pl (freebsd.czest.pl [212.87.224.105]) by freebsd.czest.pl (8.14.5/8.14.5) with ESMTP id s725b8Dm022960; Sat, 2 Aug 2014 05:37:08 GMT (envelope-from wkoszek@freebsd.czest.pl) Received: (from wkoszek@localhost) by freebsd.czest.pl (8.14.5/8.14.5/Submit) id s725b8sX022959; Sat, 2 Aug 2014 05:37:08 GMT (envelope-from wkoszek) Date: Sat, 2 Aug 2014 05:37:08 +0000 From: "Wojciech A. Koszek" To: pedrosouza@freebsd.org Subject: Re: socsvn commit: r271623 - soc2014/pedrosouza/lua_loader/head/sys/boot/lua Message-ID: <20140802053708.GB98217@FreeBSD.org> References: <201407301950.s6UJovS1023444@socsvn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <201407301950.s6UJovS1023444@socsvn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on freebsd.czest.pl X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.7 (freebsd.czest.pl [212.87.224.105]); Sat, 02 Aug 2014 05:37:12 +0000 (UTC) Cc: svn-soc-all@freebsd.org X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Aug 2014 06:02:14 -0000 On Wed, Jul 30, 2014 at 07:50:57PM +0000, pedrosouza@freebsd.org wrote: > Author: pedrosouza > Date: Wed Jul 30 19:50:56 2014 > New Revision: 271623 > URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271623 > > Log: > Added boot menu shortcuts > Pedro, I walked through all your last commits. All your work looks pretty good. I don't see anything fundamentally wrong in code your wrote. If I were to give feedback, in the order of priority: The most crucial part would be to make sure password checking can't be ommited. Thus we should try to do rigorous testing there. We should also check if by doing strange things we can crash the Lua in a way that would skip password checking. Make sure we catch all exceptions and error conditions there. To make this code easily mergable, we should probably target src/sys/lua/. This way you can make 'lua*' utilities available to users. Alternatively: src/sys/contrib/lua/. It should be plain Lua source code, so that upgrading to new Luas as they get released would be as simple as unpacking the .tar.bz2 there. The FreeBSD wrapper for Lua loader could live in src/sys/boot/lua. Think whether you also feel 80x25 rule for Lua code should be preserved. At some point we could also start lua.style.8 man page. Thanks for all this work. It's nice to see coming nicely along. Wojciech > Modified: > soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua > soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua > > Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua > ============================================================================== > --- soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua Wed Jul 30 18:47:31 2014 (r271622) > +++ soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua Wed Jul 30 19:50:56 2014 (r271623) > @@ -8,13 +8,16 @@ > screen.setcursor(x, y); > print("Boot Menu"); > for k, v in pairs(opts) do > - screen.setcursor(x, y + v.index); > - local name = v.name; > - > - if (name == nil) then > - name = v.getName(); > + -- skip alias > + if k ~= "alias" then > + screen.setcursor(x, y + v.index); > + local name = v.name; > + > + if (name == nil) then > + name = v.getName(); > + end > + print(k .. " - " .. name); > end > - print(k .. " - " .. name); > end > end > > @@ -29,6 +32,7 @@ > menu.drawbox(4, 10, 40, 10); > drawer.drawbrand(); > drawer.drawlogo(); > + screen.defcursor(); > local ch = string.char(io.getchar()); > if (opts[ch] ~= nil) then > local ret = opts[ch].func(); > @@ -36,6 +40,17 @@ > print("Exiting menu!\n"); > return; > end > + else > + --try alias key > + if opts.alias ~= nil then > + if opts.alias[ch] ~= nil then > + local ret = opts.alias[ch].func(); > + if (ret) then > + print("Exiting menu!\n"); > + return; > + end > + end > + end > end > end > end > @@ -65,26 +80,39 @@ > end > > menu.options = { > - ["1"] = {index = 1, name = "Boot Multi user", func = function () core.setSingleUser(false); loader.perform("boot"); end}, > - ["2"] = {index = 2, name = "Boot Single user", func = function () core.setSingleUser(true); loader.perform("boot"); end}, > - ["3"] = {index = 3, name = "Escape to lua interpreter", func = function () return true; end}, > - ["4"] = {index = 4, name = "Reboot", func = function () loader.perform("reboot"); end}, > - ["5"] = {index = 5, name = "Boot Options", func = function () menu.run(boot_options); return false; end} > + -- Boot multi user > + ["1"] = {index = 1, name = color.highlight("B").."oot Multi user", func = function () core.setSingleUser(false); loader.perform("boot"); end}, > + -- boot single user > + ["2"] = {index = 2, name = "Boot "..color.highlight("S").."ingle user", func = function () core.setSingleUser(true); loader.perform("boot"); end}, > + -- escape to interpreter > + ["3"] = {index = 3, name = color.highlight("E").."scape to lua interpreter", func = function () return true; end}, > + -- reboot > + ["4"] = {index = 4, name = color.highlight("R").."eboot", func = function () loader.perform("reboot"); end}, > + -- boot options > + ["5"] = {index = 5, name = "Boot "..color.highlight("O").."ptions", func = function () menu.run(boot_options); return false; end} > +}; > + > +menu.options.alias = { > + ["b"] = menu.options["1"], > + ["s"] = menu.options["2"], > + ["e"] = menu.options["3"], > + ["r"] = menu.options["4"], > + ["o"] = menu.options["5"] > }; > > function OnOff(str, b) > if (b) then > - return str .. color.escapef(color.GREEN)..": On"..color.escapef(color.WHITE); > + return str .. color.escapef(color.GREEN).."On"..color.escapef(color.WHITE); > else > - return str .. color.escapef(color.RED)..": Off"..color.escapef(color.WHITE); > + return str .. color.escapef(color.RED).."Off"..color.escapef(color.WHITE); > end > end > > boot_options = { > ["1"] = {index = 1, name = "Back to menu", func = function () return true; end }, > ["2"] = {index = 2, name = "Load System defaults", func = function () core.setDefaults(); return false; end }, > - ["3"] = {index = 3, getName = function () return OnOff("ACPI ", core.acpi); end, func = function () core.setACPI(); return false; end }, > - ["4"] = {index = 4, getName = function () return OnOff("Safe Mode ", core.sm); end, func = function () core.setSafeMode(); return false; end }, > - ["5"] = {index = 5, getName = function () return OnOff("Single user", core.su); end, func = function () core.setSingleUser(); return false; end }, > - ["6"] = {index = 6, getName = function () return OnOff("Verbose ", core.verbose); end, func = function () core.setVerbose(); return false; end } > + ["3"] = {index = 3, getName = function () return OnOff("ACPI :", core.acpi); end, func = function () core.setACPI(); return false; end }, > + ["4"] = {index = 4, getName = function () return OnOff("Safe Mode :", core.sm); end, func = function () core.setSafeMode(); return false; end }, > + ["5"] = {index = 5, getName = function () return OnOff("Single user:", core.su); end, func = function () core.setSingleUser(); return false; end }, > + ["6"] = {index = 6, getName = function () return OnOff("Verbose :", core.verbose); end, func = function () core.setVerbose(); return false; end } > } > \ No newline at end of file > > Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua > ============================================================================== > --- soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua Wed Jul 30 18:47:31 2014 (r271622) > +++ soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua Wed Jul 30 19:50:56 2014 (r271623) > @@ -32,6 +32,10 @@ > return "\027[0;37;40m"; > end > > +function color.highlight(str) > + return "\027[1m"..str.."\027[0m"; > +end > + > function screen.clear() > print("\027[H\027[J"); > end > @@ -53,5 +57,5 @@ > end > > function screen.defcursor() > - print("\027[24;0H"); > + print("\027[25;0H"); > end > \ No newline at end of file > _______________________________________________ > svn-soc-all@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/svn-soc-all > To unsubscribe, send any mail to "svn-soc-all-unsubscribe@freebsd.org" -- Wojciech A. Koszek wkoszek@FreeBSD.czest.pl http://FreeBSD.czest.pl/~wkoszek/ From owner-svn-soc-all@FreeBSD.ORG Sat Aug 2 16:39:05 2014 Return-Path: Delivered-To: svn-soc-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B5BEB2B4; Sat, 2 Aug 2014 16:39:05 +0000 (UTC) Received: from mail-wi0-x233.google.com (mail-wi0-x233.google.com [IPv6:2a00:1450:400c:c05::233]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E25FA2223; Sat, 2 Aug 2014 16:39:04 +0000 (UTC) Received: by mail-wi0-f179.google.com with SMTP id f8so2835364wiw.0 for ; Sat, 02 Aug 2014 09:39:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=f/Xb0iFPH/FXNpQaeWrdJSGfSVIDMidDzmBbEFm5+3g=; b=bNmHdHIevkaWToZYvoEWkLBNbdRw8bUzDKzKZ3PPftTaoSSgdzO0/8SLzxV89hCgHH BMIGyDnISiPfB+M5QyYA1RnfGmOKzu6KCpcuhWC6wdwPkWb7ipl6dyCl9o6DUKMsiEd+ VntDl1AMX36JzYJvYtDmbsrXqFgWdJ08ocw+kD7q5yYgTQyu9mEh7cXXdbqqAfMWkEiV Ik36GrcGytu37vqL7KtLdExM02NmOF8BxvIwST+4KQsHTHyzx/Fbvr3GOU6E3Af6Odra mR8YI1iPwSbqBVIaus3aYs6S64HErBAhVHAhJ4DolGzaScshQ2zrpsPc0spkq7ly6Vyb mh6Q== MIME-Version: 1.0 X-Received: by 10.194.121.6 with SMTP id lg6mr18910531wjb.116.1406997543188; Sat, 02 Aug 2014 09:39:03 -0700 (PDT) Received: by 10.194.185.239 with HTTP; Sat, 2 Aug 2014 09:39:03 -0700 (PDT) In-Reply-To: <20140802053708.GB98217@FreeBSD.org> References: <201407301950.s6UJovS1023444@socsvn.freebsd.org> <20140802053708.GB98217@FreeBSD.org> Date: Sat, 2 Aug 2014 13:39:03 -0300 Message-ID: Subject: Re: socsvn commit: r271623 - soc2014/pedrosouza/lua_loader/head/sys/boot/lua From: Pedro Arthur To: "Wojciech A. Koszek" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18 Cc: svn-soc-all@freebsd.org, pedrosouza@freebsd.org X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Aug 2014 16:39:05 -0000 Thanks for the tips, I'll start checking the password code to not be bypassed. 2014-08-02 2:37 GMT-03:00 Wojciech A. Koszek : > On Wed, Jul 30, 2014 at 07:50:57PM +0000, pedrosouza@freebsd.org wrote: > > Author: pedrosouza > > Date: Wed Jul 30 19:50:56 2014 > > New Revision: 271623 > > URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271623 > > > > Log: > > Added boot menu shortcuts > > > > Pedro, > > I walked through all your last commits. > > All your work looks pretty good. I don't see anything fundamentally wrong > in > code your wrote. If I were to give feedback, in the order of priority: > > The most crucial part would be to make sure password checking can't be > ommited. Thus we should try to do rigorous testing there. We should also > check if by doing strange things we can crash the Lua in a way that would > skip password checking. Make sure we catch all exceptions and error > conditions there. > > To make this code easily mergable, we should probably target > src/sys/lua/. This way you can make 'lua*' utilities available to > users. Alternatively: src/sys/contrib/lua/. > > It should be plain Lua source code, so that upgrading to new Luas as they > get released would be as simple as unpacking the .tar.bz2 there. The > FreeBSD > wrapper for Lua loader could live in src/sys/boot/lua. > > Think whether you also feel 80x25 rule for Lua code should be preserved. At > some point we could also start lua.style.8 man page. > > Thanks for all this work. It's nice to see coming nicely along. > > Wojciech > > > Modified: > > soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua > > soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua > > > > Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua > > > ============================================================================== > > --- soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua Wed Jul 30 > 18:47:31 2014 (r271622) > > +++ soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua Wed Jul 30 > 19:50:56 2014 (r271623) > > @@ -8,13 +8,16 @@ > > screen.setcursor(x, y); > > print("Boot Menu"); > > for k, v in pairs(opts) do > > - screen.setcursor(x, y + v.index); > > - local name = v.name; > > - > > - if (name == nil) then > > - name = v.getName(); > > + -- skip alias > > + if k ~= "alias" then > > + screen.setcursor(x, y + v.index); > > + local name = v.name; > > + > > + if (name == nil) then > > + name = v.getName(); > > + end > > + print(k .. " - " .. name); > > end > > - print(k .. " - " .. name); > > end > > end > > > > @@ -29,6 +32,7 @@ > > menu.drawbox(4, 10, 40, 10); > > drawer.drawbrand(); > > drawer.drawlogo(); > > + screen.defcursor(); > > local ch = string.char(io.getchar()); > > if (opts[ch] ~= nil) then > > local ret = opts[ch].func(); > > @@ -36,6 +40,17 @@ > > print("Exiting menu!\n"); > > return; > > end > > + else > > + --try alias key > > + if opts.alias ~= nil then > > + if opts.alias[ch] ~= nil then > > + local ret = opts.alias[ch].func(); > > + if (ret) then > > + print("Exiting menu!\n"); > > + return; > > + end > > + end > > + end > > end > > end > > end > > @@ -65,26 +80,39 @@ > > end > > > > menu.options = { > > - ["1"] = {index = 1, name = "Boot Multi user", func = function > () core.setSingleUser(false); loader.perform("boot"); end}, > > - ["2"] = {index = 2, name = "Boot Single user", func = function > () core.setSingleUser(true); loader.perform("boot"); end}, > > - ["3"] = {index = 3, name = "Escape to lua interpreter", func = > function () return true; end}, > > - ["4"] = {index = 4, name = "Reboot", func = function > () loader.perform("reboot"); end}, > > - ["5"] = {index = 5, name = "Boot Options", func = function > () menu.run(boot_options); return false; end} > > + -- Boot multi user > > + ["1"] = {index = 1, name = color.highlight("B").."oot Multi user", > func = function () core.setSingleUser(false); loader.perform("boot"); end}, > > + -- boot single user > > + ["2"] = {index = 2, name = "Boot "..color.highlight("S").."ingle > user", func = function () core.setSingleUser(true); > loader.perform("boot"); end}, > > + -- escape to interpreter > > + ["3"] = {index = 3, name = color.highlight("E").."scape to lua > interpreter", func = function () return true; end}, > > + -- reboot > > + ["4"] = {index = 4, name = color.highlight("R").."eboot", func = > function () loader.perform("reboot"); end}, > > + -- boot options > > + ["5"] = {index = 5, name = "Boot "..color.highlight("O").."ptions", > func = function () menu.run(boot_options); return false; end} > > +}; > > + > > +menu.options.alias = { > > + ["b"] = menu.options["1"], > > + ["s"] = menu.options["2"], > > + ["e"] = menu.options["3"], > > + ["r"] = menu.options["4"], > > + ["o"] = menu.options["5"] > > }; > > > > function OnOff(str, b) > > if (b) then > > - return str .. color.escapef(color.GREEN)..": > On"..color.escapef(color.WHITE); > > + return str .. > color.escapef(color.GREEN).."On"..color.escapef(color.WHITE); > > else > > - return str .. color.escapef(color.RED)..": > Off"..color.escapef(color.WHITE); > > + return str .. > color.escapef(color.RED).."Off"..color.escapef(color.WHITE); > > end > > end > > > > boot_options = { > > ["1"] = {index = 1, name = "Back to menu", func = function () > return true; end }, > > ["2"] = {index = 2, name = "Load System defaults", func = function > () core.setDefaults(); return false; end }, > > - ["3"] = {index = 3, getName = function () return OnOff("ACPI > ", core.acpi); end, func = function () core.setACPI(); return false; end }, > > - ["4"] = {index = 4, getName = function () return OnOff("Safe Mode > ", core.sm); end, func = function () core.setSafeMode(); return false; > end }, > > - ["5"] = {index = 5, getName = function () return OnOff("Single > user", core.su); end, func = function () core.setSingleUser(); return > false; end }, > > - ["6"] = {index = 6, getName = function () return OnOff("Verbose > ", core.verbose); end, func = function () core.setVerbose(); return false; > end } > > + ["3"] = {index = 3, getName = function () return OnOff("ACPI > :", core.acpi); end, func = function () core.setACPI(); return false; end }, > > + ["4"] = {index = 4, getName = function () return OnOff("Safe Mode > :", core.sm); end, func = function () core.setSafeMode(); return > false; end }, > > + ["5"] = {index = 5, getName = function () return OnOff("Single > user:", core.su); end, func = function () core.setSingleUser(); return > false; end }, > > + ["6"] = {index = 6, getName = function () return OnOff("Verbose > :", core.verbose); end, func = function () core.setVerbose(); return > false; end } > > } > > \ No newline at end of file > > > > Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua > > > ============================================================================== > > --- soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua > Wed Jul 30 18:47:31 2014 (r271622) > > +++ soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua > Wed Jul 30 19:50:56 2014 (r271623) > > @@ -32,6 +32,10 @@ > > return "\027[0;37;40m"; > > end > > > > +function color.highlight(str) > > + return "\027[1m"..str.."\027[0m"; > > +end > > + > > function screen.clear() > > print("\027[H\027[J"); > > end > > @@ -53,5 +57,5 @@ > > end > > > > function screen.defcursor() > > - print("\027[24;0H"); > > + print("\027[25;0H"); > > end > > \ No newline at end of file > > _______________________________________________ > > svn-soc-all@freebsd.org mailing list > > http://lists.freebsd.org/mailman/listinfo/svn-soc-all > > To unsubscribe, send any mail to "svn-soc-all-unsubscribe@freebsd.org" > > -- > Wojciech A. Koszek > wkoszek@FreeBSD.czest.pl > http://FreeBSD.czest.pl/~wkoszek/ > From owner-svn-soc-all@FreeBSD.ORG Sat Aug 2 20:26:52 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2D810DF5 for ; Sat, 2 Aug 2014 20:26:52 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 18CE329A3 for ; Sat, 2 Aug 2014 20:26:52 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s72KQp2L094537 for ; Sat, 2 Aug 2014 20:26:51 GMT (envelope-from ghostmansd@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s72KQmOI094500 for svn-soc-all@FreeBSD.org; Sat, 2 Aug 2014 20:26:48 GMT (envelope-from ghostmansd@FreeBSD.org) Date: Sat, 2 Aug 2014 20:26:48 GMT Message-Id: <201408022026.s72KQmOI094500@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ghostmansd@FreeBSD.org using -f From: ghostmansd@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271756 - in soc2014/ghostmansd/head: include lib/libc/locale lib/libc/string lib/libc/unicode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Aug 2014 20:26:52 -0000 Author: ghostmansd Date: Sat Aug 2 20:26:48 2014 New Revision: 271756 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271756 Log: small reorganization according to Pedro's suggestion Deleted: soc2014/ghostmansd/head/include/unicode.h Modified: soc2014/ghostmansd/head/lib/libc/locale/xlocale_private.h soc2014/ghostmansd/head/lib/libc/string/wcscoll.c soc2014/ghostmansd/head/lib/libc/unicode/ccclass.h soc2014/ghostmansd/head/lib/libc/unicode/ducet.h soc2014/ghostmansd/head/lib/libc/unicode/norm.h soc2014/ghostmansd/head/lib/libc/unicode/uccclass.c soc2014/ghostmansd/head/lib/libc/unicode/uchash.c soc2014/ghostmansd/head/lib/libc/unicode/ucscanon.c soc2014/ghostmansd/head/lib/libc/unicode/ucscoll.c soc2014/ghostmansd/head/lib/libc/unicode/ucsnorm.c soc2014/ghostmansd/head/lib/libc/unicode/ucsxfrm.c Modified: soc2014/ghostmansd/head/lib/libc/locale/xlocale_private.h ============================================================================== --- soc2014/ghostmansd/head/lib/libc/locale/xlocale_private.h Sat Aug 2 19:59:19 2014 (r271755) +++ soc2014/ghostmansd/head/lib/libc/locale/xlocale_private.h Sat Aug 2 20:26:48 2014 (r271756) @@ -39,10 +39,39 @@ #include #include #include "setlocale.h" + + #ifdef _UNICODE_SOURCE -#include +#include + +/* Unicode canonicalization. */ +int __uccclass(uint32_t); +int __ucscanon(uint32_t*); + +/* Unicode normalization. */ +#define __UC_NFD 1 +#define __UC_NFKD 2 +#define __UC_NFC 3 +#define __UC_NFKC 4 +size_t __ucsnorm(uint32_t*, const uint32_t*, size_t, int); + +/* Unicode collation. */ +struct __collation { + uint32_t hash; + size_t count; + const uint8_t *alternate; + const uint32_t *elements; +}; +size_t __ucsxfrm(uint32_t*, const uint32_t*, size_t, + const struct __collation*, size_t); +int __ucscoll(const uint32_t*, const uint32_t*, + const struct __collation*, size_t); + +/* Various helper functions. */ +uint32_t __uchash(const uint32_t*, size_t); #endif + enum { XLC_COLLATE = 0, XLC_CTYPE, Modified: soc2014/ghostmansd/head/lib/libc/string/wcscoll.c ============================================================================== --- soc2014/ghostmansd/head/lib/libc/string/wcscoll.c Sat Aug 2 19:59:19 2014 (r271755) +++ soc2014/ghostmansd/head/lib/libc/string/wcscoll.c Sat Aug 2 20:26:48 2014 (r271756) @@ -40,9 +40,6 @@ #include #include #include "collate.h" -#ifdef _UNICODE_SOURCE -#include -#endif #ifndef _UNICODE_SOURCE static char * Modified: soc2014/ghostmansd/head/lib/libc/unicode/ccclass.h ============================================================================== --- soc2014/ghostmansd/head/lib/libc/unicode/ccclass.h Sat Aug 2 19:59:19 2014 (r271755) +++ soc2014/ghostmansd/head/lib/libc/unicode/ccclass.h Sat Aug 2 20:26:48 2014 (r271756) @@ -24,7 +24,7 @@ * SUCH DAMAGE. */ -#include +#include "xlocale_private.h" #define COMBINING_CLASS_MIN 0x000300 Modified: soc2014/ghostmansd/head/lib/libc/unicode/ducet.h ============================================================================== --- soc2014/ghostmansd/head/lib/libc/unicode/ducet.h Sat Aug 2 19:59:19 2014 (r271755) +++ soc2014/ghostmansd/head/lib/libc/unicode/ducet.h Sat Aug 2 20:26:48 2014 (r271756) @@ -24,7 +24,7 @@ * SUCH DAMAGE. */ -#include +#include "xlocale_private.h" #define DUCET_MAX 0xFFF99024 Modified: soc2014/ghostmansd/head/lib/libc/unicode/norm.h ============================================================================== --- soc2014/ghostmansd/head/lib/libc/unicode/norm.h Sat Aug 2 19:59:19 2014 (r271755) +++ soc2014/ghostmansd/head/lib/libc/unicode/norm.h Sat Aug 2 20:26:48 2014 (r271756) @@ -24,7 +24,7 @@ * SUCH DAMAGE. */ -#include +#include "xlocale_private.h" #define UNICODE_MAX 0x10FFFF Modified: soc2014/ghostmansd/head/lib/libc/unicode/uccclass.c ============================================================================== --- soc2014/ghostmansd/head/lib/libc/unicode/uccclass.c Sat Aug 2 19:59:19 2014 (r271755) +++ soc2014/ghostmansd/head/lib/libc/unicode/uccclass.c Sat Aug 2 20:26:48 2014 (r271756) @@ -24,7 +24,7 @@ * SUCH DAMAGE. */ -#include +#include "xlocale_private.h" #include "ccclass.h" Modified: soc2014/ghostmansd/head/lib/libc/unicode/uchash.c ============================================================================== --- soc2014/ghostmansd/head/lib/libc/unicode/uchash.c Sat Aug 2 19:59:19 2014 (r271755) +++ soc2014/ghostmansd/head/lib/libc/unicode/uchash.c Sat Aug 2 20:26:48 2014 (r271756) @@ -24,7 +24,7 @@ * SUCH DAMAGE. */ -#include +#include "xlocale_private.h" uint32_t __ucshash(uint32_t const *key, size_t size) Modified: soc2014/ghostmansd/head/lib/libc/unicode/ucscanon.c ============================================================================== --- soc2014/ghostmansd/head/lib/libc/unicode/ucscanon.c Sat Aug 2 19:59:19 2014 (r271755) +++ soc2014/ghostmansd/head/lib/libc/unicode/ucscanon.c Sat Aug 2 20:26:48 2014 (r271756) @@ -25,7 +25,7 @@ */ #include -#include +#include "xlocale_private.h" int Modified: soc2014/ghostmansd/head/lib/libc/unicode/ucscoll.c ============================================================================== --- soc2014/ghostmansd/head/lib/libc/unicode/ucscoll.c Sat Aug 2 19:59:19 2014 (r271755) +++ soc2014/ghostmansd/head/lib/libc/unicode/ucscoll.c Sat Aug 2 20:26:48 2014 (r271756) @@ -26,7 +26,7 @@ #include #include -#include +#include "xlocale_private.h" int Modified: soc2014/ghostmansd/head/lib/libc/unicode/ucsnorm.c ============================================================================== --- soc2014/ghostmansd/head/lib/libc/unicode/ucsnorm.c Sat Aug 2 19:59:19 2014 (r271755) +++ soc2014/ghostmansd/head/lib/libc/unicode/ucsnorm.c Sat Aug 2 20:26:48 2014 (r271756) @@ -27,7 +27,7 @@ #include #include #include -#include +#include "xlocale_private.h" #include "norm.h" Modified: soc2014/ghostmansd/head/lib/libc/unicode/ucsxfrm.c ============================================================================== --- soc2014/ghostmansd/head/lib/libc/unicode/ucsxfrm.c Sat Aug 2 19:59:19 2014 (r271755) +++ soc2014/ghostmansd/head/lib/libc/unicode/ucsxfrm.c Sat Aug 2 20:26:48 2014 (r271756) @@ -26,7 +26,7 @@ #include #include -#include +#include "xlocale_private.h" #include "ducet.h"