Tomato 1.23
[tomato.git] / release / src / router / upnp / igd / wanppp.c
blobf7100f8f65e19633f38caf7afa524070ffe9adfd
1 /*
2 * Copyright 2005, Broadcom Corporation
3 * All Rights Reserved.
4 *
5 * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6 * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7 * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8 * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10 * $Id: wanppp.c,v 1.1.1.7 2005/03/07 07:31:12 kanki Exp $
15 Notes:
16 * This code doesn't do anything useful.
17 * Removed. Using just WANIPConnection instead.
19 -- zzz 07/2006
21 */
23 #include "upnp_dbg.h"
24 #include "upnp_osl.h"
25 #include "upnp.h"
26 #include "igd.h"
27 #include "wanppp.h"
28 #include "bcmnvram.h"
30 #if defined(linux)
31 #define pppoe_up()
32 #define pppoe_down()
33 #else
34 extern void pppoe_up();
35 extern void pppoe_down();
36 #endif
39 extern void igd_restart(int secs);
40 extern char * safe_snprintf(char *str, int *len, const char *fmt, ...);
42 extern char *WANPPPConnection_PossibleConnectionTypes_allowedValueList[];
44 int WANPPPConnection_GetVar(struct Service *psvc, int varindex)
46 struct StateVar *var;
47 char **p, *cur;
48 int len;
50 var = &(psvc->vars[varindex]);
52 switch (varindex) {
53 case VAR_PossibleConnectionTypes:
54 cur = var->value;
55 len = sizeof(var->value);
56 for (p = WANPPPConnection_PossibleConnectionTypes_allowedValueList; *p; p++) {
57 if (cur != var->value)
58 cur = safe_snprintf(cur, &len, ",");
59 cur = safe_snprintf(cur, &len, "%s", *p);
61 break;
62 case VAR_UserName:
63 strcpy(var->value, nvram_safe_get("pppoe_username"));
64 break;
65 case VAR_Password:
66 strcpy(var->value, nvram_safe_get("pppoe_passwd"));
67 break;
68 case VAR_IdleDisconnectTime:
69 strcpy(var->value, nvram_safe_get("pppoe_idletime"));
70 break;
71 case VAR_ExternalIPAddress:
72 strcpy(var->value, nvram_safe_get("wan_ipaddr"));
73 break;
75 return TRUE;
79 int WANPPPConnection_ConfigureConnection(UFILE *uclient, PService psvc, PAction ac, pvar_entry_t args, int nargs)
80 // {"NewUserName", VAR_UserName, VAR_IN},
81 // {"NewPassword", VAR_Password, VAR_IN},
83 uint success = TRUE; /* assume no error will occur */
85 if (strlen(ac->params[0].value) > 32 || strlen(ac->params[1].value) > 32) {
86 soap_error( uclient, SOAP_INVALID_ARGS);
87 success = FALSE;
88 } else {
89 nvram_set("pppoe_username", ac->params[0].value);
90 nvram_set("pppoe_passwd", ac->params[1].value);
91 nvram_commit();
94 return success;
98 int WANPPPConnection_SetIdleDisconnectTime(UFILE *uclient, PService psvc, PAction ac, pvar_entry_t args, int nargs)
99 // {"NewIdleDisconnectTime", VAR_IdleDisconnectTime, VAR_IN},
101 uint success = TRUE; /* assume no error will occur */
103 nvram_set("pppoe_idletime", ac->params[0].value);
104 nvram_commit();
106 return success;
110 int WANPPPConnection_RequestConnection(UFILE *uclient, PService psvc, PAction ac, pvar_entry_t args, int nargs)
112 char tmp[100];
114 /* should probably confirm that the pppoe_username and ppoe_passwd
115 are set here. */
116 nvram_set(igd_pri_wan_var(tmp, sizeof(tmp), "proto"), "pppoe");
117 nvram_commit();
118 pppoe_up();
120 return TRUE;
123 int WANPPPConnection_ForceTermination(UFILE *uclient, PService psvc, PAction ac, pvar_entry_t args, int nargs)
125 pppoe_down();
127 return TRUE;
131 int WANPPPConnection_SetConnectionType(UFILE *uclient, PService psvc, PAction ac, pvar_entry_t args, int nargs)
132 /* "SetConnectionType", WANPPPConnection_SetConnectionType, */
134 snprintf(psvc->vars[VAR_ConnectionType].value, sizeof(psvc->vars[VAR_ConnectionType].value), ac->params[0].value);
136 return TRUE;