# netgraph pppoe and Host-Uniq - coding



## fbsd_fuse (Feb 24, 2017)

Hi,

I'm looking for some example code or advice on using netgraph with the Host-Uniq PPPoE tag.

I'd aiming to patch mpd/mpd5 to support the Host-Uniq tag. In my case I've got a system using mpd for managing the PPPoE session and I'd like to keep that in the picture. So I'm focused on mpd with netgraph.

I'm going through the mpd code and can see how to expand it to support the tag. However I'm not seeing how to pass the tag from mpd to netgraph (which mpd uses).

For some detail - mpd initiates a PPPoE client connection with the call NgSendMsg . That call requires this data structure... from  ng_pppoe(4) ...

```
struct ngpppoe_init_data {
        char       hook[NG_HOOKSIZ];       /* hook to monitor on */
        uint16_t   data_len;               /* length of the service name */
        char       data[0];                /* init data goes here */
};
```
Easy enough - copy the PPPoE service name in, if one exists, and pass it to netgraph which in turn crafts the PADI package and sends it off to initiate the PPPoE session. But the Host-Uniq value needs to be included in that PADI.

Looking back from netgraph, I see the pppoe_start function in ng_pppoe.c is where the uniqtag is added to the PADI before it's sent. So the netgraph functionality appears to be there, I'm just yet to join all the dots between calls and options.

Any advice or examples would be appreciated.

Thanks!


----------



## fbsd_fuse (Feb 25, 2017)

After digging into netgraph further I've found it doesn't support client supplied Host-Uniq tags. But the good news is there's a patch for it already available...

https://reviews.freebsd.org/D9270

That answers that, and the updated man page supplies a bit of usage info.


----------

