2016-09-24

Eclipse usability notes

Remove unused toolbar items

Eclipse Mars installed as a part SW4STM32 uses two rows of toolbar items and most of them are probably not frequently used. To get rid of them use Window/Perspective/Customize perspective... menu.

Remove status bar

Status bar does not seem to present any useful information. Line numbers are displayed in editor window anyway, current column number and Insert/Overwrite mode state don't not seem important to me. To hide status bar open e4_basestyle.css file from Eclipse directory (in my case: Ac6\SystemWorkbench\plugins\org.eclipse.ui.themes_1.1.1.v20151026-1355\css) and add at the bottom of it:

#org-eclipse-ui-trim-status,
#org-eclipse-ui-trim-vertical1,
#org-eclipse-ui-trim-vertical2 {
   visibility: hidden;
}


Update file timestamp before building

Project properties, C/C++ build, Settings, Build Steps, Pre-build steps:
${ProjDirPath}\build-tools/touch.exe ${ProjDirPath}\..\..\main.c
For a list of environment variables look at C/C++ Build, Build Variables and check "Show system variables":

2016-09-06

Mocecom MC-STARTER mouse and replacing A4Tech X-708 encoder

Mouse wheel encoder in my old A4Tech X-708 started causing problems again (moving in opposite direction at one position and not moving at all at another position) and cleaning it with organic solvent was no help. Let's take a look inside:
As you can see it's covered with oil remains and some rust and it has miles behind it. On the bottom side of the wheel there are three contact springs - quite fragile as I broken one of them when trying to bend it. Well, it wouldn't help for long probably anyway.
Fortunately I had cheap Modecom MC-STARTER mouse lying around - almost unused as it just feels too cheap to use - little too small, little too light but still moving with too high resistance on cloth mouse pad.
It is based on MX8731 all-in-one chip - optical sensor and USB device in one from Shenzhen LIZE Electronic Technology Co., Ltd.
Mouse wheel encoder is identical as in A4Tech X-708/X-710.

2016-08-25

RPS provisioning with yealink

It looks like awareness of security problems with yealink (and many other manufacturers for that matter) rised at the end of 2013:
https://freeswitch.org/raising-awareness-about-secure-phone-provisioning/
http://www.slideshare.net/sleepycal/auto-provisioning-sucks
Basically, if your phone can fetch configuration from publicly available server so can anybody else. There are no private certificates used, often no encryption of any kind at all. And what about yealink AES encryption? At first session phone fetches user-defined AES key for configuration file (y000000000000.cfg). This key is encrypted with AES and common key inside separate file (y000000000000_Security.enc).

Whiskey Tango Foxtrot

It shouldn't take long to recover common AES key either from windows/linux encryption tools provided by yealink or from phone firmware itself. Once it is known, AES key for configuration can be decrypted, then configuration can be decrypted (with operator configuration, including password) leading to toll frauds.

I know you're too lazy, I am too. Fear not, as someone found common AES key already:

# Yealink's encryption tool generates a "random" key using characters
# [a-zA-Z0-9].  It uses this key directly as a stream of bytes to
# encrypt the configuration file with AES-128-ECB.  Then it encrypts
# this key with a "common" key distributed as part of the firmware and
# the encryption tool and writes the result to a second file, also
# using AES-128-ECB.

encrypt () {
 local key="$1"
  openssl enc -aes-128-ecb -nopad \
    -K $(printf "$key" | xxd -p)
}

decrypt () {
  local key="$1"
  openssl enc -aes-128-ecb -d -nopad \
    -K $(printf "$key" | xxd -p)
}

encrypt_key () { encrypt 'EKs35XacP6eybA25'; }
decrypt_key () { decrypt 'EKs35XacP6eybA25'; }
encrypt_cfg () { encrypt "$1"; }
decrypt_cfg () { decrypt "$1"; }

test_lib () {
  printf "Test that key decryption/encryption produces identical results..."
  (decrypt_key < test/test_Security.enc | encrypt_key | diff test/test_Security.enc -) \
    && printf "Success\n" || printf "Failure\n"
  printf "Test that we produce identical encrypted configs..."
  local key=$(decrypt_key < test/test_Security.enc)
  (decrypt_cfg $key < test/test.cfg | encrypt_cfg $key | diff test/test.cfg -) \
    && printf "Success\n" || printf "Failure\n"
}



Source: https://github.com/traviscross/yealink-confenc.

2016-07-09

FreeSWITCH on Windows - first impression

Few notes from compiling and running FreeSWITCH on Windows

In the hope of getting help with some faxing/T.30 problems from great VS debugger I've built FreeSWITCH 1.6.8 for Windows. So far I can say that Windows version is well prepared as contrary to building under Linux (tested Ubuntu 14 LTS) it works out of the box (i.e. without solving dependency puzzle).

From what I remember some earlier FreeSWITCH versions supported multiple VS versions or at least contained project files for older and relatively lightweight VS2008. With FS 1.6.8 only VS2015 is supported. Although this IDE still has free versions I definitely dislike that Microsoft forces installation of Visual Basic (which I have absolutely no intent to use) while making C++ optional. With all that .net baggage be prepared for 9GB disk usage (+ few extra hundreds for IE 10/11 if you don't have it with Windows 7) for VS2015 Community.

FreeSWITCH groups multiple project files. Although it seemed to me that building just FreeSwitchConsole project and mod_sofia from Endpoints group would create minimal functional set - it you don't build other modules, at least one that you would in /conf/autoload_conf/modules.conf.xml after building basic executable you'll gonna have bad time... With XML dialplan files ignored you won't be able making basic calls.

Configuring and debugging requires lot of try-and-error for me thus I've opted to completely disable UPnP that adds significant delay to application startup. Modified switch_nat.c:
#if 0
    if (!nat_globals.nat_type) {
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Checking for UPnP\n");
        init_upnp();
    }
#endif


To add SIP operator create new configuration file in conf/sip_profiles/external/<operator_name>.xml.
To check operator status use
sofia status
or
sofia status gateway <sip_provider>
"REGED" means registered.

To add internal SIP extension (softphones, desk phones to register) create configuration files in conf/directory/default/. Default configuration contains already extensions with numbers 1000 - 1019. Edit vars.xml file to change default password (from 1234) for all these extension, I think they are disabled until it is done as log says:
CRIT WARNING WARNING WARNING WARNING WARNING WARNING
DESTINATION_OUT_OF_ORDER
Open vars.xml and change the default_password

To check internal extensions status use list_users command.

Other useful commands:
  • shutdown or ... = quit
  • show calls
  • reloadxml
  • sofia global siptrace on - log RX/TX SIP messages

2016-04-01

ELEKTRONIKA B6-03

Small flashlight powered by 3 NiCd button cells, rechargeable directly from mains with simple inductorless charger. Made in (late) USSR, probably in the early 90s. Surprisingly reliable and very economical in use.
After cleaning cell contacts (residue in a form of crystal needles, most likely rich in cadmium) it still charges and works.