Solved

call libpcap functions

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
Is your company's data protection keeping pace with virtualization? Here are 7 dynamic ways to adapt to rapid breakthroughs in technology.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 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

12 Experts available now in Live!

Get 1:1 Help Now