Re: [PATCH] ukbd.c cleanup and mba iso support

2015-08-06 Thread Joerg Jung
On Wed, Feb 18, 2015 at 10:33:57PM -0800, William Orr wrote:
 Hey,
 
 Any interest?

I'm interested in this. Your diff looks reasonable, so I applied it and 
it compiled fine, but the less and grave keys are still wrong exchanged
on my MacBookAir4,2. Looks like usbdevs says I have a 
USB_PRODUCT_APPLE_WELLSPRING6_ISO:

   port 2 addr 7: full speed, power 40 mA, config 1, Apple Internal
  Keyboard / Trackpad(0x024d), Apple Inc.(0x05ac), rev 2.09   

So I guess some more case's are required in the diff below?
 
 Thanks,
 William Orr
 
 On 2/4/15 9:37 AM, William Orr wrote:
  Hey,
  
  This implements some of Alexey's comments as well as munging the grave key 
  for
  macbook airs. Tested on a mba with a WELLSPRING ANSI keyboard.
  
  Thanks,
  William Orr
  
  Index: sys/dev/usb/ukbd.c
  ===
  RCS file: /cvs/src/sys/dev/usb/ukbd.c,v
  retrieving revision 1.70
  diff -u -b -w -p -r1.70 ukbd.c
  --- sys/dev/usb/ukbd.c  19 Jan 2015 20:16:10 -  1.70
  +++ sys/dev/usb/ukbd.c  4 Feb 2015 05:18:47 -
  @@ -182,6 +182,11 @@ void   ukbd_gdium_munge(void *, uint8_t *,
   void   ukbd_apple_munge(void *, uint8_t *, u_int);
   void   ukbd_apple_mba_munge(void *, uint8_t *, u_int);
   void   ukbd_apple_iso_munge(void *, uint8_t *, u_int);
  +void   ukbd_apple_iso_mba_munge(void *, uint8_t *, u_int);
  +
  +void ukbd_apple_translate(void *, uint8_t *, u_int,
  +  const struct ukbd_translation *, u_int);
  +
   uint8_tukbd_translate(const struct ukbd_translation *, size_t, 
  uint8_t);
   
   int
  @@ -244,14 +249,16 @@ ukbd_attach(struct device *parent, struc
  case USB_PRODUCT_APPLE_GEYSER_ISO:
  sc-sc_munge = ukbd_apple_iso_munge;
  break;
  -   case USB_PRODUCT_APPLE_WELLSPRING4A_ANSI:
  case USB_PRODUCT_APPLE_WELLSPRING4A_ISO:
  +   case USB_PRODUCT_APPLE_WELLSPRING4_ISO:
  +   case USB_PRODUCT_APPLE_WELLSPRING_ISO:
  +   sc-sc_munge = ukbd_apple_iso_mba_munge;
  +   break;
  +   case USB_PRODUCT_APPLE_WELLSPRING4A_ANSI:
  case USB_PRODUCT_APPLE_WELLSPRING4A_JIS:
  case USB_PRODUCT_APPLE_WELLSPRING4_ANSI:
  -   case USB_PRODUCT_APPLE_WELLSPRING4_ISO:
  case USB_PRODUCT_APPLE_WELLSPRING4_JIS:
  case USB_PRODUCT_APPLE_WELLSPRING_ANSI:
  -   case USB_PRODUCT_APPLE_WELLSPRING_ISO:
  case USB_PRODUCT_APPLE_WELLSPRING_JIS:
  sc-sc_munge = ukbd_apple_mba_munge;
  break;
  @@ -461,12 +468,28 @@ ukbd_translate(const struct ukbd_transla
   }
   
   void
  -ukbd_apple_munge(void *vsc, uint8_t *ibuf, u_int ilen)
  +ukbd_apple_translate(void *vsc, uint8_t *ibuf, u_int ilen,
  +const struct ukbd_translation* trans, u_int tlen)
   {
  struct ukbd_softc *sc = vsc;
  struct hidkbd *kbd = sc-sc_kbd;
  uint8_t *pos, *spos, *epos, xlat;
   
  +   spos = ibuf + kbd-sc_keycodeloc.pos / 8;
  +   epos = spos + kbd-sc_nkeycode;
  +
  +   for (pos = spos; pos != epos; pos++) {
  +   xlat = ukbd_translate(trans, tlen, *pos);
  +   if (xlat != 0)
  +   *pos = xlat;
  +   }
  +}
  +
  +void
  +ukbd_apple_munge(void *vsc, uint8_t *ibuf, u_int ilen)
  +{
  +   struct ukbd_softc *sc = vsc;
  +
  static const struct ukbd_translation apple_fn_trans[] = {
  { 40, 73 }, /* return - insert */
  { 42, 76 }, /* backspace - delete */
  @@ -499,23 +522,14 @@ ukbd_apple_munge(void *vsc, uint8_t *ibu
  if (!hid_get_data(ibuf, ilen, sc-sc_apple_fn))
  return;
   
  -   spos = ibuf + kbd-sc_keycodeloc.pos / 8;
  -   epos = spos + kbd-sc_nkeycode;
  -
  -   for (pos = spos; pos != epos; pos++) {
  -   xlat = ukbd_translate(apple_fn_trans,
  -   nitems(apple_fn_trans), *pos);
  -   if (xlat != 0)
  -   *pos = xlat;
  -   }
  +   ukbd_apple_translate(vsc, ibuf, ilen, apple_fn_trans,
  +nitems(apple_fn_trans));
   }
   
   void
   ukbd_apple_mba_munge(void *vsc, uint8_t *ibuf, u_int ilen)
   {
  struct ukbd_softc *sc = vsc;
  -   struct hidkbd *kbd = sc-sc_kbd;
  -   uint8_t *pos, *spos, *epos, xlat;
   
  static const struct ukbd_translation apple_fn_trans[] = {
  { 40, 73 }, /* return - insert */
  @@ -545,40 +559,34 @@ ukbd_apple_mba_munge(void *vsc, uint8_t 
  if (!hid_get_data(ibuf, ilen, sc-sc_apple_fn))
  return;
   
  -   spos = ibuf + kbd-sc_keycodeloc.pos / 8;
  -   epos = spos + 

Re: ceill(0.9) returns 0 instead of 1 ?

2015-08-06 Thread Christian Weisgerber
Assaf Gordon:

 On OpenBSD-5.7/amd64 (under qemu/kvm), I'm getting incorrect results
 when using ceill(3). For values between 0 and 1, the returned value
 is 0, while I'd expected it to be 1. Using ceil(3) does return 1 as
 expected. Is this my incorrect usage or a bug?

It's a bug in the ceill(3) implementation for x86 extended precision
numbers.  Contrary to the IEEE single/double formats, the fraction
part has no implicit bit.

Index: src/ld80/s_ceill.c
===
RCS file: /cvs/src/lib/libm/src/ld80/s_ceill.c,v
retrieving revision 1.2
diff -u -p -r1.2 s_ceill.c
--- src/ld80/s_ceill.c  25 Jul 2011 16:20:09 -  1.2
+++ src/ld80/s_ceill.c  6 Aug 2015 21:44:02 -
@@ -37,7 +37,7 @@ ceill(long double x)
if(jj00) { /* raise inexact if x != 0 */
if(huge+x0.0) {/* return 0*sign(x) if |x|1 */
if(sx) {se=0x8000;i0=0;i1=0;}
-   else if((i0|i1)!=0) { se=0x3fff;i0=0;i1=0;}
+   else if((i0|i1)!=0) { se=0x3fff;i0=0x8000;i1=0;}
}
} else {
i = (0x7fff)jj0;
-- 
Christian naddy Weisgerber  na...@mips.inka.de



[PATCH] share/man/man4/pppoe.4: fix hostname.pppoe0 example

2015-08-06 Thread Delan Azabani
Hi there,

I've written a patch to fix two subtle errors in the example file for
/etc/hostname.pppoe0 that prevent it from working.

Placing inet6 eui64 before the PPPoE parameters inadvertently brings
the interface up, after which the parameters can't be changed.

route add default fe80:: doesn't work either unless the -inet6 option
is specified, because incompatible address families arise.

Cheers,
Delan Azabani

Index: share/man/man4/pppoe.4
===
RCS file: /cvs/src/share/man/man4/pppoe.4,v
retrieving revision 1.28
diff -u -p -u -r1.28 pppoe.4
--- share/man/man4/pppoe.4  16 Feb 2015 16:38:54 -  1.28
+++ share/man/man4/pppoe.4  6 Aug 2015 17:30:00 -
@@ -96,13 +96,13 @@ This all is typically accomplished using
 file.
 A typical file looks like this:
 .Bd -literal -offset indent
-inet6 eui64
 inet 0.0.0.0 255.255.255.255 NONE \e
pppoedev em0 authproto pap \e
authname 'testcaller' authkey 'donttell' up
 dest 0.0.0.1
+inet6 eui64
 !/sbin/route add default -ifp pppoe0 0.0.0.1
-!/sbin/route add default -ifp pppoe0 fe80::
+!/sbin/route add -inet6 default -ifp pppoe0 fe80::
 .Ed
 .Pp
 The physical interface must also be marked




[PATCH] tftpd, rdomain

2015-08-06 Thread Bertrand PROVOST
Hi,

this diff add rdomain support to tftpd.
It used setsockopt/SO_RTABLE like in ping program.

Alternatively I could use `setrtable` once instead of multiple setsockopt.

I don't know which method is the best in this case.

http://pastebin.com/7jBU78fc


Index: tftpd.8
===
RCS file: /cvs/src/usr.sbin/tftpd/tftpd.8,v
retrieving revision 1.4
diff -u -p -r1.4 tftpd.8
--- tftpd.8 4 Mar 2012 07:26:51 - 1.4
+++ tftpd.8 6 Aug 2015 16:10:19 -
@@ -41,6 +41,7 @@
 .Op Fl l Ar address
 .Op Fl p Ar port
 .Op Fl r Ar socket
+.Op Fl V Ar rtable
 .Ar directory
 .Sh DESCRIPTION
 .Nm
@@ -119,6 +120,8 @@ By default
 does not use filename rewriting.
 .It Fl v
 Log the client IP, type of request, and filename.
+.It Fl V Ar rtable
+Set the routing table to be used for listening connections.
 .It Ar directory
 .Xr chroot 2
 to
Index: tftpd.c
===
RCS file: /cvs/src/usr.sbin/tftpd/tftpd.c,v
retrieving revision 1.26
diff -u -p -r1.26 tftpd.c
--- tftpd.c 16 Jan 2015 06:40:22 - 1.26
+++ tftpd.c 6 Aug 2015 16:10:19 -
@@ -260,13 +260,14 @@ __dead void
 usage(void)
 {
  extern char *__progname;
- fprintf(stderr, usage: %s [-46cdv] [-l address] [-p port] [-r socket]
+ fprintf(stderr, usage: %s [-46cdv] [-l address] [-p port] [-r socket]
[-V rtable]
  directory\n, __progname);
  exit(1);
 }

 int  cancreate = 0;
 int  verbose = 0;
+int  rtableid = -1;

 int
 main(int argc, char *argv[])
@@ -283,8 +284,9 @@ main(int argc, char *argv[])
  char *addr = NULL;
  char *port = tftp;
  int family = AF_UNSPEC;
+ const char *errstr;

- while ((c = getopt(argc, argv, 46cdl:p:r:v)) != -1) {
+ while ((c = getopt(argc, argv, 46cdl:p:r:vV:)) != -1) {
  switch (c) {
  case '4':
  family = AF_INET;
@@ -310,6 +312,13 @@ main(int argc, char *argv[])
  case 'v':
  verbose = 1;
  break;
+ case 'V':
+ rtableid = (unsigned int)strtonum(optarg, 0,
+RT_TABLEID_MAX, errstr);
+ if (errstr)
+ errx(1, rtable value is %s: %s,
+errstr, optarg);
+ break;
  default:
  usage();
  /* NOTREACHED */
@@ -537,6 +546,15 @@ tftpd_listen(const char *addr, const cha
  continue;
  }

+ if (rtableid != -1) {
+ if (setsockopt(s, SOL_SOCKET, SO_RTABLE, rtableid,
+sizeof(rtableid)) == -1) {
+ cause = setsockopt SO_RTABLE;
+ cerrno = errno;
+ continue;
+ }
+ }
+
  if (bind(s, res-ai_addr, res-ai_addrlen) == -1) {
  cause = bind;
  cerrno = errno;
@@ -674,6 +692,15 @@ tftpd_recv(int fd, short events, void *a
  lwarn(socket);
  goto err;
  }
+
+ if (rtableid != -1) {
+ if (setsockopt(client-sock, SOL_SOCKET, SO_RTABLE, rtableid,
+sizeof(rtableid)) == -1) {
+ lwarn(setsockopt SO_RTABLE);
+ goto err;
+ }
+ }
+
  memset(s_in, 0, sizeof(s_in));
  s_in.ss_family = client-ss.ss_family;
  s_in.ss_len = client-ss.ss_len;

-- 
Bertrand PROVOST