newlisp Documentation 10.3.0 "net-packet"

Started by newdep, March 25, 2011, 08:35:40 AM

Previous topic - Next topic

newdep

Hi Lutz,



This option (net-packet) is far the best network option newlisp has..Thanks a lot for this Lutz!

I do remember we once discussed this option to manipulate packets headers (3 years ago..hehe)

because i needed it to do so.. At that time it wasnt ready yet..now it is and I have my next project

already finished. (dumped the C code application and replaced it with newlisp ;-))



Here perhpas a small addon for the manual to give the example a little more strenght,

i know you have the qa-packet too but the manual is user input number one ...



Again... please use if usefull else /dev/null ...


Quote
; The following example is an UDP example.

; The packet generated is almost the same as the function (net-send-udp "192.168.1.95" 12345 "Hello World")

; it that context that a net-send-udp does send its original source-address. But this example manipulates

; the source-address of the UDP packet.



; client side UDP packet generation with source address 192.168.1.95 and destination address 192.168.10.10

; The packets is sent from the client machine with ip address 192.168.3.100.        



(set 'udp-packet (pack (dup "b" 39) '(

    0x45 0x00 0x00 0x27 0x4b 0x8f 0x00 0x00 0x40 0x11 0x00 0x00 192 168 1 95

    192  168  10   10   0xf2 0xc8 0x30 0x39 0x00 0x13 0x00 0x00 0x48 0x65 0x6c 0x6c

    0x6f 0x20 0x57 0x6f 0x72 0x6c 0x64)))

           

(unless (net-packet udp-packet)

        (println "net-error: " (net-error))

        (println "sys-error: " (sys-error)))

       

; On the server side:

; You see that the source address is not 192.168.3.100 but 192.168.1.95    

; which is correct as the packet was originaly sent from 192.168.3.100 but  

; the UDP stack has no source ip checking therefore this works.

(net-receive-udp 12345 2048)

it will return ("Hello world" "192.168.1.95" 62123)

       

; when using net-packet as a none root user the following error will return

net-error: (1 "Cannot open socket")

sys-error: (1 "Operation not permitted")
-- (define? (Cornflakes))

kanen

#1
I too am glad to have this option. I think Lutz might have used some of my C code to add this feature. :)
. Kanen Flowers http://kanen.me[/url] .

newdep

#2
Quote from: "kanen"I too am glad to have this option. I think Lutz might have used some of my C code to add this feature. :)


Heheh.. That would not have surpriced me .. and Its for a good purpose...

I can nicely follow the product progress by the updates Lutz makes...nice insight ;-)
-- (define? (Cornflakes))