153410Sjulian#!/bin/sh
253410Sjulian# script to set up a frame relay link on the sr card.
353410Sjulian# The dlci used is selected below. The default is 16
453410Sjulian# $FreeBSD$
553410Sjulian
653410SjulianCARD=sr0
753410SjulianDLCI=16
853410Sjulian
953410Sjulian# create a frame_relay type node and attach it to the sync port.
1053410Sjulianngctl mkpeer ${CARD}: frame_relay rawdata downstream
1153410Sjulian
1253410Sjulian# Attach the dlci output of the (de)multiplexor to a new 
1353410Sjulian# Link management protocol node.
1453410Sjulianngctl mkpeer ${CARD}:rawdata lmi dlci0 auto0
1553410Sjulian
16222179Suqs# Also attach dlci 1023, as it needs both to try auto-configuring.
1753410Sjulian# The Link management protocol is now alive and probing..
1853410Sjulianngctl connect ${CARD}:rawdata ${CARD}:rawdata.dlci0 dlci1023 auto1023
1953410Sjulian
2053410Sjulian# Attach the DLCI(channel) the Telco has assigned you to
21222179Suqs# a node to handle whatever protocol encapsulation your peer
22222179Suqs# is using. In this case RFC1490 encapsulation.
2353410Sjulianngctl mkpeer ${CARD}:rawdata rfc1490 dlci${DLCI} downstream
2453410Sjulian
2553410Sjulian
2653410Sjulian# Attach the ip (inet) protocol output of the protocol mux to the ip (inet)
2753410Sjulian# input of a netgraph "interface" node (ifconfig should show it as "ng0").
2853410Sjulian#if interface ng0 needs to be created use a mkpeer command.. e.g.
2953410Sjulianngctl mkpeer ${CARD}:rawdata.dlci${DLCI} iface inet inet
3053410Sjulian
3153410Sjulian# if ng0 already exists, use a CONNECT command instead of a mkpeer. e.g.
3253410Sjulian# ngctl connect ${CARD}:rawdata.dlci${DLCI} ng0: inet inet
3353410Sjulian
3453410Sjulian# Then use ifconfig on interface ng0 as usual
3553410Sjulian
3653410Sjulian# A variant on this whole set might use the 'name' command to make it more
37222179Suqs# readable. But it doesn't work if you have multiple lines or dlcis
38222179Suqs# e.g.
3953410Sjulian# ngctl mkpeer ${CARD}: frame_relay rawdata downstream
4053410Sjulian# ngctl name ${CARD}:rawdata mux
4153410Sjulian# ngctl mkpeer mux: lmi dlci0 auto0
4253410Sjulian# ngctl name mux:dlci0 lmi
4353410Sjulian# ngctl connect mux: lmi: dlci1023 auto1023
4453410Sjulian# ngctl mkpeer mux: rfc1490 dlci${DLCI} downstream
4553410Sjulian# ngctl mux:dlci${DLCI} protomux
4653410Sjulian# ngctl mkpeer protomux: iface inet inet
47