Changeset 11328
- Timestamp:
- 01/11/17 19:05:09 (7 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/globals.h
r11306 r11328 617 617 #define DEFAULT_CC_RECONNECT 12000 618 618 #define DEFAULT_CC_RECV_TIMEOUT 2000 619 620 #define GBOX_MAX_PROXY_CARDS 32621 #define GBOX_MAX_IGNORED_PEERS 16622 #define GBOX_MAX_BLOCKED_ECM 16623 619 624 620 #define DEFAULT_AC_USERS -1 // Use global cfg … … 2068 2064 #endif 2069 2065 #ifdef MODULE_GBOX 2070 #define GBOX_MY_VERS_DEF 0x25 2071 #define GBOX_MY_CPU_API_DEF 0x40 2066 #define GBOX_MY_VERS_DEF 0x25 2067 #define GBOX_MY_CPU_API_DEF 0x40 2068 #define GBOX_MAX_PROXY_CARDS 32 2069 #define GBOX_MAX_IGNORED_PEERS 16 2070 #define GBOX_MAX_BLOCKED_ECM 16 2071 #define GBOX_MAX_DEST_PEERS 16 2072 #define GBOX_MAX_MSG_TXT 127 2072 2073 2073 2074 uint16_t gbox_port[CS_MAXPORTS]; … … 2087 2088 uint16_t gbox_block_ecm[GBOX_MAX_BLOCKED_ECM]; 2088 2089 uint8_t gbox_block_ecm_num; 2090 uint8_t gbox_save_gsms; 2091 uint8_t gbox_msg_type; 2092 uint16_t gbox_dest_peers[GBOX_MAX_DEST_PEERS]; 2093 uint8_t gbox_dest_peers_num; 2094 char gbox_msg_txt[GBOX_MAX_MSG_TXT+1]; 2089 2095 #endif 2090 2096 #ifdef MODULE_SERIAL -
trunk/module-gbox-sms.c
r11281 r11328 198 198 } 199 199 200 int gbox_direct_send_gsms(uint16_t boxid, uint8_t num, char *gsms) 201 { 202 uint8_t gsms_prot = 0, msg_type = 0, gsms_len = 0; 203 int peer_found=0; 204 char text[GBOX_MAX_MSG_TXT+1]; 205 206 memset(text, 0, sizeof(text)); 207 if(cfg.gsms_dis) 208 { 209 gsms_unavail(); 210 return 0; 211 } 212 gsms_len = strlen(gsms); 213 if(gsms_len<6) 214 { 215 cs_log("GBOX: message to send to peer is too short 6 chars expected and %d received texte[%s]", gsms_len, gsms); 216 } 217 else if(gsms_len>GBOX_MAX_MSG_TXT) 218 { 219 gsms_len=GBOX_MAX_MSG_TXT; 220 cs_log("GBOX message is too long so it will be truncated to max. [%d].", GBOX_MAX_MSG_TXT); 221 } 222 cs_strncpy(text,gsms,gsms_len+1); 223 224 switch(num) 225 { 226 case 0: {gsms_prot = 1; msg_type = 0x30; break;} 227 case 1: {gsms_prot = 1; msg_type = 0x31; break;} 228 case 2: {gsms_prot = 2; msg_type = 0x30; break;} 229 case 3: {gsms_prot = 2; msg_type = 0x31; break;} 230 default:{cs_log("ERROR unknown gsms protocol"); return 0;} 231 } 232 cs_log_dbg(D_READER,"init gsms_length=%d msg_type=%02X msg_prot=%d",gsms_len, msg_type, gsms_prot); 233 struct s_client *cl; 234 for (cl = first_client; cl; cl = cl->next) 235 { 236 peer_found=0; 237 if(cl->gbox && cl->typ == 'p') 238 { 239 struct gbox_peer *peer = cl->gbox; 240 if (peer->online && boxid == 0xFFFF) //send gsms to all peers online 241 { 242 gbox_send_gsms2peer(cl, text, msg_type, gsms_prot, gsms_len); 243 peer_found=1; 244 } 245 if (!peer->online && boxid == 0xFFFF) 246 { 247 cs_log("GBOX Info: peer %04X is OFFLINE",peer->gbox.id); 248 write_gsms_nack( cl, gsms_prot, 1); 249 } 250 if (peer->online && boxid == peer->gbox.id) 251 { 252 gbox_send_gsms2peer(cl, text, msg_type, gsms_prot, gsms_len); 253 peer_found=1; 254 } 255 if (!peer->online && boxid == peer->gbox.id) 256 { 257 cs_log("GBOX WARNING: send GSMS failed - peer %04X is OFFLINE",peer->gbox.id); 258 write_gsms_nack( cl, gsms_prot, 0); 259 } 260 } 261 } 262 return peer_found; 263 } 264 265 void gbox_get_online_peers(void) 266 { 267 int n = 0, i; 268 struct s_client *cl; 269 270 for(i = 0; i < GBOX_MAX_DEST_PEERS; i++) 271 { 272 cfg.gbox_dest_peers[i]='\0'; 273 } 274 cfg.gbox_dest_peers_num=0; 275 276 for (cl = first_client; cl; cl = cl->next) 277 { 278 if((cl->gbox && cl->typ == 'p') && (n<GBOX_MAX_DEST_PEERS)) 279 { 280 struct gbox_peer *peer = cl->gbox; 281 if (peer->online) //peer is online 282 { 283 cfg.gbox_dest_peers[n++] = (peer->gbox.id); 284 } 285 } 286 } 287 cfg.gbox_dest_peers_num = n; 288 return; 289 } 290 200 291 void gbox_init_send_gsms(void) 201 292 { -
trunk/module-gbox-sms.h
r10694 r11328 12 12 void gbox_init_send_gsms(void); 13 13 void write_gsms_msg (struct s_client *cli, uchar *gsms, uint16_t type, uint16_t UNUSED(msglen)); 14 int gbox_direct_send_gsms(uint16_t boxid, uint8_t num, char *gsms); 15 void gbox_get_online_peers(void); 14 16 void gbox_send_gsms_ack(struct s_client *cli, uint8_t gsms_prot); 15 17 void write_gsms_ack (struct s_client *cli, uint8_t gsms_prot); -
trunk/module-webif.c
r11325 r11328 31 31 #include "oscam-time.h" 32 32 #include "oscam-work.h" 33 #ifdef MODULE_GBOX 34 #include "module-gbox-sms.h" 35 #endif 33 36 34 37 extern const struct s_cardreader *cardreaders[]; … … 96 99 #define MNU_CFG_SERIAL 12 97 100 #define MNU_CFG_DVBAPI 13 98 #define MNU_CFG_LCD 14101 #define MNU_CFG_LCD 14 99 102 #define MNU_CFG_MONITOR 15 100 103 #define MNU_CFG_WEBIF 16 104 #define MNU_GBOX_SMS 17 101 105 102 106 /* constants for files.html submenuactivating */ … … 1023 1027 static char *send_oscam_config_gbox(struct templatevars *vars, struct uriparams *params) 1024 1028 { 1029 uint8_t i=0; 1030 char local_gbox_save_gsms[2],local_gbox_msg_type[3], local_gbox_dest_peers[GBOX_MAX_DEST_PEERS*5], tmp_gbox_dest_peers[GBOX_MAX_DEST_PEERS*5] ; 1031 int n=0, len_gbox_save_gsms=0, len_gbox_msg_type=0, len_gbox_dest_peers=0, len_gbox_msg_txt=0; 1032 char *ptr1, *saveptr1, *isbroadcast = NULL; 1033 const char *s; 1034 uint16_t gbox_dest_peers_tmp; 1035 1025 1036 setActiveSubMenu(vars, MNU_CFG_GBOX); 1026 1037 webif_save_config("gbox", vars, params); 1038 /* 1039 * Action when GetOnlinePeers is pressed 1040 */ 1041 if(streq(getParam(params, "action"), "Online peers")) 1042 { 1043 gbox_get_online_peers(); 1044 // init var 1045 len_gbox_save_gsms=strlen(getParam(params, "gbox_msg_type")); 1046 len_gbox_msg_type=strlen(getParam(params, "gbox_msg_type")); 1047 len_gbox_msg_txt=strlen(getParam(params, "gbox_msg_txt")); 1048 if(len_gbox_msg_txt>GBOX_MAX_MSG_TXT) { len_gbox_msg_txt=GBOX_MAX_MSG_TXT; } 1049 // retrieve value from Webif 1050 cs_strncpy(local_gbox_save_gsms, getParam(params, "gbox_save_gsms"), len_gbox_save_gsms+1); 1051 cfg.gbox_save_gsms=atoi(local_gbox_save_gsms); 1052 cs_strncpy(local_gbox_msg_type, getParam(params, "gbox_msg_type"), len_gbox_msg_type+1); 1053 cfg.gbox_msg_type=atoi(local_gbox_msg_type); 1054 cs_strncpy(cfg.gbox_msg_txt,getParam(params, "gbox_msg_txt"), len_gbox_msg_txt+1); 1055 } 1056 /* 1057 * Action when ResetGSMS button is pressed 1058 */ 1059 if(streq(getParam(params, "action"), "resetallgsms")) 1060 { 1061 cfg.gbox_save_gsms = 0; 1062 cfg.gbox_msg_type = 0; 1063 for(i = 0; i < GBOX_MAX_DEST_PEERS; i++) 1064 { 1065 cfg.gbox_dest_peers[i]='\0'; 1066 } 1067 cfg.gbox_dest_peers_num=0; 1068 for(i = 0; i < GBOX_MAX_MSG_TXT; i++) 1069 { 1070 cfg.gbox_msg_txt[i]='\0'; 1071 } 1072 tpl_addMsg(vars, "GBOX: Reset GSMS datas done!"); 1073 } 1074 /* 1075 * Action when Send GSMS is pressed 1076 */ 1077 if(streq(getParam(params, "action"), "Send GSMS")) 1078 { 1079 // init var 1080 len_gbox_msg_type=strlen(getParam(params, "gbox_msg_type")); 1081 len_gbox_dest_peers=strlen(trim(getParam(params, "gbox_dest_peers"))); 1082 len_gbox_msg_txt=strlen(getParam(params, "gbox_msg_txt")); 1083 if(len_gbox_msg_txt>GBOX_MAX_MSG_TXT) { len_gbox_msg_txt=GBOX_MAX_MSG_TXT; } 1084 // retrieve value from Webif 1085 cs_strncpy(local_gbox_msg_type, getParam(params, "gbox_msg_type"), len_gbox_msg_type+1); 1086 cfg.gbox_msg_type=atoi(local_gbox_msg_type); 1087 cs_strncpy(local_gbox_dest_peers, strtoupper(trim(getParam(params, "gbox_dest_peers"))), len_gbox_dest_peers+1); 1088 cs_strncpy(tmp_gbox_dest_peers, strtoupper(trim(getParam(params, "gbox_dest_peers"))), len_gbox_dest_peers+1); 1089 cs_strncpy(cfg.gbox_msg_txt,getParam(params, "gbox_msg_txt"), len_gbox_msg_txt+1); 1090 n=0; 1091 for (ptr1 = strtok_r(tmp_gbox_dest_peers, ",", &saveptr1); (ptr1); ptr1 = strtok_r(NULL, ",", &saveptr1)) 1092 { 1093 s=trim(ptr1); 1094 if ((n < GBOX_MAX_DEST_PEERS) && (s[strspn(s, "0123456789abcdefABCDEF")] == 0)) 1095 { cfg.gbox_dest_peers[n++] = a2i(trim(ptr1), strlen(trim(ptr1))); } 1096 } 1097 cfg.gbox_dest_peers_num = n; 1098 /* 1099 Start sending GBox SMS 1100 */ 1101 if((strlen(cfg.gbox_msg_txt) > 5)) 1102 { 1103 isbroadcast=strstr(local_gbox_dest_peers, "FFFF"); 1104 if(isbroadcast == NULL) 1105 { 1106 n =0; 1107 for (i = 0, ptr1 = strtok_r(local_gbox_dest_peers, ",", &saveptr1); (i < 4) && (ptr1); ptr1 = strtok_r(NULL, ",", &saveptr1)) 1108 { 1109 s=ptr1; 1110 if ((n < GBOX_MAX_DEST_PEERS) && (s[strspn(s, "0123456789abcdefABCDEF")] == 0)) 1111 { 1112 gbox_dest_peers_tmp = a2i(ptr1, 4); 1113 if(gbox_direct_send_gsms(gbox_dest_peers_tmp, cfg.gbox_msg_type, cfg.gbox_msg_txt)) { cs_log("GBOX message sent to[%04X] type[%d] text[%s] ", gbox_dest_peers_tmp, cfg.gbox_msg_type, cfg.gbox_msg_txt);} 1114 n++; 1115 } 1116 } 1117 tpl_addMsg(vars, "GBOX Send SMS: individual messages started."); 1118 } 1119 else 1120 { 1121 if(gbox_direct_send_gsms(0xFFFF, cfg.gbox_msg_type, cfg.gbox_msg_txt)) { cs_log("GBOX broadcast message sent type[%d] text[%s] ", cfg.gbox_msg_type, cfg.gbox_msg_txt);} 1122 tpl_addMsg(vars, "GBOX Send SMS: broadcast started."); 1123 } 1124 } 1125 else 1126 { 1127 cs_log("GBox SMS: destination peers or message text not specified or too short"); 1128 tpl_addMsg(vars, "GBOX: Send SMS failed - error in input fields: dest peers or text message."); 1129 } 1130 } 1131 1027 1132 tpl_addVar(vars, TPLADD, "HOSTNAME", xml_encode(vars, cfg.gbox_hostname)); 1028 1133 char *value0 = mk_t_gbox_port(); … … 1046 1151 tpl_addVar(vars, TPLAPPEND, "GBOXBLOCKECM", value3); 1047 1152 free_mk_t(value3); 1153 /* 1154 * GBOX SMS 1155 */ 1156 tpl_addVar(vars, TPLADD, "GBOXSAVEGSMS", (cfg.gbox_save_gsms == 1) ? "checked" : ""); 1157 if(cfg.gbox_msg_type == 0) 1158 { 1159 tpl_addVar(vars, TPLADD, "GBOXMSGTYPENORMAL", "selected"); 1160 } 1161 else if(cfg.gbox_msg_type == 1) 1162 { 1163 tpl_addVar(vars, TPLADD, "GBOXMSGTYPEOSD", "selected"); 1164 } 1165 char *gmsg_dest_peers = mk_t_gbox_dest_peers(); 1166 tpl_addVar(vars, TPLADD, "GBOXMSGDESTPEERS", gmsg_dest_peers); 1167 free_mk_t(gmsg_dest_peers); 1168 tpl_addVar(vars, TPLADD, "GBOXMSGTXT", cfg.gbox_msg_txt); 1169 1048 1170 return tpl_getTpl(vars, "CONFIGGBOX"); 1049 1171 } -
trunk/oscam-conf-mk.c
r11325 r11328 140 140 for(i = 0; i < cfg.c35_tcp_ptab.nports; ++i) 141 141 { 142 /* Port is maximally 5 chars long, plus the @caid (5),plus the ";" between ports */143 needed += 1 1;142 /* Port is maximally 5 chars long, plus comma, plus the @caid, plus the :provid plus the ";" between ports */ 143 needed += 18; 144 144 if(cfg.c35_tcp_ptab.ports[i].ncd && cfg.c35_tcp_ptab.ports[i].ncd->ncd_ftab.filts[0].nprids > 0) 145 145 { … … 278 278 279 279 pos += snprintf(value + pos, needed - pos, "%s%04hX", dot, cfg.gbox_block_ecm[i]); 280 dot = ","; 281 } 282 return value; 283 } 284 /* 285 * Creates a string ready to write as a token into config or WebIf for the gbox SMS dest peers. You must free the returned value through free_mk_t(). 286 */ 287 char *mk_t_gbox_dest_peers(void) 288 { 289 int32_t i, pos = 0, needed = GBOX_MAX_DEST_PEERS * 5 + 8; 290 291 char *value; 292 if(!cs_malloc(&value, needed)) { return ""; } 293 char *dot = ""; 294 for(i = 0; i < GBOX_MAX_DEST_PEERS; i++) 295 { 296 if(!cfg.gbox_dest_peers[i]) { break; } 297 pos += snprintf(value + pos, needed - pos, "%s%04hX", dot, cfg.gbox_dest_peers[i]); 280 298 dot = ","; 281 299 } -
trunk/oscam-conf-mk.h
r11296 r11328 16 16 extern char *mk_t_gbox_ignored_peer(void); 17 17 extern char *mk_t_gbox_block_ecm(void); 18 extern char *mk_t_gbox_dest_peers(void); 18 19 extern char *mk_t_aeskeys(struct s_reader *rdr); 19 20 extern char *mk_t_newcamd_port(void); -
trunk/oscam-config-global.c
r11325 r11328 1064 1064 } 1065 1065 1066 static void gbox_dest_peers_fn(const char *token, char *value, void *UNUSED(setting), FILE *f) 1067 { 1068 if (value) 1069 { 1070 char *ptr1, *saveptr1 = NULL; 1071 const char *s; 1072 memset(cfg.gbox_dest_peers, 0, sizeof(cfg.gbox_dest_peers)); 1073 int n = 0; 1074 for (ptr1 = strtok_r(value, ",", &saveptr1); (ptr1); ptr1 = strtok_r(NULL, ",", &saveptr1)) 1075 { 1076 s=trim(ptr1); 1077 if ((n < GBOX_MAX_DEST_PEERS) && (s[strspn(s, "0123456789abcdefABCDEF")] == 0)) 1078 { cfg.gbox_dest_peers[n++] = a2i(trim(ptr1), strlen(trim(ptr1))); } 1079 } 1080 cfg.gbox_dest_peers_num = n; 1081 return; 1082 } 1083 if ((cfg.gbox_dest_peers_num > 0) && cfg.gbox_save_gsms) 1084 { 1085 value = mk_t_gbox_dest_peers(); 1086 fprintf_conf(f, token, "%s\n", value); 1087 free_mk_t(value); 1088 } 1089 } 1090 1091 static void gbox_msg_txt_fn(const char *token, char *value, void *UNUSED(setting), FILE *f) 1092 { 1093 int len = 0; 1094 if (value) 1095 { 1096 len = strlen(value); 1097 if (len > GBOX_MAX_MSG_TXT) { len = GBOX_MAX_MSG_TXT; } 1098 cs_strncpy(cfg.gbox_msg_txt,value, len+1); 1099 return; 1100 } 1101 if ((cfg.gbox_msg_txt[0]!='\0') && cfg.gbox_save_gsms) 1102 { 1103 fprintf_conf(f, token, "%s\n", cfg.gbox_msg_txt); 1104 } 1105 } 1106 1066 1107 static bool gbox_should_save_fn(void *UNUSED(var)) 1067 1108 { … … 1085 1126 DEF_OPT_FUNC("block_ecm" , OFS(gbox_block_ecm) , gbox_block_ecm_fn ), 1086 1127 DEF_OPT_FUNC("proxy_card" , OFS(gbox_proxy_card) , gbox_proxy_card_fn ), 1128 DEF_OPT_UINT8("gbox_save_gsms" , OFS(gbox_save_gsms) , 0), 1129 DEF_OPT_UINT8("gbox_msg_type" , OFS(gbox_msg_type) , 0), 1130 DEF_OPT_FUNC("gbox_dest_peers" , OFS(gbox_dest_peers) , gbox_dest_peers_fn ), 1131 DEF_OPT_FUNC("gbox_msg_txt" , OFS(gbox_msg_txt) , gbox_msg_txt_fn ), 1087 1132 DEF_LAST_OPT 1088 1133 }; -
trunk/webif/config/gbox.html
r11296 r11328 24 24 <TR><TD><A data-p="block_ecm">Block ECM(s) peer(s):</A></TD><TD>Maximum 16 * 2 bytes (4 hexa digits), comma-separated<BR><textarea name="block_ecm" rows="2" class="bt" maxlength="81">##GBOXBLOCKECM##</textarea><BR></TD></TR> 25 25 <TR><TD><A data-p="proxy_card">Proxy cards:</A></TD><TD>Maximum 32 * 4 bytes (8 hexa digits), comma-separated<BR><textarea name="proxy_card" rows="6" class="bt" maxlength="288">##GBOXPROXYCARD##</textarea><BR></TD></TR> 26 <TR><TH COLSPAN="2">GBox Short Message Service</TH></TR> 27 <TR><TD><A data-p="gbox_save_gsms">Save this GSMS in conf:</A></TD><TD><input name="gbox_save_gsms" value="0" type="hidden"><input name="gbox_save_gsms" value="1" type="checkbox" ##GBOXSAVEGSMS##><label>You need to press save button to really save it!</label></TD></TR> 28 <TR><TD><A data-p="gbox_msg_type">Message type:</TD> 29 <TD><select name="gbox_msg_type"> 30 <option value="0" ##GBOXMSGTYPENORMAL##>0 - normal text message</option> 31 <option value="1" ##GBOXMSGTYPEOSD##>1 - normal txt message + OSD message</option> 32 </select> 33 </TD> 34 </TR> 35 <TR><TD><A data-p="gbox_dest_peers">Destination peer(s):</A></TD> 36 <TD>Maximum 16 * 2 bytes (4 hexa digits), comma-separated. For broadcast to all use FFFF.<BR> 37 <textarea name="gbox_dest_peers" rows="2" class="bt" maxlength="79">##GBOXMSGDESTPEERS##</textarea> 38 </TD> 39 </TR> 40 <TR><TD><A data-p="gbox_msg_txt">Text to send:</A></TD> 41 <TD>From 6 to 127 alphanumerical characters.<BR> 42 <textarea name="gbox_msg_txt" rows="3" class="bt" maxlength="127">##GBOXMSGTXT##</textarea> 43 </TD> 44 </TR> 45 <TR><TD>Action for GSMS</TD> 46 <TD><TABLE align="center" width="100%"><TR> 47 <TD class="centered" TITLE="Send SMS to defined peers"><input name="action" type="submit" value="Send GSMS" ##BTNDISABLED##></TD> 48 <TD class="centered" TITLE="Clear the form"><input type="button" name="resetallgsms" value="Reset GSMS" onclick="window.location.href = 'config.html?part=gbox&action=resetallgsms';" /></TD> 49 <TD class="centered" TITLE="Define online GBox peers as destination"><input name="action" type="submit" value="Online peers" ##BTNDISABLED##></TD> 50 </TR></TABLE></TD> 51 </TR> 52 <TR CLASS="configfirstrow"><TD></TD><TD></TD></TR> 53 </TR> 26 54 55
Note:
See TracChangeset
for help on using the changeset viewer.