Android pppd_gprs script Startup Process

Source: Internet
Author: User

The GPRS internet access process of Android:

1. Open the data service device corresponding to the module in the RIL layer, such as/dev/ttyusb3.

2. Send the at + cgdcont command to the data device to specify the corresponding APN and send dialing commands such as atdt * 98*1 #.

3. After the above at command returns OK, you can start the pppd_gprs script. Before starting, set the attributes of the APN, such as user, PWD, and device.

View plain
  1. Property_set ("net. GPRS. User", user );
  2. Property_set ("net. GPRS. Password", PWD );
  3. Property_set ("net. GPRS. device", device );
  4. Property_set ("net. GPRS. PPP-Exit ","");
  5. Property_set ("CTL. Start", "pppd_gprs ");

4, attribute setting process in my previous blog has a detailed description of http://blog.csdn.net/yinlijun2004/article/details/6981954

See the code of the void handle_property_set_fd (int fd) function in property_service.c.

View plain
  1. Switch (msg. cmd ){
  2. Case prop_msg_setprop:
  3. MSG. name [PROP_NAME_MAX-1] = 0;
  4. MSG. value [PROP_VALUE_MAX-1] = 0;
  5. If (memcmp (msg. Name, "CTL.", 4) = 0 ){
  6. If (check_control_perms (msg. Value, Cr. uid, Cr. GID )){
  7. Handle_control_message (char *) MSG. Name + 4, (char *) msg. value );
  8. } Else {
  9. Error ("sys_prop: Unable to % s service CTL [% s] uid: % d PID: % d \ n ",
  10. MSG. Name + 4, MSG. Value, Cr. uid, Cr. PID );
  11. }

Call the handle_control_message function of init. c Based on the attribute key value "CTL. Start ".

View plain
  1. Void handle_control_message (const char * MSG, const char * Arg)
  2. {
  3. If (! Strcmp (MSG, "Start ")){
  4. Msg_start (ARG );
  5. } Else if (! Strcmp (MSG, "stop ")){
  6. Msg_stop (ARG );
  7. } Else {
  8. Error ("unknown control MSG '% s' \ n", MSG );
  9. }
  10. }

In msg_start, find the service named pppd_gprs. The service name is also the script name, and then start and modify the service, that is, run the pppd_gprs script.

View plain
  1. Static void msg_start (const char * name)
  2. {
  3. Struct Service * SVC;
  4. Char * TMP = NULL;
  5. Char * ARGs = NULL;
  6. If (! Strchr (name ,':'))
  7. SVC = service_find_by_name (name );
  8. Else {
  9. TMP = strdup (name );
  10. ARGs = strchr (TMP ,':');
  11. * ARGs = '\ 0 ';
  12. ARGs ++;
  13. SVC = service_find_by_name (TMP );
  14. }
  15. If (SVC ){
  16. Service_start (SVC, argS );
  17. } Else {
  18. Error ("No such service '% s' \ n", name );
  19. }
  20. If (TMP)
  21. Free (TMP );
  22. }

5. The pppd_gprs service is defined in the initialization script init. XX. RC and parsed from parser. C to service_list.

View plain
  1. Service pppd_gprs/system/xbin/pppd_gprs
  2. User Root
  3. Group Root
  4. Oneshot
  5. Disabled

6. The pppd_gprs script reads the attributes of the configured APN and runs the pppd process.

View plain
  1. User = '/system/bin/getprop net. GPRS. user'
  2. Password = '/system/bin/getprop net. GPRS. password'
  3. Device = '/system/bin/getprop net. GPRS. devic'
  4. /System/bin/setprop net. GPRS. PPP-Exit ""
  5. /System/bin/pppd-Detach $ device 115200 noipdefault noauth debug novj usepeerdns noccp ipcp-no-addresses kdebug 4 defaultroute user $ User Password $ Password
  6. /System/bin/setprop net. GPRS. PPP-exit $?
  7. # Exit $?

7. After the pppd_gprs script is executed, the RIL layer reads/sys/class/NET/ppp0/operstate to monitor the status of data network data.

From: http://blog.csdn.net/yinlijun2004/article/details/7007046

The GPRS internet access process of Android:

1. Open the data service device corresponding to the module in the RIL layer, such as/dev/ttyusb3.

2. Send the at + cgdcont command to the data device to specify the corresponding APN and send dialing commands such as atdt * 98*1 #.

3. After the above at command returns OK, you can start the pppd_gprs script. Before starting, set the attributes of the APN, such as user, PWD, and device.

View plain
  1. Property_set ("net. GPRS. User", user );
  2. Property_set ("net. GPRS. Password", PWD );
  3. Property_set ("net. GPRS. device", device );
  4. Property_set ("net. GPRS. PPP-Exit ","");
  5. Property_set ("CTL. Start", "pppd_gprs ");

4, attribute setting process in my previous blog has a detailed description of http://blog.csdn.net/yinlijun2004/article/details/6981954

See the code of the void handle_property_set_fd (int fd) function in property_service.c.

View plain
  1. Switch (msg. cmd ){
  2. Case prop_msg_setprop:
  3. MSG. name [PROP_NAME_MAX-1] = 0;
  4. MSG. value [PROP_VALUE_MAX-1] = 0;
  5. If (memcmp (msg. Name, "CTL.", 4) = 0 ){
  6. If (check_control_perms (msg. Value, Cr. uid, Cr. GID )){
  7. Handle_control_message (char *) MSG. Name + 4, (char *) msg. value );
  8. } Else {
  9. Error ("sys_prop: Unable to % s service CTL [% s] uid: % d PID: % d \ n ",
  10. MSG. Name + 4, MSG. Value, Cr. uid, Cr. PID );
  11. }

Call the handle_control_message function of init. c Based on the attribute key value "CTL. Start ".

View plain
  1. Void handle_control_message (const char * MSG, const char * Arg)
  2. {
  3. If (! Strcmp (MSG, "Start ")){
  4. Msg_start (ARG );
  5. } Else if (! Strcmp (MSG, "stop ")){
  6. Msg_stop (ARG );
  7. } Else {
  8. Error ("unknown control MSG '% s' \ n", MSG );
  9. }
  10. }

In msg_start, find the service named pppd_gprs. The service name is also the script name, and then start and modify the service, that is, run the pppd_gprs script.

View plain
  1. Static void msg_start (const char * name)
  2. {
  3. Struct Service * SVC;
  4. Char * TMP = NULL;
  5. Char * ARGs = NULL;
  6. If (! Strchr (name ,':'))
  7. SVC = service_find_by_name (name );
  8. Else {
  9. TMP = strdup (name );
  10. ARGs = strchr (TMP ,':');
  11. * ARGs = '\ 0 ';
  12. ARGs ++;
  13. SVC = service_find_by_name (TMP );
  14. }
  15. If (SVC ){
  16. Service_start (SVC, argS );
  17. } Else {
  18. Error ("No such service '% s' \ n", name );
  19. }
  20. If (TMP)
  21. Free (TMP );
  22. }

5. The pppd_gprs service is defined in the initialization script init. XX. RC and parsed from parser. C to service_list.

View plain
  1. Service pppd_gprs/system/xbin/pppd_gprs
  2. User Root
  3. Group Root
  4. Oneshot
  5. Disabled

6. The pppd_gprs script reads the attributes of the configured APN and runs the pppd process.

View plain
  1. User = '/system/bin/getprop net. GPRS. user'
  2. Password = '/system/bin/getprop net. GPRS. password'
  3. Device = '/system/bin/getprop net. GPRS. devic'
  4. /System/bin/setprop net. GPRS. PPP-Exit ""
  5. /System/bin/pppd-Detach $ device 115200 noipdefault noauth debug novj usepeerdns noccp ipcp-no-addresses kdebug 4 defaultroute user $ User Password $ Password
  6. /System/bin/setprop net. GPRS. PPP-exit $?
  7. # Exit $?

7. After the pppd_gprs script is executed, the RIL layer reads/sys/class/NET/ppp0/operstate to monitor the status of data network data.

From: http://blog.csdn.net/yinlijun2004/article/details/7007046

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.