Wednesday, May 1, 2013
simplemediawiki edit example - python
# ---------------- python code start ----------------------
from simplemediawiki import MediaWiki
wiki = MediaWiki('http://192.168.20.20/mediawiki/api.php')
myUserName = "xxx"
myPassword = "xxx"
#logs in
loginData = wiki.call({'action':'login', 'lgname': myUserName,'lgpassword': myPassword})
print loginData
#resubmission of the login token
personalLoginData = wiki.call({'action':'login', 'lgname': myUserName ,'lgpassword': myPassword,'lgtoken': loginData['login']['token'$
print "[][][]]"
print personalLoginData
print "[][][][]"
returnData = wiki.call({'action':'query','prop':'info', 'titles':'Main_Page','intoken':'edit'});
print returnData
# get the edittoken:
edittoken = returnData['query']['pages']['1']['edittoken']
print "----"
print edittoken
print "----"
results = wiki.call({'action':'edit','title':"testwiki1_Page",'section':'new','text':"new page sample text",'token':edittoken})
print results
# ---------------- python code end ----------------------
Friday, March 22, 2013
CISCO IPv6 PPPOE server
I have been trying to test a CPE router with IPv6 PPPoE client, and finally manage to setup a PPPoE server in a cisco 7K witch supports IPv6. Now the set-up seems to establish an IPv6 link local address in the ppp0 interface in the CPE router and the br0 interface in the router is obtaining a global IPv6 address using DHCPv6. I will update this post with more details soon . CISCO running config is given below,
-----------------------
version 12.4
!
ipv6 unicast-routing
ipv6 cef
ipv6 dhcp pool Clients
prefix-delegation pool DhcpPool
!
ipv6 dhcp pool dhcpv6
prefix-delegation pool dhcpv6-pool1 lifetime 1800 600
address prefix 2001:1::/64
dns-server 2001:1::1
domain-name dhcpv6.com
!
!
multilink bundle-name authenticated
!
memory-size iomem 0
username cisco password 0 cisco
archive
log config
hidekeys
!
bba-group pppoe GROUP
!
bba-group pppoe GROUPA
virtual-template 1
!
!
interface Loopback0
ip address 10.12.0.1 255.255.255.0
ipv6 address 2001:6::1/64
ipv6 enable
!
interface Loopback1
no ip address
!
interface FastEthernet0/0
no ip address
duplex auto
speed auto
ipv6 address 2001:2::1/64
ipv6 enable
ipv6 nd managed-config-flag
ipv6 dhcp server dhcpv6
pppoe enable group GROUPA
!
interface FastEthernet0/1
ip address dhcp
duplex auto
speed auto
ipv6 address 2001:1::1/64
!
interface Virtual-Template1
ip unnumbered Loopback0
ipv6 unnumbered Loopback0
ipv6 enable
ipv6 nd managed-config-flag
ipv6 nd other-config-flag
ipv6 nd router-preference High
no ipv6 nd ra suppress
ipv6 dhcp server dhcpv6
peer default ip address pool ppppool1
peer default ipv6 pool dhcpv6-pool1
ppp authentication pap chap callin
!
ip local pool ppppool1 10.12.0.50 10.12.0.254
ip forward-protocol nd
no ip http server
no ip http secure-server
!
ipv6 local pool dhcpv6-pool1 2001:5::/32 48
!
-----------------------
version 12.4
!
ipv6 unicast-routing
ipv6 cef
ipv6 dhcp pool Clients
prefix-delegation pool DhcpPool
!
ipv6 dhcp pool dhcpv6
prefix-delegation pool dhcpv6-pool1 lifetime 1800 600
address prefix 2001:1::/64
dns-server 2001:1::1
domain-name dhcpv6.com
!
!
multilink bundle-name authenticated
!
memory-size iomem 0
username cisco password 0 cisco
archive
log config
hidekeys
!
bba-group pppoe GROUP
!
bba-group pppoe GROUPA
virtual-template 1
!
!
interface Loopback0
ip address 10.12.0.1 255.255.255.0
ipv6 address 2001:6::1/64
ipv6 enable
!
interface Loopback1
no ip address
!
interface FastEthernet0/0
no ip address
duplex auto
speed auto
ipv6 address 2001:2::1/64
ipv6 enable
ipv6 nd managed-config-flag
ipv6 dhcp server dhcpv6
pppoe enable group GROUPA
!
interface FastEthernet0/1
ip address dhcp
duplex auto
speed auto
ipv6 address 2001:1::1/64
!
interface Virtual-Template1
ip unnumbered Loopback0
ipv6 unnumbered Loopback0
ipv6 enable
ipv6 nd managed-config-flag
ipv6 nd other-config-flag
ipv6 nd router-preference High
no ipv6 nd ra suppress
ipv6 dhcp server dhcpv6
peer default ip address pool ppppool1
peer default ipv6 pool dhcpv6-pool1
ppp authentication pap chap callin
!
ip local pool ppppool1 10.12.0.50 10.12.0.254
ip forward-protocol nd
no ip http server
no ip http secure-server
!
ipv6 local pool dhcpv6-pool1 2001:5::/32 48
!
----------------------------------------------
Thursday, March 21, 2013
L2TP with MPPE
For my understanding L2TP usually use IPsec for security, but
today I tested a cpe router which has a L2TP client which use MPPE. I was puzzled
but then I figured out that CISCO ios support L2TP with MPPE. You just need to
add the line "ppp encrypt mppe auto" to the virtual template,
vpdn-group L2TP-pure
accept-dialin
protocol l2tp
virtual-template 52
interface Virtual-Template52
ip unnumbered Loopback1
ip nat inside
ip virtual-reassembly
peer default ip address pool L2TP-POOL
ppp encrypt mppe
auto
ip local pool L2TP-POOL
192.168.60.10 192.168.60.100
Tuesday, February 21, 2012
IPv6 TFTPD and TOD servers
To enable IPv6 support for xinetd TFTP and TOD server, just add the bind statement in to the configuration file,
------------ TFTP -------------------------
service tftp
{
protocol = udp
port = 69
socket_type = dgram
wait = yes
user = nobody
server = /usr/sbin/in.tftpd
server_args = /tftpboot
disable = no
bind = 2001:0:130:1::24
}
------- TOD --------------------------
service time
{
disable = no
type = INTERNAL
id = time-dgram
socket_type = dgram
protocol = udp
user = root
wait = yes
bind = 2001:0:130:1::24
}
------------ TFTP -------------------------
service tftp
{
protocol = udp
port = 69
socket_type = dgram
wait = yes
user = nobody
server = /usr/sbin/in.tftpd
server_args = /tftpboot
disable = no
bind = 2001:0:130:1::24
}
------- TOD --------------------------
service time
{
disable = no
type = INTERNAL
id = time-dgram
socket_type = dgram
protocol = udp
user = root
wait = yes
bind = 2001:0:130:1::24
}
DOCSIS and eRouter ISC DHCPv6 server configuration
After googling around a lot I managed to configure my ISC DHCP server to provision a DOCSIS modem and eRouter in IPv6. Given below is how I configured the DHCPv6 options in the ISC DHCPD config file (dhcp6.conf),
---------- Cable modem DHCP options ---------------
option space docsis code width 2 length width 2 hash size 17;
option docsis.tftp-server code 32 = array of ip6-address;
option docsis.cablelabs-configuration-file code 33 = text;
option docsis.cablelabs-syslog-servers code 34 = array of ip6-address;
option docsis.device-id code 36 = string;
option docsis.time-servers code 37 = array of ip6-address;
option docsis.time-offset code 38 = signed integer 32;
option vsio.docsis code 4491 = encapsulate docsis;
shared-network CM {
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet6 2001:0:140:1::/64 {
range6 2001:0:140:1::50 2001:0:140:1::254;
option dhcp6.name-servers 2001:0:130:1::23;
option docsis.tftp-server 2001:0:130:1::24;
option docsis.cablelabs-configuration-file "basic.cfg";
option docsis.cablelabs-syslog-servers 2001:0:130:1::23;
option docsis.time-servers 2001:0:130:1::24;
option docsis.time-offset 28800;
}
}
---------------------------------------------------------
----------- CPE ( eRouter ) DHCP options -----------------
shared-network CPE {
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet6 2001:0:f140:1::/64 {
range6 2001:0:f140:1::50 2001:0:f140:1::254;
option dhcp6.name-servers 2001:0:130:1::23;
prefix6 2001:0:150:: 2001:0:150:: /64;
}
}
-----------------------------------------------------------
---------- Cable modem DHCP options ---------------
option space docsis code width 2 length width 2 hash size 17;
option docsis.tftp-server code 32 = array of ip6-address;
option docsis.cablelabs-configuration-file code 33 = text;
option docsis.cablelabs-syslog-servers code 34 = array of ip6-address;
option docsis.device-id code 36 = string;
option docsis.time-servers code 37 = array of ip6-address;
option docsis.time-offset code 38 = signed integer 32;
option vsio.docsis code 4491 = encapsulate docsis;
shared-network CM {
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet6 2001:0:140:1::/64 {
range6 2001:0:140:1::50 2001:0:140:1::254;
option dhcp6.name-servers 2001:0:130:1::23;
option docsis.tftp-server 2001:0:130:1::24;
option docsis.cablelabs-configuration-file "basic.cfg";
option docsis.cablelabs-syslog-servers 2001:0:130:1::23;
option docsis.time-servers 2001:0:130:1::24;
option docsis.time-offset 28800;
}
}
---------------------------------------------------------
----------- CPE ( eRouter ) DHCP options -----------------
shared-network CPE {
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet6 2001:0:f140:1::/64 {
range6 2001:0:f140:1::50 2001:0:f140:1::254;
option dhcp6.name-servers 2001:0:130:1::23;
prefix6 2001:0:150:: 2001:0:150:: /64;
}
}
-----------------------------------------------------------
Saturday, January 1, 2011
Two's complement to Decimal in JAVA
I was searching for a way to convert two's complement to Decimal in JAVA , it seems like there is no built-in method to do this. So I wrote a code , probably this is not the most efficient way to do it , but you can use it if u are desperate and have no time to write your own version.
//----------------JAVA code-------------------------------------
package de.vogella.android.locationapi.maps;
public class TwosToInt {
private static int[] latIntArrayNew = new int[32];
private static String[] latStringArray = new String[32];
private static int latDec;
private static String latStringString;
/**
* @param args
*/
public static String twostoint(int[] latIntArray) {
int kk = latIntArray[0];
if(kk==1){
//---convert-----------
for(int i=0;i<32;i++){
//--- binary NO operation
if(latIntArray[i]==0){latIntArrayNew[i]=1;}
else{latIntArrayNew[i]=0;}
}
}else{
latIntArrayNew = latIntArray;
}
for(int j=0;j<32;j++){latStringArray[j] = Integer.toString(latIntArrayNew[j]);}
latStringString = arrayToString2(latStringArray);
//--add 1 after the NO operation
latDec = 0;
if(kk==1){
latDec = (( Integer.parseInt(latStringString,2))+1)*(-1);
}else{
latDec = ( Integer.parseInt(latStringString,2)+1);
}
return Integer.toString(latDec);
//Integer.toString(latDec);
//latStringString;
}
public static String arrayToString2(String[] a) {
StringBuffer result = new StringBuffer();
if (a.length > 0) {
for (int i=0; i result.append(a[i]);
}
}
return result.toString();
}
}
//----------------JAVA code-------------------------------------
package de.vogella.android.locationapi.maps;
public class TwosToInt {
private static int[] latIntArrayNew = new int[32];
private static String[] latStringArray = new String[32];
private static int latDec;
private static String latStringString;
/**
* @param args
*/
public static String twostoint(int[] latIntArray) {
int kk = latIntArray[0];
if(kk==1){
//---convert-----------
for(int i=0;i<32;i++){
//--- binary NO operation
if(latIntArray[i]==0){latIntArrayNew[i]=1;}
else{latIntArrayNew[i]=0;}
}
}else{
latIntArrayNew = latIntArray;
}
for(int j=0;j<32;j++){latStringArray[j] = Integer.toString(latIntArrayNew[j]);}
latStringString = arrayToString2(latStringArray);
//--add 1 after the NO operation
latDec = 0;
if(kk==1){
latDec = (( Integer.parseInt(latStringString,2))+1)*(-1);
}else{
latDec = ( Integer.parseInt(latStringString,2)+1);
}
return Integer.toString(latDec);
//Integer.toString(latDec);
//latStringString;
}
public static String arrayToString2(String[] a) {
StringBuffer result = new StringBuffer();
if (a.length > 0) {
for (int i=0; i
}
}
return result.toString();
}
}
Tuesday, May 11, 2010
Statically creating a UGS flow (DOCSIS)
I have been trying to define a UGS flow in the Cable modem config file because this particular eMTA I was testing does not support Dynamic service flow creation ( DQOS) for Voice traffic. When I just change the "SchedulingType" to "6" the modem gets a registration reject from the CMTS .
the examples below can be used to define a UGS flow statically using the CM config file , I am using a Best effort service flow for Downstream,
-----------------------
UsServiceFlow /*voice service flow*/
{
UsServiceFlowRef 5;
QosParamSetType 7;
SchedulingType 6;
RequestOrTxPolicy 0x0000001f;
UnsolicitedGrantSize 500;
NominalGrantInterval 10000;
ToleratedGrantJitter 2000;
GrantsPerInterval 1;
}
-----------------------
Subscribe to:
Posts (Atom)