slankdev / libpgen Goto Github PK
View Code? Open in Web Editor NEWHeader only packet analysis library written in C++11
License: Other
Header only packet analysis library written in C++11
License: Other
ドキュメントに記述してもいいが、scapyみたいに簡単にパケットのプロトコルフィールドと、設定方法を閲覧できるように情報出力をするメンバ関数を追加する。
help関数はpgen_packetクラスの純粋仮想関数としてプロトタイプさせる。
OS依存をnetutilsだけに切り離したいので、addressクラスを修正。
詳細に調べてはいないが、arptableの動作に不具合がある。
At now, the way to install libpgen with make install is specific to some linux destribution and OSX.
Studying about difference each OS and rewrite makefile
を実装して、パケットの入出力を完全に分担する。
それぞれの関数は一つのパケットのバイナリを渡して、それを処理する関数である。
libpgen.orgで各プロトコルごとのドキュメントを作成する。
プロトコル
pgen has many functions. I will make the list that is usage of function and infomation of one.
I must write function type, it is pgen-syscall of not.
We want a function that gets statistical-data from PGEN-descriptor.
implement on pgen.h
I found unintelligible problem. If I write program that open 2 two descriptors, the program can't write to file. I thought about this error for 6 hours today, but I couldn't fix this problem. please help.,..... (T , T)
This program fails to write packet to pcap.
#include <pgen.h>
#include <stdio.h>
int main(int argc, char** argv){
pgen_t* w = pgen_open_offline("write.pcap", PCAP_WRITE);
pgen_t* handle = pgen_open("en0", NULL);
if(handle==NULL || w==NULL){
pgen_perror("oops");
return -1;
}
u_char buf[1000];
int buflen;
while(1){
buflen = pgen_recvpacket_handle(handle, buf, sizeof(buf));
if(buflen < 0){
pgen_perror("oops");
break;
}else if(buflen == 0){
printf("fin \n");
break;
}
pgen_unknown b(buf, buflen);
if(b.isUDP() && b.UDP.port()==53){
buflen= pgen_sendpacket_handle(w , b.byte(), b.length());
}
}
pgen_close(handle);
pgen_close(w);
}
ドキュメントを早急に作成する。
作成したら、数人に読んでもらって修正する。
If it receives packets from receive interface, packet class record timestamp.
And pcapng file's comment too.
ソスーコードの先頭にライセンスの短文をついかする。
Install location on OSX. I don't know that where does it install, at default.
re implement arp-table in pgen_module to program the router and switch easly.
プロトコルとかの拡張をしやすいようにソースツリー構造を変更する。
pgenのコアの部分とは完全に分割させる。
member function, pgen_protocol::compile(), has making binnary, and parsing binnary. I'll independ parse bin pgen_protocol::read_bin(), write_bin()
MBPで作業することが多くなってきたので、BSD向けのnetutilsのコードを追加する。
まずはlinuxでしかコンパイルできないコードをifdefで除外して、BSD向けのifdefの枠組みをついかしてからコードを書く。
前半の作業はlinuxでやって、後半はmacでやる。
I want function that gets statistical data from PGEN-descriptor.
Implementation example)
pgen_t* handle = pgen_open_offline("in.pcapng", PCAPNG_READ);
if(handle == NULL){
pgen_perror("oopes");
return -1;
}
struct pgen_statistics ps;
u_char buf[1000];
int buflen;
while(1){
buflen = pgen_recvpacket_handle(handle, buf, buflen);
if(buflen < 0){
pgen_perror("oops");
break;
}else if(buflen == 0){
break;
}
}
pgen_getstatistic(handle, &ps);
pgen_close(handle);
I'm going to implement new function that gets statistical data. However, I didn't decide function specification. 1st, I have to decide one.
In pgen_ip class and many classes that inherited it, IP header's check sum is always 0x0000.
Re implementation get_checksum function, and use it.
pgen_errno is pgen's error number that global value.
int check(const char* filename);
を作成して、pcapファイルのパケットを読み込んで一つ一つバイナリ生成をして、元のバイナリと同じかを確認する。
返り値は比較で違う値がでてしまったパケットの数を返す。
Support pcapNG files. add functions to PGEN-Util
Add more values about ARP's hardware-type, protocol-type, hardware-length, protocol-length and IP's flag.
機能が増えてきて全体を確認するのが難しくなってきたのでそれを確認するスクリプトを作成する。
各プロトコルごとにパケットを生成してそのバイナリをファイル出力してその値があらかじめ用意していたバイナリファイルと同じになるかを確認すれば、各プロトコルのチェックをすることができる。
各ヘッダごとに任意のバイト列を追加できる機能を追加
Extension-data's implementation is crude. We have to re-implement that.
各関数でエラー処理をするためにエラー番号を追加する。
pgen_erronoみたいなグローバル変数を使ってたくさんのエラーに対応させる。
pgen_perror(const char*);でエラー出力をできるようにする。
READMEを修正する。現在廃止した機能とかの説明とかもあるので、それらをなくすことと。
内部実装をまず設計する。
生成した時から、インターフェースを開いて、パケットを受信し続ける使用にするか、パケット受信部分のみ動作させるかなど。
arpテーブルを検索して、データがない場合新たにarpリクエストを送信するなどの機能の設計もする。
If packet may be malformed, packet class alert warning message in pgen_packet::write_bin()
checking at...
u_char buf[1000];
int buflen;
/* recv packet */
pgen_packet* pack = &arp;
pack->cast(buf, buflen);
if(buflen != pack->len()){
printf("length error \n");
}else{
int res = memcmp(buf, pack->data());
printf("result: %d \n", res);
}
pcapファイルへの書き込みが失敗する不具合があった。
intで正負によって成功判断したり、boolで真理値をかえしたりしてるので、なにかしらの判断方式を決定して、以後それに従って開発する。
それを同時進行でエラー番号も勧められる。
char* でヌル文字列ポインタを返す関数のコードを修正する。
現在は関数内部でmallocしていて、freeは特に行っていないのでメモリをたくさん無駄使いしている。
受信バッファを設定できるようにする、
とくにBPFをつかった場合は受信バッファの設定がとてもセンシティブなので安全なコードを目指す。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.