Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

call libpcap functions

Posted on 2006-11-14
5
Medium Priority
?
613 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
What we learned in Webroot's webinar on multi-vector protection.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

670 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