OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / openswan / testing / klips / saref-alloc-01 / alloc_dealloc.sh
1 #!/bin/sh
2
3 # This script allocates a number of SPIs, then deallocates them in a 
4 # different order. It is driven by an input file which contains some
5 # generated SPI data.
6
7 def_enckey=0x4043434545464649494a4a4c4c4f4f515152525454575758
8 def_authkey=0x87658765876587658765876587658765
9
10 # input file is in the format:
11 #   {alloc,free}  edst spi proto src algo enckey authkey
12 #
13 # if algo="", then algo="3des-md5-96"
14 # if enckey="", then enckey=above, ditto for authkey.
15 # keys are not relevant for dealloc.
16 #
17 # note, proto must be = esp at present.
18
19 # the goal is to make something like:n
20 # ipsec spi --saref --af inet --edst 192.1.2.45 --spi 0x12345678 --proto esp --src 192.1.2.23 --esp 3des-md5-96 --enckey $enckey --authkey $authkey
21 #
22 #
23
24
25 # ROOT is "" in the UML testing environment, and /testing is mounted.
26
27 line=0
28
29 cat $ROOT/testing/klips/saref-alloc-01/allocfile1.txt | while read op edst spi proto src algo enckey authkey
30 do
31     # set up defaults
32     if [ -z "$algo" ]; then algo="3des-md5-96"; fi
33     if [ -z "$enckey" ]; then enckey=$def_enckey;  fi
34     if [ -z "$authkey"]; then authkey=$def_authkey; fi
35
36     line=`expr $line + 1`
37     #echo Input Line: $line
38
39     case $op in
40     \#*) ;;
41     alloc) echo ipsec spi --saref --af inet --edst $edst --spi $spi --proto $proto --src $src --esp $algo --enckey $enckey --authkey $authkey;;
42     free)  echo ipsec spi --saref --af inet --edst $edst --spi $spi --proto $proto --del;;
43     esac
44 done
45
46
47