Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
CLassical IP over ATM
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Forum di discussione italiano
View previous topic :: View next topic  
Author Message
g.tomassoni
n00b
n00b


Joined: 13 Aug 2005
Posts: 51

PostPosted: Tue Oct 04, 2005 4:58 pm    Post subject: CLassical IP over ATM Reply with quote

Carissimi,

c'è nessuno che ha un collegamento ADSL con Telecom Italia, un modem ADSL tipo SpeedTouch o similare, voglia di provare un network init script per avviare la connessione CLIP automaticamente ed un po' di tempo da dedicargli?

Lo script lo allego in linea al messaggio. Va salvato nel file
Code:
/lib/rcscripts/net.modules.d/clip
.

Saluti,

giampaolo

Code:

#!/bin/bash
# Copyright (c) 2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Contributed by Giampaolo Tomassoni <g.tomassoni@libero.it>
#
# This is a Classical IP over ATM network init script for Gentoo.
#
# Requirements
#  - CONFIG_ATM_CLIP must be enabled before building the linux kernel.
#  - The net-dialup/linux-atm package must be emerged
#  - If a modular built of the clip kernel module was choosen, it is suggested
#    to pre-load it at boot time by adding the line:
#
#   clip
#
#    to the /etc/modules.autoload.d/kernel-2.x file.
#
# Usage
#  Build your linux kernel with ATM CLIP support and emerge the
#  net-dialup/linux-atm package. Then chdir to /etc/init.d and make a symlink to
#  net.lo naming it net.atmX, where X is 0 to 9. You may setup more CLIP inter-
#  faces if you have more than a single connection. Anyway, please note that it
#  is better to have the first interface name start by 0. So, your first CLIP
#  conn will be named atm0, the second atm1 and so on.
#
#  Now have a look at "man atmsigd.conf" and edit the file /etc/atmsigd.conf
#  according to your preferences. My own /etc/atmsigd.conf looks this:
#
#   # atmsigd.conf - configuration data for atmsigd
#   #
#   # See the atmsigd.conf man page for configuration details.
#   #
#
#   debug {
#      level   warn
#      dump   /var/tmp
#      log   syslog
#      trace   100
#   }
#
#   sig {
#      uni30
#      uni31
#   }
#
#  but you may prefer a different setup, expecially for the "sig {}" section.
#
#  Now edit the file /etc/conf.d/net, adding entries like config_atmX= and
#  routes_atmX= as for every standard tcp/ip device. Then, you have to add one
#  or more clip_atmX= entries to the file. Their syntax is:
#
#   clip_atmX=( "peer_ip [if.]vpi.vci [opts]" ... )
#
#  where "peer_ip" is the IP address of a PVC peer (in case of an ATM connection
#  with your ISP, your only peer is usually the ISP gateway closest to you),
#  "if" is the number of the ATM interface which will carry the PVC, "vpi.vci"
#  is the VC ATM address, and "opts" may optionally specify VC parameters like
#  qos, pcr, and the like (see "atmarp -s" for further reference).
#
#  By default, the PVC will use the LLC/SNAP encapsulation. If you need a null
#  encapsulation (sometimes referred as "VC mode"), please add the keyword
#  "null" to opts.
#
#  An example of /etc/conf.d/net setup for an LLC/SNAP-encapsulated CLIP con-
#  nection having ip address 1.1.1.1, netmask 255.255.255.0 and remote gateway
#  1.1.1.254 would be:
#
#   clip_atm0=( "1.1.1.254 8.35" )
#   config_atm0=( "1.1.1.1/24" )
#   routes_atm0=( "default via 1.1.1.254" )      <- iproute2
#            or
#   routes_atm0=( "0.0.0.0/0 gw 1.1.1.254" )   <- ifconfig
#
#  Now save the file and execute the command:
#
#   /etc/init.d/net.atm0 start
#
#  you should see an output similar to the following:
#
#* Starting atm0
#*   First CLIP instance: starting ATM CLIP daemons
#*     Starting Signaling Daemon (atmsigd) ...            [ ok ]
#*     Starting Integrated Local Management Interface Daemon (ilmid) ...[ ok ]
#*     Starting Address Resolution Protocol Daemon (atmarpd) ...        [ ok ]
#*   Creating CLIP interface atm0 ...                                   [ ok ]
#*   Bringing up atm0
#*     1.1.1.1/24                     [ ok ]
#*   Creating PVC 8.35 for peer 1.1.1.254 ...            [ ok ]
#
#  The link is now up. Please note that, as opposed to other protocols like the
#  PPP-over-ATM one, the CLIP protocol has no provision for automatic system
#  configuration: you have to manually add your ISP's DNS servers to the
#  /etc/resolv.conf file in order to successfully start surfing. When you've
#  done with the CLIP link, issue a:
#
#   /etc/init.d/net.atm0 stop
#
#  which should produce an output like:
#
#* Stopping atm0
#*   Removing PVCs on this interface
#*     Removing PVC to 81.75.231.254 ...              [ ok ]
#*   Bringing down atm0
#*     Shutting down atm0 ...                    [ ok ]
#*     Last CLIP instance: stopping ATM CLIP daemons
#*       Stopping Address Resolution Protocol Daemon (atmarpd) ...     [ ok ]
#*       Stopping Integrated Local Management Interface Daemon (ilmid) ...[ ok ]
#*       Stopping Signaling Daemon (atmsigd) ...           [ ok ]
#
#  Of course, you can start your CLIP connection(s) automatically at system
#  startup by issuing a:
#
#   rc-update add net.atmX default
#
#  but please read first the "Known bugs and limitations" section.
#
#
# Known bugs and limitations
#  - It should be possible to specify an ATM SVC address instead of the PVC one,
#    but this is actually not yet tested.
#  - It should be possible to setup an IPv6 CLIP link through this script, but
#    this is actually not yet tested.
#  - There are tons of problems with CLIP under Linux 2.6.x. It seems to me that
#    the porting of the ATM stack into 2.6 is buggy at least. I expect that the
#    kind of problem I'm experiencing will disappear as more people will start
#    using Linux with the CLIP connection to its ISP. The problems I found are
#    the following:
#  - This script attempts loading the CLIP module into the kernel if it is not
#    already loaded, but this may lead to very weird behaviours on a linux
#    2.6.x kernel: sometimes the kernel may freeze or oops. This script attempts
#    it with great care, but it is probably better to preload the module at boot
#    time instead (edit /etc/modules.autoload.d/kernel-2.6 accordingly).
#  - Under linux 2.6.x and during heavy load (like at system startup) I experi-
#    enced some kernel freeze. This script implements a nondeterministic work-
#    around (yeah, aka a "sleep"), which lets the CLIP kernel and daemon code to
#    stabilize a bit before going further. It seem to work to me, but since it
#    is a nonderterministic workaround, I wouldn't bet it works in other setups
#    as well. Also, in order for the workaround to have any effect, that's much
#    better not to setup a CLIP connection through a parallel startup! This
#    means that the RC_PARALLEL_STARTUP must be "no" in your /etc/conf.d/rc.
#
# Hints for Telecom Italia's Smart ADSL users
#  You should have received a piece of paper full with a lot of numbers, IPs and
#  the like. The numbers you need in order to setup your CLIP connection to
#  internet are in the "IP ADDESS BASE PUBBLICO" field, which is the address to
#  assign to your local ATM interface, and in the "IP REMOTO" field, which is
#  the ip address of the Telecom's router closest to you.
#  In every and each Telecom Italia's Smart ADSL installation I saw, the subnet
#  mask was 255.255.255.0, which means a cidr of "/24", the gateway was always
#  at x.x.x.254 and the CLIP conn adopted the LLC/SNAP encapsulation. Also, in
#  Italy the vpi.vci pair is always 8.35. A reasonable setup would then be close
#  to the example shown above, apart the trivial differences in IP addresses.
#
# Further references
#  - the man pages o atmsigd, ilmid, atmarpd, and atmarp
#  - /usr/share/doc/linux-atm-*/atm-linux-howto.txt.gz
#  - the http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=4
#    (Gentoo Linux x86 Handbook, Network Configuration section)
#
# Support
#  Actually, I'm not supporting this file in any way. If you have troubles or
#  question, it is better to ask to the knowledgefull Gentoo staff. If you send
#  me an e-mail, I'm easily going to discard it without notice.

ATMPATH=/usr/sbin
ATMARP=atmarp
ARPFILE=/proc/net/atm/arp

ATMCLIP_SVC_NAME=( atmsigd ilmid atmarpd )
ATMCLIP_SVC_DESC=( \
      "Signaling"            \
      "Integrated Local Management Interface"   \
      "Address Resolution Protocol"      \
   )
typeset -ar ATMCLIP_SVC_NAME ATMCLIP_SVC_DESC

atmclip_svc_start() {
   local name="${ATMCLIP_SVC_NAME[$1]}"
   ebegin "Starting ${ATMCLIP_SVC_DESC[$1]} Daemon (${name})"
   start-stop-daemon --start --quiet --name "${name}" --exec "${ATMPATH}/${name}" -- -b -l syslog
   eend ${?}
}

atmclip_svcs_start() {
   einfo "First CLIP instance: starting ATM CLIP daemons"
   eindent
   atmclip_svc_start 0 && atmclip_svc_start 1 && atmclip_svc_start 2 || return 1
   eoutdent
}

atmclip_svc_stop() {
   local name="${ATMCLIP_SVC_NAME[$1]}"
   ebegin "Stopping ${ATMCLIP_SVC_DESC[$1]} Daemon (${name})"
   start-stop-daemon --stop --quiet --name "${name}" --retry=-TERM/1/-TERM/2/-KILL/2
   eend ${?}
}

atmclip_svcs_stop() {
   einfo "Last CLIP instance: stopping ATM CLIP daemons"
   eindent
   atmclip_svc_stop 2 && atmclip_svc_stop 1 && atmclip_svc_stop 0 || return 1
   eoutdent
}

are_atmclip_svcs_running() {
   is_daemon_running "${ATMCLIP_SVC_NAME[0]}" || \
   is_daemon_running "${ATMCLIP_SVC_NAME[1]}" || \
   is_daemon_running "${ATMCLIP_SVC_NAME[2]}"
}

atmarp() {
   "${ATMPATH}/${ATMARP}" "$@"
}


# char* clip_provides(void)
#
# Returns a string to change module definition for starting up
clip_provides() {
   echo 'clip'
}

# void clip_depend(void)
#
# Sets up the dependancies for the module
clip_depend() {
   before interface
}

# bool clip_check_depends(void)
#
# Checks to see if we have the needed functions
clip_check_depends() {
        local f
        for f in interface_post_start interface_down interface_up start-stop-daemon is_daemon_running; do
                if [[ ! $( type -t "${f}" ) == "function" ]]; then
         eerror "clip: missing required function ${f}\n"
         return 1
      fi
        done

        return 0
}


# bool clip_check_installed(void)
#
# Returns 1 if clip and linux-atm tools are installed, otherwise 0
clip_check_installed() {
   if [[ ! -r "${ARPFILE}" ]]; then
      /sbin/modprobe clip && sleep 2
      if [[ ! -r "${ARPFILE}" ]]; then
         eerror "You need first to enable the kernel support for ATM CLIP"
         return 1
      fi
   fi

   local x;
   for x in "${ATMCLIP_SVC_NAME[@]}" ${ATMARP}; do
      if [[ ! -x "${ATMPATH}/$x" ]]; then
         eerror 'You need first to "emerge net-dialup/linux-atm"'
         return 1
      fi
   done

   return 0
}

clip_get_vars() {
   echo "clip_$1"
}

# bool clip_pre_start(char *iface)
#
# Create the interface by calling atmarp -c
#
# Returns 0 (true) when successful, non-zero otherwise
clip_pre_start() {
   local iface="$1" ifvar=$( bash_variable "$1" ) msg
   local -a opts
   eval opts=\"\$\{clip_${ifvar}\[@\]\}\"

   [[ -z "${opts}" ]] && return 0
   clip_check_installed || return 1

   if ! are_atmclip_svcs_running; then
      atmclip_svcs_start && sleep 1 || return 1
   fi

   ebegin "Creating CLIP interface ${iface}"
   msg="`atmarp -c \"${iface}\" 2>&1`"
   if [[ $? -ne 0 ]]; then
      case "${msg}" in
      'atmarp: Operation not permitted')
         # Interface already created
         # We don't need to create it anymore
         eend 0 'already present'
         ;;

      *)
         # Other error
         eend 1 "${msg}"
         ;;
      esac
   else
      eend 0
   fi
}

clip_post_start() {
   local iface="$1" ifvar=$( bash_variable "$1" ) i
   local -a opts
   eval opts=\"\$\{clip_${ifvar}\[@\]\}\"

   [[ -z "${opts}" ]] && return 0
   clip_check_installed || return 1
   are_atmclip_svcs_running || return 1

   # We need to have the interface fully set up.
   interface_post_start "${iface}" || return 1

   # The atm tools (atmarpd?) are silly enough that they
   # woun't work with iproute2 interface setup as opposed to
   # the ifconfig one. This is due to the fact that iproute2
   # "ip link set up" command brings the interface status to
   # 'up', but doesn't jet assign an address to it. Some
   # buggy interface setup trapping code in the clip daemons
   # do assume this. It it probably due to the fact that atm
   # tools were designed when only the ifconfig way was
   # available.
   # The workaround is to temporarily toggle the interface
   # state from up to down and then up again, without touching
   # its address. This (should) work with both iproute2 and
   # ifconfig.
   interface_down "${iface}"
   interface_up "${iface}"

   # Now the real thing: create a PVC with our peer(s)
   for (( i=0; i<${#opts[@]}; i++ )); do
      set -- ${opts[$i]}
      local peerip="$1"; shift
      local ifvpivci="$1"; shift

      ebegin "Creating PVC ${ifvpivci} for peer ${peerip}"
      atmarp -s $peerip $ifvpivci $*
      eend ${?}
   done

   # When I'm telling CLIP is buggy in 2.6, it's buggy: the
   # system sometimes locks on heavy load (ie: during startup).
   # As a workaroung, I'm going to let this script sleep for
   # a while. This also mean you can't use CLIP on a parallel
   # startup!
   if [[ "`/usr/bin/uname -r`" > '2.6.0' ]]; then
      ebegin "[WORKAROUND] Please allow 5 seconds for the CLIP code to stabilize"
      sync; sleep 5; sync
      eend 0
   fi
}

# bool clip_pre_stop(char *iface)
#
# There is no way to "undo" the interface creation.
# We can just put the interface "down", but ifconfig -a
# will still list it...
clip_pre_stop() {
   local iface="$1" ifvar=$( bash_variable "$1" ) i
   local -a opts
   eval opts=\"\$\{clip_${ifvar}\[@\]\}\"

   [[ -z "${opts}" ]] && return 0

   if are_atmclip_svcs_running; then
      # We remove all the PVCs which may have been created by
      # clip_post_start for this interface. This shouldn't be
      # needed by the ATM stack, but sometimes I got a panic
      # killing CLIP daemons without previously vacuuming
      # every active CLIP PVCs.
      # The linux 2.6's ATM stack is really a mess...
      local itf t encp idle ipaddr left
      einfo "Removing PVCs on this interface"
      eindent
      {
         read t && while read itf t encp idle ipaddr left
         do
            if [[ "${itf}" == "${iface}" ]]; then
               ebegin "Removing PVC to ${ipaddr}"
               atmarp -d "${ipaddr}"
               eend ${?}
            fi
         done
      } < "${ARPFILE}"
      eoutdent
   fi
}

clip_post_stop() {
   local iface="$1" ifvar=$( bash_variable "$1" ) i
   local -a opts
   eval opts=\"\$\{clip_${ifvar}\[@\]\}\"

   [[ -z "${opts}" ]] && return 0

   are_atmclip_svcs_running || return 0

   local hasothers
   {
      read t && while read itf t encp idle ipaddr left
      do
         if [[ "${itf}" != "${iface}" ]]; then
            hasothers=1
         fi
      done
   } < "${ARPFILE}"

   if [[ -z "${hasothers}" ]]; then
      atmclip_svcs_stop || return 1
   fi
}

# vim:ts=4
Back to top
View user's profile Send private message
g.tomassoni
n00b
n00b


Joined: 13 Aug 2005
Posts: 51

PostPosted: Thu Oct 06, 2005 2:23 pm    Post subject: CLassical IP over ATM - new version Reply with quote

Ho una nuova versione dello script, che allego in linea come la precedente.

Questa versione dovrebbe essere molto più robusta della precedente, oltre a permettere l'attivazione di connessioni CLIP da parallel startup.

Chi avesse modo di provarla, vorrebbe essere così gentile da rispondere a questo messaggio? Ho provato finora solo con una connessione (la mia).

Saluti,

g


Code:

#!/bin/bash
# Copyright (c) 2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Contributed by Giampaolo Tomassoni <g.tomassoni@libero.it>
#
# This is a Classical IP over ATM network init script for Gentoo.
#
# Requirements
#  - CONFIG_ATM_CLIP must be enabled before building the linux kernel.
#  - The net-dialup/linux-atm package must be emerged
#  - If a modular built of the clip kernel module was choosen, it is suggested
#    to pre-load it at boot time by adding the line:
#
#   clip
#
#    to the /etc/modules.autoload.d/kernel-2.x file.
#
# Usage
#  Build your linux kernel with ATM CLIP support and emerge the
#  net-dialup/linux-atm package. Then chdir to /etc/init.d and make a symlink to
#  net.lo naming it net.atmX, where X is 0 to 9. You may setup more CLIP inter-
#  faces if you have more than a single connection. Anyway, please note that it
#  is better to have the first interface name start by 0. So, your first CLIP
#  conn will be named atm0, the second atm1 and so on.
#
#  Now have a look at "man atmsigd.conf" and edit the file /etc/atmsigd.conf
#  according to your preferences. My own /etc/atmsigd.conf looks this:
#
#   # atmsigd.conf - configuration data for atmsigd
#   #
#   # See the atmsigd.conf man page for configuration details.
#   #
#
#   debug {
#      level   warn
#      dump   /var/tmp
#      log   syslog
#      trace   100
#   }
#
#   sig {
#      uni30
#      uni31
#   }
#
#  but you may prefer a different setup, expecially for the "sig {}" section.
#
#  Now edit the file /etc/conf.d/net, adding entries like config_atmX= and
#  routes_atmX= as for every standard tcp/ip device. Then, you have to add one
#  or more clip_atmX= entries to the file. Their syntax is:
#
#   clip_atmX=( "peer_ip [if.]vpi.vci [opts]" ... )
#
#  where "peer_ip" is the IP address of a PVC peer (in case of an ATM connection
#  with your ISP, your only peer is usually the ISP gateway closest to you),
#  "if" is the number of the ATM interface which will carry the PVC, "vpi.vci"
#  is the ATM VC address, and "opts" may optionally specify VC parameters like
#  qos, pcr, and the like (see "atmarp -s" for further reference).
#
#  By default, the PVC will use the LLC/SNAP encapsulation. If you need a null
#  encapsulation (aka "VC mode"), please add the keyword "null" to opts.
#
#  An example of /etc/conf.d/net setup for an LLC/SNAP-encapsulated CLIP con-
#  nection having ip address 1.1.1.1, netmask 255.255.255.0 and remote gateway
#  1.1.1.254 would be:
#
#   clip_atm0=( "1.1.1.254 8.35" )
#   config_atm0=( "1.1.1.1/24" )
#   routes_atm0=( "default via 1.1.1.254" )      <- iproute2
#            or
#   routes_atm0=( "0.0.0.0/0 gw 1.1.1.254" )   <- ifconfig
#
#  Now save the file and execute the command:
#
#   /etc/init.d/net.atm0 start
#
#  you should see an output similar to the following:
#
#* Starting atm0
#*   First CLIP instance: starting ATM CLIP daemons
#*     Starting Signaling Daemon (atmsigd) ...            [ ok ]
#*     Starting Integrated Local Management Interface Daemon (ilmid) ...[ ok ]
#*     Starting Address Resolution Protocol Daemon (atmarpd) ...        [ ok ]
#*   Creating CLIP interface atm0 ...                                   [ ok ]
#*   Bringing up atm0
#*     1.1.1.1/24                     [ ok ]
#*   Creating PVC 8.35 for peer 1.1.1.254 ...            [ ok ]
#
#  The link is now up. Please note that, as opposed to other protocols like the
#  PPP-over-ATM one, the CLIP protocol has no provision for automatic system
#  configuration: you have to manually add your ISP's DNS servers to the
#  /etc/resolv.conf file in order to successfully start surfing. When you've
#  done with the CLIP link, issue a:
#
#   /etc/init.d/net.atm0 stop
#
#  which should produce an output like:
#
#* Stopping atm0
#*   Removing PVCs on this interface
#*     Removing PVC to 81.75.231.254 ...              [ ok ]
#*   Bringing down atm0
#*     Shutting down atm0 ...                    [ ok ]
#*     Last CLIP instance: stopping ATM CLIP daemons
#*       Stopping Address Resolution Protocol Daemon (atmarpd) ...     [ ok ]
#*       Stopping Integrated Local Management Interface Daemon (ilmid) ...[ ok ]
#*       Stopping Signaling Daemon (atmsigd) ...           [ ok ]
#
#  Of course, you can start your CLIP connection(s) automatically at system
#  startup by issuing a:
#
#   rc-update add net.atmX default
#
#  but please read first the "Known bugs and limitations" section.
#
#  There is also a further setting to be optionally specified in
#  /etc/conf.d/net:
#
#   clip_full="no"
#
#  Setting this, you ask not to start the whole daemon set but just atmarpd.
#
#  The sole atmarpd execution should be enough for an ADSL connection to an ISP,
#  but it is out of the linux-atm specification regarding CLIP, so it is not the
#  suggested (and default) setting.
#
# Known bugs and limitations
#  - It should be possible to specify an ATM SVC address instead of the PVC one,
#    but this is actually not yet tested.
#  - It seems that the actual CLIP kernel module lacks yet of any support for an
#    IPv6 link, but I didn't try it at all.
#  - If your /etc/conf.d/rc file specifies RC_NET_STRICT_CHECKING as "no", you
#    may see your CLIP connection to be automatically started at the end of the
#    default softlevel. If you have services depending on it, you may pretend
#    to start it soon at the beginning of the startup sequence by setting
#    RC_NET_STRICT_CHECKING to "yes". There are also other ways to have the link
#    working where needed, however. Have a look at the Gentoo Handbook for them.
#  - There are tons of problems with CLIP under at least Linux 2.6.13. It seems
#    to me that the porting of the ATM stack into 2.6 is buggy at least. I
#    expect that the kind of problems I'm experiencing will disappear as more
#    people will start using Linux with the CLIP connection to its ISP. The
#    problems I found are the following:
#  - This script attempts loading the CLIP module into the kernel if it is not
#    already loaded, but this may lead to very weird behaviours on a linux
#    2.6.x kernel: sometimes the kernel may freeze or oops. This script attempts
#    it with great care, but it is probably better to preload the module at boot
#    time instead (edit /etc/modules.autoload.d/kernel-2.6 accordingly).
#  - Setting up a PVC on an interface previously setup by "ip link up" as
#    opposed to "ifconfig", the "atmarp -s" commands fails with a "No route
#    to host". However, this script implements a workaround to this.
#
# Hints for Telecom Italia's Smart ADSL users
#  You should have received a piece of paper full with a lot of numbers, IPs and
#  the like. The numbers you need in order to setup your CLIP connection to
#  internet are in the "IP ADDESS BASE PUBBLICO" field, which is the address to
#  assign to your local ATM interface, and in the "IP REMOTO" field, which is
#  the ip address of the Telecom's router closest to you.
#  In every and each Telecom Italia's Smart ADSL installation I saw, the subnet
#  mask was 255.255.255.0, which means a cidr of "/24", the gateway was always
#  at x.x.x.254 and the CLIP conn adopted the LLC/SNAP encapsulation. Also, in
#  Italy the vpi.vci pair is always 8.35. A reasonable setup would then be close
#  to the example shown above, apart the trivial differences in IP addresses.
#
# Further references
#  - the man pages of atmsigd, ilmid, atmarpd, and atmarp
#  - /usr/share/doc/linux-atm-*/atm-linux-howto.txt.gz
#  - the http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=4
#    (Gentoo Linux x86 Handbook, Network Configuration section)
#
# Support
#  Actually, I'm not supporting this script in any way. If you have troubles or
#  questions, it is better to ask to the knowledgefull Gentoo staff. If you send
#  me an e-mail, I'm easily going to discard it without notice.

# If you are using CLIP on an ADSL link, you may try to set "clip_full=no" in
# your /etc/conf.d/net. This way your clip interface will rely only on atmarpd,
# yielding a more stable system in the overall.
# However, this is not the setup suggested by the linux-atm docs and it wouldn't
# work on a switched connection, so our default is "clip_full=yes" instead.
clip_full="${clip_full:-yes}"


if [[ ${clip_full} == 'yes' ]]; then
   CLIP_ATMDAEMON_NAMES=( atmsigd ilmid atmarpd )
   CLIP_ATMDAEMON_DESCS=( \
      "Signaling" \
      "Integrated Local Management Interface" \
      "Address Resolution Protocol" \
   )
else
   CLIP_ATMDAEMON_NAMES=( atmarpd )
   CLIP_ATMDAEMON_DESCS=( "Address Resolution Protocol" )
fi
typeset -ar CLIP_ATMDAEMON_NAMES CLIP_ATMDAEMON_DESCS


# int atmclip_svc_start(char *name, char *desc)
#
# This starts a service. Albeit atmsigd, ilmid and atmarpd do allow for back-
# grounding through the -b option, its usage causes them to be sensible to
# SIGHUP, which is sent to all daemons when console detaches right after
# startup.
# This is probably due to the fact that these programs don't detach itself from
# the controlling terminal when backgrounding... The only way I see to overcame
# this is to use the --background option in start-stop-daemon, which is reported
# as a "last resort" method, but it acts correctly about this.
atmclip_svc_start() {
   ebegin "Starting $2 Daemon ($1)"
   start-stop-daemon --start \
      --quiet \
      --background \
      --name "$1" \
      --exec "/usr/sbin/$1" -- -l syslog
   local x=${?}
   eend ${x}
   return ${x}
}

# int atmclip_svc_start()
#
# This starts the whole set of atm services needed by clip
atmclip_svcs_start() {
   einfo "First CLIP instance: starting ATM CLIP daemons"
   eindent
   local i s=0
   for (( i=0; i<${#CLIP_ATMDAEMON_NAMES[@]}; ++i )); do
      atmclip_svc_start "${CLIP_ATMDAEMON_NAMES[${i}]}" "${CLIP_ATMDAEMON_DESCS[${i}]}"
      s=${?}
      [[ ${s} -ne 0 ]] && break
   done
   eoutdent

   return ${s}
}

# void atmclip_svc_stop(char *name, char* desc)
#
atmclip_svc_stop() {
   ebegin "Stopping $2 Daemon ($1)"
   start-stop-daemon --stop \
      --quiet \
      --name "$1" \
      --retry=-TERM/1/-TERM/2/-KILL/2
   eend ${?}
}

# void atmclip_svcs_stop()
#
atmclip_svcs_stop() {
   einfo "Last CLIP instance: stopping ATM CLIP daemons"
   eindent
   local i
   for (( i=${#CLIP_ATMDAEMON_NAMES[@]} - 1; i>=0; --i )); do
      atmclip_svc_stop "${CLIP_ATMDAEMON_NAMES[${i}]}" "${CLIP_ATMDAEMON_DESCS[${i}]}"
   done
   eoutdent
}

# bool are_atmclip_svcs_running()
#
are_atmclip_svcs_running() {
   local name
   for name in "${CLIP_ATMDAEMON_NAMES[@]}"; do
      is_daemon_running "${name}" || return 1
   done

   return 0
}

atmarp() {
   /usr/sbin/atmarp "$@"
}


# char* clip_provides(void)
#
# Returns a string to change module definition for starting up
clip_provides() {
   echo 'clip'
}

# void clip_depend(void)
#
# Sets up the dependancies for the module
clip_depend() {
   before interface
}

# bool clip_check_depends(void)
#
# Checks to see if we have the needed functions
clip_check_depends() {
        local f
        for f in \
      interface_post_start \
      interface_down \
      interface_up \
      start-stop-daemon \
      is_daemon_running
   do
                if [[ ! $( type -t "${f}" ) == "function" ]]; then
         eerror "clip: missing required function ${f}\n"
         return 1
      fi
        done

        return 0
}


# bool clip_check_installed(void)
#
# Returns true if clip and linux-atm tools are installed, otherwise false
clip_check_installed() {
   if [[ ! -r "/proc/net/atm/arp" ]]; then
      [ -x /sbin/modprobe ] && /sbin/modprobe clip && sleep 2
      if [[ ! -r "/proc/net/atm/arp" ]]; then
         eerror "You need first to enable kernel support for ATM CLIP"
         return 1
      fi
   fi

   local x;
   for x in "${CLIP_ATMDAEMON_NAMES[@]}" "atmarp"; do
      if [[ ! -x "/usr/sbin/${x}" ]]; then
         eerror 'You need first to "emerge net-dialup/linux-atm"'
         return 1
      fi
   done

   return 0
}

clip_get_vars() {
   echo "clip_$1"
}

# bool clip_pre_start(char *iface)
#
# Start the CLIP daemons
# Create the interface by calling atmarp -c
#
# Returns 0 (true) when successful, non-zero otherwise
clip_pre_start() {
   local iface="$1" ifvar=$( bash_variable "$1" )
   local -a opts
   eval opts=\"\$\{clip_${ifvar}\[@\]\}\"

   [[ -z "${opts}" ]] && return 0
   clip_check_installed || return 1

   if ! are_atmclip_svcs_running; then
      atmclip_svcs_start || return 1
   fi

   if ! interface_exists "${iface}"; then
      ebegin "Creating CLIP interface ${iface}"
      local msg="$( atmarp -c "${iface}" )"
      local r=$?
      eend ${r} "${msg}"

      if [[ ${r} != 0 ]]; then
         atmclip_svcs_stop
         return 1
      fi
   fi

   return 0
}

clip_post_start() {
   local iface="$1" ifvar=$( bash_variable "$1" ) i
   local -a opts
   eval opts=\"\$\{clip_${ifvar}\[@\]\}\"

   [[ -z "${opts}" ]] && return 0
   clip_check_installed || return 1
   are_atmclip_svcs_running || return 1

   # The atm tools (atmarpd?) are silly enough that they woun't work with
   # iproute2 interface setup as opposed to the ifconfig one.
   # The workaround is to temporarily toggle the interface state from up
   # to down and then up again, without touching its address. This (should)
   # work with both iproute2 and ifconfig.
   interface_down "${iface}"
   interface_up "${iface}"

   # Now the real thing: create a PVC with our peer(s)
   for (( i=0; i<${#opts[@]}; i++ )); do
      set -- ${opts[${i}]}
      local peerip="$1"; shift
      local ifvpivci="$1"; shift

      ebegin "Creating PVC ${ifvpivci} for peer ${peerip}"
      atmarp -s ${peerip} ${ifvpivci} $*
      eend $?
   done
}

# bool clip_pre_stop(char *iface)
#
# Here we basicly undo the PVC creation previously created through the
# clip_post_start function. When we establish a new PVC, a corresponding line
# is added to the /proc/net/atm/arp file, so we inspect it to extract all the
# outstanding PVCs of this interface.
clip_pre_stop() {
   local iface="$1" ifvar=$( bash_variable "$1" ) i
   local -a opts
   eval opts=\"\$\{clip_${ifvar}\[@\]\}\"

   [[ -z "${opts}" ]] && return 0

   if are_atmclip_svcs_running; then
      # We remove all the PVCs which may have been created by
      # clip_post_start for this interface. This shouldn't be
      # needed by the ATM stack, but sometimes I got a panic
      # killing CLIP daemons without previously vacuuming
      # every active CLIP PVCs.
      # The linux 2.6's ATM stack is really a mess...
      local itf t encp idle ipaddr left
      einfo "Removing PVCs on this interface"
      eindent
      {
         read left && while read itf t encp idle ipaddr left
         do
            if [[ ${itf} == "${iface}" ]]; then
               ebegin "Removing PVC to ${ipaddr}"
               atmarp -d "${ipaddr}"
               eend ${?}
            fi
         done
      } < /proc/net/atm/arp
      eoutdent
   fi
}

# bool clip_post_stop(char *iface)
#
# Here we should teorically delete the interface previously created in the
# clip_pre_start function, but there is no way to "undo" an interface creation.
# We can just leave the interface down. "ifconfig -a" will still list it...
# What we can do here is to stop the ATM CLIP daemons if there is no other CLIP
# PVC outstanding. We check this condition by inspecting the /proc/net/atm/arp
# file.
clip_post_stop() {
   local iface="$1" ifvar=$( bash_variable "$1" ) i
   local -a opts
   eval opts=\"\$\{clip_${ifvar}\[@\]\}\"

   [[ -z "${opts}" ]] && return 0

   are_atmclip_svcs_running || return 0

   local itf t encp idle ipaddr left hasothers
   {
      read left && while read itf t encp idle ipaddr left
      do
         if [[ ${itf} != "${iface}" ]]; then
            hasothers=1
            break
         fi
      done
   } < /proc/net/atm/arp

   if [[ -z "${hasothers}" ]]; then
      atmclip_svcs_stop || return 1
   fi
}

# vim:ts=8
Back to top
View user's profile Send private message
Atomikramp
Apprentice
Apprentice


Joined: 27 Sep 2004
Posts: 200

PostPosted: Thu Oct 06, 2005 7:13 pm    Post subject: Reply with quote

specificherei che il protocollo CLIP è compatibile solo con le adsl telecom business ( smart ) e non con alice, che supporta solo protocolli pppoa/pppoe
Back to top
View user's profile Send private message
g.tomassoni
n00b
n00b


Joined: 13 Aug 2005
Posts: 51

PostPosted: Thu Oct 06, 2005 8:44 pm    Post subject: Reply with quote

Giusta puntualizzazione.

Ho sottoposto lo script ai tipi di Gentoo, che mi hanno indicato varie correzioni.

Così stando le cose, non c'è necessità che io invii aggiornamenti ai vari forum: l'ultima versione può essere scaricata dal Gentoo Bug#108153.

Saluti
Back to top
View user's profile Send private message
Thrain
Guru
Guru


Joined: 01 Sep 2003
Posts: 380

PostPosted: Sat May 13, 2006 3:35 pm    Post subject: Reply with quote

Ciao g.tomassoni,

vorrei ringraziarti per aver realizzato questo script, spero che tu frequenti ancora il forum, perché purtroppo ho dei problemi nel far funzionare, appunto, il tuo script!

Ho impostato sul mio router ADSL ethernet la modalità "bridge", pensando che fosse quella da abilitare per renderlo un semplice "modem adsl"... fatto sta che o non è quello ciò che devo impostare (infatti sembra che il collegamento funzioni ancora, anche se a rigor di logica non dovrebbe, giusto?) oppure sto facendo qualche errore sul mio pc: infatti, quando cerco di avviare /etc/init.d/net.atm0, ottengo un errore circa la mancanza di un interfaccia atm0, e mi consiglia di verificare il modulo o driver...

Francamente non so come comportarmi...

Nel kernel ho abilitato quel che hai suggerito.

Non ho il supporto al ppp (non mi sembra necessario).

Spero tu possa rispondermi,
Ciao!

Emanuele
_________________
Thrain

"...only astonishment knows..."
Back to top
View user's profile Send private message
g.tomassoni
n00b
n00b


Joined: 13 Aug 2005
Posts: 51

PostPosted: Sat May 13, 2006 11:28 pm    Post subject: Reply with quote

Aspetta, fammi capire. Hai un router ADSL che, quindi, ha un'interfaccia Ethernet (altrimenti sarebbe un modem), giusto?

Però è uno di quei router "combo", con anche un'interfaccia USB, giusto?

1) che marca e modello è? Se è collegato via USB ed il kernel non fornisce un driver adeguato, non serve lo script che hai scaricato.

2) che versione del kernel Linux hai?

3) che provider hai?

4) L'errore circa la mancanza dell'interfaccia atm0 ha generalmente a che vedere con il fatto che nel Kernel non è stato abilitato il modulo clip (in 'make menuconfig' deve essere attivata l'opzione Networking-->Network Options-->Classical IP Over ATM nella versione 2.6.16). Una interfaccia atm0 la dovresti poter creare anche in assenza di opportune device atm (quali il tuo router/modem).

5) Generalmente (ma dipende dal modello) il collegamento di un router a Linux tramite USB viene vista come interfaccia di rete ethernet via USB, non come canale ADSL. Lo script per il CLIP o connessioni via PPPo[AE] su quel canale non hanno praticamente senso.

Ciao,

giampaolo
Back to top
View user's profile Send private message
Thrain
Guru
Guru


Joined: 01 Sep 2003
Posts: 380

PostPosted: Sun May 14, 2006 9:55 am    Post subject: Reply with quote

g.tomassoni wrote:
Aspetta, fammi capire. Hai un router ADSL che, quindi, ha un'interfaccia Ethernet (altrimenti sarebbe un modem), giusto?

Però è uno di quei router "combo", con anche un'interfaccia USB, giusto?

1) che marca e modello è? Se è collegato via USB ed il kernel non fornisce un driver adeguato, non serve lo script che hai scaricato.

È uno Starbridge-EU Aethra, collegato via ethernet. È un router nel senso che fornisce tutto il necessario per connettersi ad internet senza aver bisogno del collegamento ad un altro pc che fornisce nomeutente, password e altri parametri... Nel caso della mia connessione, l'indirizzo IP, la subnet mask e il gateway...
g.tomassoni wrote:
2) che versione del kernel Linux hai?

gentoo-sources-2.6.16-r3
g.tomassoni wrote:
3) che provider hai?

Indovina :D ? Telecom Interbusiness (Smart) con protocollo IPoA
g.tomassoni wrote:
4) L'errore circa la mancanza dell'interfaccia atm0 ha generalmente a che vedere con il fatto che nel Kernel non è stato abilitato il modulo clip (in 'make menuconfig' deve essere attivata l'opzione Networking-->Network Options-->Classical IP Over ATM nella versione 2.6.16). Una interfaccia atm0 la dovresti poter creare anche in assenza di opportune device atm (quali il tuo router/modem).

Io ho collegato il router alla mia porta ethernet (prima era collegato direttamente allo switch), ho impostato il "bridge mode" sul router, dopodiché ho dato
Code:
modprobe clip

ed ho provato ad avviare il servizio /etc/init.d/net.atm0 creato come tu hai detto.
A quel punto ottengo l'errore circa l'interfaccia atm0 non esistente...
g.tomassoni wrote:
5) Generalmente (ma dipende dal modello) il collegamento di un router a Linux tramite USB viene vista come interfaccia di rete ethernet via USB, non come canale ADSL. Lo script per il CLIP o connessioni via PPPo[AE] su quel canale non hanno praticamente senso.

Intendi dire che se collegassi il mio router via USB, non potrei far funzionare il tuo script, oppure intendi dire che non potrei farlo funzionare solo nel caso in cui non abbia gli appositi driver usb per il mio router?
g.tomassoni wrote:
Ciao,

giampaolo

Ciao ;)

MODIFICA: Ho notato che sembra che baselayout ignori completamente il tuo script! Sia che lo metta in /lib/rcscripts/net.modules.d/ sia in qualsiasi altra cartella, con qualsiasi tipo di permesso, l'errore è sempre lo stesso! Quindi, pare che proprio NON venga letto!
Spero che questo sia rilevante...

Ri-ciao!

MODIFICA 2: Dopo una breve conversazione con g.tomassoni ho capito che non è possibile usare un modem/router ethernet con lo script clip perché non esiste uno "standard" per l'ATM over Ethernet. Quindi acquisterò a breve uno SpeedTouch 330 e risolverò il problema :D Grazie ancora a g.tomassoni!

Ri-definitivamente-ciao!
_________________
Thrain

"...only astonishment knows..."
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Forum di discussione italiano All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum