[9fans] Failed 'reject' function?

2014-10-10 Thread Pavel Klinkovský
Hi all,

I tried very simple program on native Plan9:

#include u.h
#include libc.h

void
main(int, char**)
{
int afd, lfd;
char adir[NETPATHLEN], ldir[NETPATHLEN];

afd = announce(tcp!*!20540, adir);
if (afd  0)
sysfatal(listen: %r);

lfd = listen(adir, ldir);
if (lfd  0)
sysfatal(listen: %r);

if (reject(lfd, ldir, unauthorized)  0)
sysfatal(reject: %r);

close(lfd);
close(afd);
exits(nil);
}

I dicovered that the funtion 'reject' fails:
term% 8.out
reject: unknown control request

In 'ratrace' listing I can really see the 'reject' function failure:
348 8.out Open 33a7 0xdfffe9bc//net/cs 0x2 = 3  1412926762174586973
1412926762174841785
348 8.out Pwrite 5577 3  0x7880/tcp!*!20540 11 -1 = 11 
1412926762186976342 1412926762187086984
348 8.out Seek 3391 0x7ab8 3 0x0 0 = 0  1412926762198637769
1412926762198646989
348 8.out Pread 557f 3 0xdfffe9bc 255 -1 0xdfffe9bc//net/tcp/clone.20540
255 -1 = 20  1412926762200546351 1412926762200619275
348 8.out Close 1225 3 = 0  1412926762221784602 1412926762221865069
348 8.out Open 33a7 0xdfffebe0//net/tcp/clone 0x2 = 3 
1412926762223717492 1412926762223849089
348 8.out Pread 557f 3 0xdfffede9 246 -1 0xdfffede9/4 246 -1 = 1 
1412926762235853725 1412926762235866298
348 8.out Pwrite 5577 3  0xdfffece0/announce.20540 14 -1 = 14 
1412926762247454802 1412926762247479948
348 8.out Open 33a7 0xdfffede0//net/tcp/4/listen 0x2 = 4 
1412926762259028218 1412926771821372908
348 8.out Pread 557f 4 0xdfffede9 246 -1 0xdfffede9/6 246 -1 = 1 
1412926771844967723 1412926771844984487
348 8.out Pwrite 5577 4  0xdfffedec/reject.6.unauthorized 21 -1 = -1
unknown control request 1412926771854330421 1412926771854347185
348 8.out Errstr 5587 0xdfffe914 128 128 = 0  1412926771871626615
1412926771871632483
348 8.out Errstr 5587 0xdfffe914 128 128 = 0 unknown control request
1412926771887234674 1412926771887239703
348 8.out Pwrite 5577 2  0xdfffe980/reject:.unknown.control.request. 32
-1reject: unknown control request
 = 32  1412926771918100040 1412926771932457957
348 8.out Open 33a7 0x7538/#c/pid 0x0 = 5  1412926771947976329
1412926771948085295
348 8.out Pread 557f 5 0xdfffeaa0 20 -1 0xdfffeaa0/348. 20 -1 =
12  1412926771963591547 1412926771963607473
348 8.out Close 1225 5 = 0  1412926771979115786 1412926771979128359
348 8.out Exits 122d 0xdfffeadc/reject: unknown control request

Do you have any explanation?
Did I make some bug in the program?

Thanks in advance.

Pavel


Re: [9fans] Failed 'reject' function?

2014-10-10 Thread Charles Forsyth
On 10 October 2014 08:48, Pavel Klinkovský pavel.klinkov...@gmail.com
wrote:

 Do you have any explanation?
 Did I make some bug in the program?


Not all network types implement reject, and the result of reject is
therefore usually ignored (since in any case the connection is going to be
closed).


Re: [9fans] Failed 'reject' function?

2014-10-10 Thread Charles Forsyth
On 10 October 2014 10:22, Charles Forsyth charles.fors...@gmail.com wrote:

 Not all network types implement reject,


To be more precise: not all network types allow a diagnostic to be sent
with the reset or close and sadly TCP/IP is one of them.


Re: [9fans] Failed 'reject' function?

2014-10-10 Thread Sergey Zhilkin
Hi Pavel !

It seems, you do it incorrectly :) dial(2) has an exact example if using
announce/listen/accept functions.

2014-10-10 11:48 GMT+04:00 Pavel Klinkovský pavel.klinkov...@gmail.com:

 Hi all,

 I tried very simple program on native Plan9:

 #include u.h
 #include libc.h

 void
 main(int, char**)
 {
 int afd, lfd;
 char adir[NETPATHLEN], ldir[NETPATHLEN];

 afd = announce(tcp!*!20540, adir);
 if (afd  0)
 sysfatal(listen: %r);

 lfd = listen(adir, ldir);
 if (lfd  0)
 sysfatal(listen: %r);

 if (reject(lfd, ldir, unauthorized)  0)
 sysfatal(reject: %r);

 close(lfd);
 close(afd);
 exits(nil);
 }

 I dicovered that the funtion 'reject' fails:
 term% 8.out
 reject: unknown control request

 In 'ratrace' listing I can really see the 'reject' function failure:
 348 8.out Open 33a7 0xdfffe9bc//net/cs 0x2 = 3  1412926762174586973
 1412926762174841785
 348 8.out Pwrite 5577 3  0x7880/tcp!*!20540 11 -1 = 11 
 1412926762186976342 1412926762187086984
 348 8.out Seek 3391 0x7ab8 3 0x0 0 = 0  1412926762198637769
 1412926762198646989
 348 8.out Pread 557f 3 0xdfffe9bc 255 -1 0xdfffe9bc//net/tcp/clone.20540
 255 -1 = 20  1412926762200546351 1412926762200619275
 348 8.out Close 1225 3 = 0  1412926762221784602 1412926762221865069
 348 8.out Open 33a7 0xdfffebe0//net/tcp/clone 0x2 = 3 
 1412926762223717492 1412926762223849089
 348 8.out Pread 557f 3 0xdfffede9 246 -1 0xdfffede9/4 246 -1 = 1 
 1412926762235853725 1412926762235866298
 348 8.out Pwrite 5577 3  0xdfffece0/announce.20540 14 -1 = 14 
 1412926762247454802 1412926762247479948
 348 8.out Open 33a7 0xdfffede0//net/tcp/4/listen 0x2 = 4 
 1412926762259028218 1412926771821372908
 348 8.out Pread 557f 4 0xdfffede9 246 -1 0xdfffede9/6 246 -1 = 1 
 1412926771844967723 1412926771844984487
 348 8.out Pwrite 5577 4  0xdfffedec/reject.6.unauthorized 21 -1 = -1
 unknown control request 1412926771854330421 1412926771854347185
 348 8.out Errstr 5587 0xdfffe914 128 128 = 0  1412926771871626615
 1412926771871632483
 348 8.out Errstr 5587 0xdfffe914 128 128 = 0 unknown control request
 1412926771887234674 1412926771887239703
 348 8.out Pwrite 5577 2  0xdfffe980/reject:.unknown.control.request. 32
 -1reject: unknown control request
  = 32  1412926771918100040 1412926771932457957
 348 8.out Open 33a7 0x7538/#c/pid 0x0 = 5  1412926771947976329
 1412926771948085295
 348 8.out Pread 557f 5 0xdfffeaa0 20 -1 0xdfffeaa0/348. 20 -1 =
 12  1412926771963591547 1412926771963607473
 348 8.out Close 1225 5 = 0  1412926771979115786 1412926771979128359
 348 8.out Exits 122d 0xdfffeadc/reject: unknown control request

 Do you have any explanation?
 Did I make some bug in the program?

 Thanks in advance.

 Pavel




-- 
С наилучшими пожеланиями
Жилкин Сергей
With best regards
Zhilkin Sergey


Re: [9fans] Failed 'reject' function?

2014-10-10 Thread Pavel Klinkovský
Hi Sergey,

It seems, you do it incorrectly :) dial(2) has an exact example if using
 announce/listen/accept functions.


I do exactly what I need. ;)

The sequence announce/listen/accept is very well known to me.

But I need both possibilities:
- accept incoming connection
- reject incoming connection, which failed.

Thank to Charles, I finally understood.

Pavel


Re: [9fans] Failed 'reject' function?

2014-10-10 Thread Charles Forsyth
On 10 October 2014 10:28, Pavel Klinkovský pavel.klinkov...@gmail.com
wrote:

 reject incoming connection, which failed.


reject should probably swallow the error return from the ctl file write, as
accept does, until
tcp/ip and others interpret the control request and either reset the
connection there,
or ignore the request and act on the close.


[9fans] Anonymous function formal parameter

2014-10-10 Thread Carsten Kunze
Hello,

in sys/src/cmd/eqn/text.c a function definition starts with

int
trans(int c, char *)
{

What does that mean (i.e. how is the second function parameter referenced?

   Carsten



Re: [9fans] [Solved] Anonymous function formal parameter

2014-10-10 Thread Carsten Kunze
 int
 trans(int c, char *)
 {

That parameter seems not to be used inside. That may answer the question...

  Carsten



[9fans] DNS/DHCP/AUTH with Raspberry Pi?

2014-10-10 Thread brankush
Hello,

I'm new to Plan9, using acme/p9p for a couple of months, and I want to add 
plan9 machines to my network. I'm thinking that a DNS/DHCP/AUTH server will be 
an easy step. If this machine could have the role of an Internet 
firewall/nat-router it will be even better.

Do you think plan9+raspi can handle this?
What is the recommended size for the SD card for this role?
Do you recommend other hardware? I don't know what tasks need console access 
during maintenance.

I'll be grateful for any pointers, links and advises.
Thank you.




[9fans] neqn not found

2014-10-10 Thread Carsten Kunze
Hello,

is there no neqn on Plan9?

   Carsten



Re: [9fans] neqn not found

2014-10-10 Thread Kurt H Maier

Quoting Carsten Kunze carsten.ku...@arcor.de:


Hello,

is there no neqn on Plan9?

   Carsten


neqn just runs eqn with -Tascii.  Plan 9 uses UTF-8
and eqn has -Tutf as the default.

khm




Re: [9fans] [Solved] Anonymous function formal parameter

2014-10-10 Thread Brian L. Stuart
 int
 trans(int c, char *)
 {
 
 That parameter seems not to be used inside. That may answer
 the question...

Yes, that is the answer.  By alowing a parameter name to be
omitted, the compiler can warn you about unused parameters
without having to add clutter that explicitly says, I'm ignoring
this parameter.

BLS




Re: [9fans] DNS/DHCP/AUTH with Raspberry Pi?

2014-10-10 Thread Brian L. Stuart
 I'm new to Plan9, using acme/p9p for a couple of months, and
 I want to add plan9 machines to my network. I'm thinking
 that a DNS/DHCP/AUTH server will be an easy step. If this
 machine could have the role of an Internet
 firewall/nat-router it will be even better.
 
 Do you think plan9+raspi can handle this?

While I haven't set one up like this myself, I'm tempted to do so.
I expect the Pi would make a very nice little auth/dhcp/etc
server.  However, to my knowledge, there aren't any NAT
implementations available on Plan 9.  I know it's been worked
on by several people at different times, but I don't think anyone
has a currently packaged implementation.

 What is the recommended size for the SD card for this role?

The databases used for these functions are pretty small, so
I'd be surprised if you filled a 1G card.

BLS




Re: [9fans] DNS/DHCP/AUTH with Raspberry Pi?

2014-10-10 Thread Jeremy Jackins
I think the raspberry pi disk image that is available is 2GB, so it's
probably easiest if you have at least that.

On 10 October 2014 09:41, Brian L. Stuart blstu...@bellsouth.net wrote:

  I'm new to Plan9, using acme/p9p for a couple of months, and
  I want to add plan9 machines to my network. I'm thinking
  that a DNS/DHCP/AUTH server will be an easy step. If this
  machine could have the role of an Internet
  firewall/nat-router it will be even better.
 
  Do you think plan9+raspi can handle this?

 While I haven't set one up like this myself, I'm tempted to do so.
 I expect the Pi would make a very nice little auth/dhcp/etc
 server.  However, to my knowledge, there aren't any NAT
 implementations available on Plan 9.  I know it's been worked
 on by several people at different times, but I don't think anyone
 has a currently packaged implementation.

  What is the recommended size for the SD card for this role?

 The databases used for these functions are pretty small, so
 I'd be surprised if you filled a 1G card.

 BLS





Re: [9fans] DNS/DHCP/AUTH with Raspberry Pi?

2014-10-10 Thread Quintile
sounds like an excellent idea, only one pain, the auth server uses the console 
for its config

you could use erik's con Ethernet console driver so you can configure it from 
another plan system, or even dial into the pi and connect back in via con.

this is not referred though, ideally you should not bye able to cup into the 
auth server, for security reasons.

it's hard to hack a machine that doesn't allow logins.

-Steve




 On 10 Oct 2014, at 13:56, brank...@hushmail.com wrote:
 
 Hello,
 
 I'm new to Plan9, using acme/p9p for a couple of months, and I want to add 
 plan9 machines to my network. I'm thinking that a DNS/DHCP/AUTH server will 
 be an easy step. If this machine could have the role of an Internet 
 firewall/nat-router it will be even better.
 
 Do you think plan9+raspi can handle this?
 What is the recommended size for the SD card for this role?
 Do you recommend other hardware? I don't know what tasks need console access 
 during maintenance.
 
 I'll be grateful for any pointers, links and advises.
 Thank you.
 



Re: [9fans] DNS/DHCP/AUTH with Raspberry Pi?

2014-10-10 Thread erik quanstrom
 you could use erik's con Ethernet console driver so you can configure it from 
 another plan system, or even dial into the pi and connect back in via con.

cec(1), which is implemented in 9atom.

- erik



Re: [9fans] DNS/DHCP/AUTH with Raspberry Pi?

2014-10-10 Thread Quintile
 
cec(1)

oops, yep, that's the one.




On 10 Oct 2014, at 22:08, erik quanstrom quans...@quanstro.net wrote:

 you could use erik's con Ethernet console driver so you can configure it 
 from another plan system, or even dial into the pi and connect back in via 
 con.
 
 cec(1), which is implemented in 9atom.
 
 - erik