2011年12月14日 星期三

[Router] DMZ

iptables -t nat -A PREROUTING -i ppp0 -p all -j DNAT --to-destination 192.168.0.100

[Router] NAT

# Flush NAT table rules
  iptables -F -t nat
  iptables -X -t nat
  iptables -Z -t nat
  iptables -t nat -P PREROUTING  ACCEPT
  iptables -t nat -P POSTROUTING ACCEPT
  iptables -t nat -P OUTPUT      ACCEPT

# Accept eth0 for all resources
iptables -A INPUT -i eth0 -j ACCEPT

# Enable router function
echo "1" > /proc/sys/net/ipv4/ip_forward

# Enable NAT function
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o ppp0 -j MASQUERADE

[3G] D-Link DWM-156

A clear way to make DWM-156 possible.

1. add usbfs or put it in the /etc/fstab
mount -t usbfs none /proc/bus/usb

fstab:
none    /proc/bus/usb   usbfs   defaults        0       0

2. modem switch
usb_modeswitch -v 0x07d1 -p 0xa804 -m 0x01 -M 5553424312345678000000000000061b000000020000000000000000000000

3. insmod usbserial.ko
insmod /lib/modules/2.6.30/kernel/drivers/usb/serial/usbserial.ko vendor=0x07d1 product=0x7e11

In this stage, /dev/ttyUSB0, /dev/ttyUSB1 and /dev/ttyUSB2 should be appearing.

4. Unlock PIN or not. (xxxx is the PIN code.)
echo -e "AT+CPIN=xxxx\r" > /dev/ttyUSB2

5. /etc/ppp/peers/3g

noauth
nodetach
debug
lock
crtscts
/dev/ttyUSB3
115200
noipdefault
mtu 1500
mru 1500
usepeerdns
local
noccp
refuse-chap
lcp-echo-interval 20
lcp-echo-failure 3
defaultroute
novj
nobsdcomp
nopcomp
noaccomp
nodeflate
linkname 3g
connect "/bin/chat -v -f /etc/ppp/3g_chat"
disconnect '/bin/chat -v -t15 ABORT "BUSY" ABORT "ERROR" ABORT "DIALTONE" "" "\K" "" "ATH" '

6. /etc/ppp/3g_chat

ABORT 'BUSY'
ABORT 'NO CARRIER'
ABORT 'ERROR'
TIMEOUT 10
'' AT
OK AT+CGDCONT=1,"IP","internet",""
OK ATDT*99#
CONNECT ""

7. pppd call 3g
Then ppp0 should appear.

PS: The ISP is "Chunghwa".

[USB] hotplug

    ACTION ... "add", "remove"
    PRODUCT ... USB vendor, product, and version codes (hex)
    TYPE ... device class codes (decimal)
    INTERFACE ... interface 0 class codes (decimal)

    USB_DEVICE (vendorId, productId)
        ... matching devices with specified vendor and product ids
    USB_DEVICE_VER (vendorId, productId, lo, hi)
        ... like USB_DEVICE with lo <= productversion <= hi
    USB_INTERFACE_INFO (class, subclass, protocol)
        ... matching specified interface class info
    USB_DEVICE_INFO (class, subclass, protocol)
        ... matching specified device class info

[3G] ppp-2.4.5

environment variable:
[ipv6]
LLLOCAL
LLREMOTE

BUNDLE
PEERNAME
ORIG_UID
PPPLOGNAME
PPPD_PID
IPLOCAL
IPREMOTE
DNS1
DNS2
USEPEERDNS
OLDIPLOCAL
OLDIPREMOTE
MACREMOTE
UID
DEVICE
SPEED
IFNAME
LINKNAME
CONNECT_TIME
BYTES_SENT
BYTES_RCVD

ip-pre-up:

* Pppd will now run /etc/ppp/ip-pre-up, if it exists, after creating
  the ppp interface and configuring its IP addresses but before
  bringing it up.  This can be used, for example, for adding firewall
  rules for the interface.

2011年12月13日 星期二

[3G] AT commands

"AT+COPS?": Which ISP.
"AT+CGMM": Model name
"AT+CPIN=xxxx": Unlock PIN.


手機 AT 指令集
http://www.360doc.com/content/06/0727/10/10450_165786.shtml
Sierra 320U
Sierra 320U with Telstra
AT commands
手機 AT 指令集
List of AT commands

[iOS] Location

LocateMe:
http://developer.apple.com/library/ios/#samplecode/LocateMe/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007801
This demonstrates the two primary use cases for the Core Location Framework: getting the user's location and tracking changes to the user's location.

GeocoderDemo:
http://developer.apple.com/library/ios/#samplecode/GeocoderDemo/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011097
This sample application demonstrates using a CLGeocoder instance to perform forward and reverse geocoding on strings and dictionaries. The application also includes an example distance calculator that will display the distance between two placemarks.


Teslameter:
http://developer.apple.com/library/ios/#samplecode/Teslameter/Introduction/Intro.html#//apple_ref/doc/uid/DTS40008931

This application implements a Teslameter, a magnetic field detector. It displays the raw x, y, and z magnetometer values, a plotted history of those values, and a computed magnitude (size or strength) of the magnetic field.
The use of the Core Location API for getting "heading" data is contained in the TeslameterViewController class. It creates a CLLocationManager object and uses it to get heading by invoking -[CLLocationManager startUpdatingHeading]. It implements the CLLocationManagerDelegate APIs for receiving heading and updates its user interface accordingly.

Breadcrumb:
http://developer.apple.com/library/ios/#samplecode/Breadcrumb/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010048
Demonstrates how to draw a path using the Map Kit overlay, MKOverlayView, that follows and tracks the user's current location. The included CrumbPath and CrumbPathView overlay and overlay view classes can be used for any path of points that are expected to change over time. It also demonstrates what is needed to track the user's location as a background process.


Regions:
http://developer.apple.com/library/ios/#samplecode/Regions/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010726

This sample demonstrates proper use of region monitoring, significant location changes, and handling location events in the background on iOS. The sample uses an MKMapView that allows the user to add and remove regions to monitor, as well as a UITableView to display the region enter/exit/fail events that occur. When the application goes into the background, location updates are stopped and significant location changes are started. Likewise, when the application enters the foreground, location updates are started again and significant location changes are stopped. When location updates occur in the background, a badge is added to the homescreen icon displaying the number of region enter/exit/fail events logged.


Current Address
http://developer.apple.com/library/ios/#samplecode/CurrentAddress/Introduction/Intro.html#//apple_ref/doc/uid/DTS40009469

Demonstrates basic use of MapKit, displaying a map view and setting its region to current location.
It makes use of the MKReverseGeocoder class that provides services for converting your map coordinate (specified as a latitude/longitude pair) into information about that coordinate, such as the country, city, or street. A reverse geocoder object is a single-shot object that works with a network-based map service to look up placemark information for its specified coordinate value. To use placemark information is leverages the MKPlacemark class to store this information.


MapCallouts:
http://developer.apple.com/library/ios/#samplecode/MapCallouts/Introduction/Intro.html#//apple_ref/doc/uid/DTS40009746
Demonstrates the use of the MapKit framework, displaying a map view with custom MKAnnotations each with custom callouts. An annotation object on a map is any object that conforms to the MKAnnotation protocol and is displayed on the screen as a MKAnnotationView. Through the use of the MKAnnotation protocol and MKAnnotationView, this application shows how you can extend annotations with custom strings and left/right calloutAccessoryViews.