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
Solved

call libpcap functions

Posted on 2006-11-14
5
607 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

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

The business world is becoming increasingly integrated with tech. It’s not just for a select few anymore — but what about if you have a small business? It may be easier than you think to integrate technology into your small business, and it’s likely…
Most MSPs worth their salt are already offering cybersecurity to their customers. But cybersecurity as a service is wide encompassing and can mean many things.  So where are MSPs falling in this spectrum?
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

828 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