Python

Room rules: sopython.com/chatroom Code formatting guide: tinyu...
Mar 28, 2021 11:30
I did .I used it for calculation continues fourier transformation .
Mar 28, 2021 11:29
ok
Mar 28, 2021 11:26
EX: is it possible to integrate this using scipy.integrate.quad
def square_wave(a):
A=2
T=2
return (-1)*A*((a%T)<T/2)+(A)*((a%T)>=T/2)
Mar 28, 2021 11:24
Is it possible to use if statement in a function and integrate it using scipy.integrate.quad ? or I want to integrate them as two ranges ?
Jan 28, 2021 09:31
Hi,is there a documentation for knxnet protocol ?(python based one or C++ based one)
Nov 29, 2020 02:38
Netlink sockets are working in python ?
Oct 30, 2020 11:59
Linux kernel
Oct 30, 2020 11:51
it is not from socket library.... it is in bpf instructions.
Oct 30, 2020 11:50
you mean the SO_ATTACH_FILTER ? it is in built with syscall.
Oct 30, 2020 11:44
Code
Oct 30, 2020 11:44
Oct 30, 2020 11:44
It is not a specific library.
Oct 30, 2020 11:30
that line refer to that ,
(Constants.BPF_LD | Constants.BPF_W | Constants.BPF_ABS,0,0,26) #packet[26:30] loads to accumulator ... but,I didn't get the output of that ,I got whole packet as output...I want to get the output as packet[26:30]
Oct 30, 2020 11:21
#bpf filter
filters=[(Constants.BPF_LD | Constants.BPF_H | Constants.BPF_ABS,0,0,12),
(Constants.BPF_JMP | Constants.BPF_JEQ | Constants.BPF_K,0,2,0x800),
(Constants.BPF_LD | Constants.BPF_W | Constants.BPF_ABS,0,0,26),
(Constants.BPF_RET | Constants.BPF_A,0,0,0),
(Constants.BPF_RET | Constants.BPF_K,0,0,0),
]

fprog=bpf_fprog(5,ctypes.pointer((bpf_inst*5)(*filters)))

is this filter correct? but,it returns full packet...I want to get return of packet[26:30] ...any solution?
Oct 29, 2020 15:49
thanks
Oct 29, 2020 15:36
how to code that in ctypes in python?
Oct 29, 2020 15:35
struct sd {
int a;
int b;
};
struct sd records[3]
= { { 1,0 }, { 2,8 },
{ 4,6 } };
Oct 29, 2020 15:16
Is it possible to use struct arrays in ctypes?
Oct 25, 2020 14:38
@PaulMcG Really,bpf(cbpf) can't do it...may be ebpf and XDP can do it... I got some sources ..I am still reading them.. qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf
Oct 25, 2020 04:38
@PaulMcG scapy only can capture and build packets ...I think It uses PF_PACKET sockets...it can't do that kind of tasks....
Oct 25, 2020 03:59
@PaulMcG It is not about containers ... when getting the packets to rx ring,I just need to move packets to userspace directly without going to protocol stack ....If rx/tx rings can be fully mapping and maneging in userspace,it can be done ..... Really,I need to do bypass system protocol stack... but,bpf do move packets to both protocol stack and bpf vm and run bytecodes in vm and capturing specific packets.....Is there any solution or idea?
Oct 24, 2020 15:37
In python ,is there a way for fully mapping and managing rx/tx ring buffers in userspace?
Oct 22, 2020 04:38
is there a way to tell kernel to pass packets only to bpf vm without passing them to protocol stack in libpcap library or any other library which can be used in python ?
Oct 18, 2020 09:40
hello
Oct 18, 2020 09:39
that is assembly output,it is very short....but,python one is very long...
execve("./helloworld", ["./helloworld"], 0x7ffc1213d130 /* 21 vars */) = 0
write(1, "Hello, world!\n", 14Hello, world!
) = 14
exit(0) = ?
+++ exited with 0 +++
really,I want to call syscalls directly in python ,is it possible?
Oct 18, 2020 09:37
I compared same function(write to sysout).... and tracked syscalls using strace ... it indicates assembly<C++<python (syscalls)
Oct 18, 2020 09:35
they make many syscalls (print)......I think it works as user script -> library -> kernel -> hardware... is there a way to use it as script -> kernel -> hardware?
Oct 18, 2020 09:33
I know
Oct 18, 2020 09:33
but,I like to use it directly .....
Oct 18, 2020 09:33
yeah
Oct 18, 2020 09:20
@AndrasDeak use write() syscall like write(1, "Hello, world!\n", 14) in python... 1 -stdout
Oct 18, 2020 02:31
is it possible to pass a file descriptor to write() in python?
Oct 15, 2020 13:11
I did ....and I got about it..but,it also is under performance engineering.... but,I want to find more of that kind of hacks .....
Oct 15, 2020 12:44
I am still searching programming hacks .... but,got nothing in python....
Oct 15, 2020 12:13
\x00
Oct 15, 2020 12:13
may be
Oct 15, 2020 12:12
I got it in C++
Oct 15, 2020 12:12
0k
Oct 15, 2020 12:02
In generally in programming ?
Oct 15, 2020 12:01
oh ok
Oct 15, 2020 11:59
Are there benefits of using them ? performance ?
Oct 15, 2020 11:59
it is equal to i=1597463007 - ( i //2 )
Oct 15, 2020 11:54
Any source?
Oct 15, 2020 11:51
What are bit hacks ?
Oct 13, 2020 14:40
yeah
Oct 13, 2020 14:39
but,if it is more longer,processing power may be problem ... I had some cases with regex processing power ... it takes more when expression is longer.... I attempted to crawl web using regex after move to beautifulsoup .... regex takes more resources than beautifulsoup.
Oct 13, 2020 14:36
I know it already
Oct 13, 2020 14:33
ok