# Using binpac standalone

**URL:** <https://community.zeek.org/t/using-binpac-standalone/1961>\
**Category:** Zeek\
**Created:** [August 4, 2011, 1:18pm UTC](https://community.zeek.org/t/using-binpac-standalone/1961 "2011-08-04T13:18:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christoph\_Mobius](https://avatars.discourse-cdn.com/v4/letter/c/aca169/32.png) [@Christoph\_Mobius](https://community.zeek.org/u/Christoph_Mobius)\
**Post date:** [August 4, 2011, 1:18pm UTC](https://community.zeek.org/t/using-binpac-standalone/1961/1 "2011-08-04T13:18:45Z")

</div>

Hi all,

I want to use binpac as a standalone parser generator. My use case is:  
-write a PDU description  
-feed it to a standalone binpac  
-get the parser files for the PDU  
-use that files somewhere else in order to access protocol fields  
programmatically

I tried the Howto of 2008 in the Wiki ([http://is.gd/pyZ7If](http://is.gd/pyZ7If)) which leads  
me to a problem:  
I added the mentioned RE.h, binpac\_stdalone.h and binpac\_pcre.h to  
binpac/lib and recompiled in aux/binpac. Is it right that recompiling  
didn't change the binpac binary in aux/binpac/src? And if yes from where  
do I call binpac then and where should the .pac file be placed? Even the  
unbro'ed http.pac file in the Wiki refers to binpac-lib.pac which  
resides outside the binpac folder. Compiling http.pac then leads to an  
error since bytestring\_to\_int is undeclared.  
Adding binpac-lib.pac to binpac/lib didn't help. Before changing too  
much and getting lost I better ask 🙂

Even If solve the first problem there's another question: I don't need  
any functionality of a protocol machine. So I'd like to get rid of the  
need to define connections and analyzers. I just need access to the  
fields of a single PDU. Anything else is beyond my focus. Do I really  
ALWAYS need to define a connection and a flow?

So is there now another way than the wikified to use binpac as  
standalone parser generator?

Best regards,  
Christoph Möbius

---

<div class="post-metadata">

**Author:** ![Jordi\_Ros-Giralt](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@Jordi\_Ros-Giralt](https://community.zeek.org/u/Jordi_Ros-Giralt)\
**Post date:** [August 5, 2011, 9:15am UTC](https://community.zeek.org/t/using-binpac-standalone/1961/2 "2011-08-05T09:15:13Z")

</div>

What version of Bro are you running? the wiki is for 1.4, so not sure if  
that may affect if you are using a newer version.

you can place the .pac file anywhere you want, for instance, in a pac  
folder. Then from that folder, you can call binpac and the output files  
.cc / .h will be placed in the same folder by default.

For binpac to see binpac-lib.pac, you can use the -I option (binpac --help)

Looks like you may also need to patch the file binpac\_bytestring.h if  
you want to run the example. I am attaching a patch.

[binpac\_bytestring.patch](https://community.zeek.org/uploads/short-url/5gy3CBC7g8n1GEfMAhsAuIHRNld.patch) (592 Bytes)

---

<div class="post-metadata">

**Author:** ![robin](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.zeek.org/robin/32/599_2.png) [@robin](https://community.zeek.org/u/robin)\
**Post date:** [August 5, 2011, 3:00pm UTC](https://community.zeek.org/t/using-binpac-standalone/1961/3 "2011-08-05T15:00:44Z")

</div>

I have some example code how to do that. I'll put it together and get  
back to you.

Robin

---

<div class="post-metadata">

**Author:** ![Hui\_Lin](https://avatars.discourse-cdn.com/v4/letter/h/13edae/32.png) [@Hui\_Lin](https://community.zeek.org/u/Hui_Lin)\
**Post date:** [August 5, 2011, 4:17pm UTC](https://community.zeek.org/t/using-binpac-standalone/1961/4 "2011-08-05T16:17:23Z")

</div>

HI, Robin,

Can I get that code too? I tried to run Binpac stand alone before, but not successful. But may need that in recently DNP3 protocol test.

Best,

Hui

---

<div class="post-metadata">

**Author:** ![robin](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.zeek.org/robin/32/599_2.png) [@robin](https://community.zeek.org/u/robin)\
**Post date:** [August 5, 2011, 5:16pm UTC](https://community.zeek.org/t/using-binpac-standalone/1961/5 "2011-08-05T17:16:51Z")

</div>

Sure, will send it to you too. Hopefully later today.

Robin

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/zeek/original/1X/f09d732bc2cc7c7cc7e35db67cf4e1d5233ce7a7.png) [@system](https://community.zeek.org/u/system)\
**Post date:** [May 6, 2022, 3:39pm UTC](https://community.zeek.org/t/using-binpac-standalone/1961/6 "2022-05-06T15:39:43Z")

</div>


