Solved

call libpcap functions

Posted on 2006-11-14
5
601 Views
Last Modified: 2008-02-01
hi,

i found all sorts of information of how to call libpcap functions from C/C++ but i can't find anything usefull on calling libpcap functions from free pascal (lazarus)
we could use tcpdump output in a memorystream, but we rather work with libpcap itself.

grtz
0
Comment
Question by:Commsquare
  • 2
5 Comments
 
LVL 6

Expert Comment

by:My name is Mud
ID: 17940058
Do you know the structure of the external fuctions/procedures, Have you try...

procedure ProcName(VarName: VarType); external; $L PROC.OBJ
0
 

Author Comment

by:Commsquare
ID: 17945129
hi whatboy,

the libpcap functions are written in C.
I can only find examples using libpcap using the C language.
they include the libpcap headers in C like this: #include <pcap.h>
and a function call is like this: dev = pcap_lookupdev(errbuf);

but i don't know if it is possible to call a C function in free pascal.
we're also developing in GNU/Linux so a dll with C code is no option.

also, what does $L PROC.OBJ mean?



0
 
LVL 6

Accepted Solution

by:
My name is Mud earned 250 total points
ID: 17946891
I didn't catch the "free pascal" thing... I never have use free pascal. but in borland pascal you can link to external libraries by compiling to *.OBJ, those can be asm or C.

and the $L instruct the compiler to link the specified obj file to your program...


Like in an ASM file you declare this...

DATA  segment  word public use16
      extrn    RotAngle:WORD
      extrn    TiltAngle:WORD
      extrn    Xt, Yt, Zt : DWORD
      extrn    _3DX, _3DY, _3DZ : DWORD
      extrn    _2DX, _2DY : DWORD
      extrn    CenterX, CenterY : DWORD
      extrn    SinTab:BYTE
      extrn    CosTab:BYTE
      extrn    ObserverX, ObserverY, ObserverDist : DWORD
      extrn    TmpEqu:DWORD
      extrn    Perspective:BYTE
      extrn    ZoomFactor:WORD
      extrn    CameraX, CameraY, CameraZ : DWORD
DATA  ends

CODE  segment  byte public use16
      assume   ds:DATA,cs:CODE

      public   IntMapCoordinates
      public   IntMapCoordinates2

IntMapCoordinates proc far
  .
  .
  .
IntMapCoordinates endp

IntMapCoordinates2 proc far
  .
  .
  .
IntMapCoordinates2 endp


And in your pascal program you put...

{$L engine3d}

Procedure IntMapCoordinates;external;
Procedure IntMapCoordinates2;external;
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
An analysis of the phishing scam that has been affecting Google users, along with steps to take for protection, as well as what to do if you receive one of the emails.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now