# SOME DESCRIPTIVE TITLE. # This file is put in the public domain. # # Translators: # Flamarion Jorge , 2009. # Flamarion Jorge Flamarion , 2012. # Frédéric L. W. Meunier , 20, 2009. msgid "" msgstr "" "Project-Id-Version: HexChat\n" "Report-Msgid-Bugs-To: www.hexchat.org\n" "POT-Creation-Date: 2012-10-28 01:41+0200\n" "PO-Revision-Date: 2012-10-27 23:43+0000\n" "Last-Translator: bviktor \n" "Language-Team: Portuguese (Brazil) (http://www.transifex.com/projects/p/hexchat/language/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: src/common/cfgfiles.c:757 msgid "I'm busy" msgstr "Estou ocupado" #: src/common/cfgfiles.c:781 msgid "Leaving" msgstr "Sair" #: src/common/cfgfiles.c:841 msgid "" "* Running IRC as root is stupid! You should\n" " create a User Account and use that to login.\n" msgstr "* Executar IRC como root é estupido. Você pode\n criar uma conta de usuá¡rio e usa-la para fazer o login\n" #: src/common/dcc.c:84 msgid "Waiting" msgstr "Esperar" #: src/common/dcc.c:85 msgid "Active" msgstr "Ativar" #: src/common/dcc.c:86 msgid "Failed" msgstr "Falha" #: src/common/dcc.c:87 msgid "Done" msgstr "Feito" #: src/common/dcc.c:88 src/fe-gtk/menu.c:943 msgid "Connect" msgstr "Conectar" #: src/common/dcc.c:89 msgid "Aborted" msgstr "Abortar" #: src/common/dcc.c:1898 src/common/outbound.c:2508 #, c-format msgid "Cannot access %s\n" msgstr "Impossível acessar %s\n" #: src/common/dcc.c:1899 src/common/text.c:1441 src/common/text.c:1479 #: src/common/text.c:1490 src/common/text.c:1497 src/common/text.c:1510 #: src/common/text.c:1527 src/common/text.c:1627 src/common/util.c:357 msgid "Error" msgstr "Erro" #: src/common/dcc.c:2378 #, c-format msgid "%s is offering \"%s\". Do you want to accept?" msgstr "%s está oferecendo \"%s\". Você quer aceitar?" #: src/common/dcc.c:2593 msgid "No active DCCs\n" msgstr "Nenhum DCC ativo\n" #: src/common/hexchat.c:741 msgid "_Open Dialog Window" msgstr "_Abrir automaticamente janelas de diálogo" #: src/common/hexchat.c:742 msgid "_Send a File" msgstr "_Enviar um arquivo" #: src/common/hexchat.c:743 msgid "_User Info (WhoIs)" msgstr "" #: src/common/hexchat.c:744 msgid "_Add to Friends List" msgstr "" #: src/common/hexchat.c:745 msgid "_Ignore" msgstr "" #: src/common/hexchat.c:746 msgid "O_perator Actions" msgstr "" #: src/common/hexchat.c:748 msgid "Give Ops" msgstr "" #: src/common/hexchat.c:749 msgid "Take Ops" msgstr "" #: src/common/hexchat.c:750 msgid "Give Voice" msgstr "" #: src/common/hexchat.c:751 msgid "Take Voice" msgstr "" #: src/common/hexchat.c:753 msgid "Kick/Ban" msgstr "" #: src/common/hexchat.c:754 src/common/hexchat.c:791 msgid "Kick" msgstr "" #: src/common/hexchat.c:755 src/common/hexchat.c:756 src/common/hexchat.c:757 #: src/common/hexchat.c:758 src/common/hexchat.c:759 src/common/hexchat.c:790 msgid "Ban" msgstr "Banir" #: src/common/hexchat.c:760 src/common/hexchat.c:761 src/common/hexchat.c:762 #: src/common/hexchat.c:763 msgid "KickBan" msgstr "Expulsar" #: src/common/hexchat.c:773 msgid "Leave Channel" msgstr "Sair do canal" #: src/common/hexchat.c:774 msgid "Join Channel..." msgstr "Entrar no canal" #: src/common/hexchat.c:775 src/fe-gtk/menu.c:1337 msgid "Enter Channel to Join:" msgstr "Informe o canal para entrar:" #: src/common/hexchat.c:776 msgid "Server Links" msgstr "Links para servidores" #: src/common/hexchat.c:777 msgid "Ping Server" msgstr "Servidor de ping" #: src/common/hexchat.c:778 msgid "Hide Version" msgstr "Esconder versão" #: src/common/hexchat.c:788 msgid "Op" msgstr "" #: src/common/hexchat.c:789 msgid "DeOp" msgstr "" #: src/common/hexchat.c:792 msgid "bye" msgstr "" #: src/common/hexchat.c:793 #, c-format msgid "Enter reason to kick %s:" msgstr "" #: src/common/hexchat.c:794 msgid "Sendfile" msgstr "Enviar arquivo" #: src/common/hexchat.c:795 msgid "Dialog" msgstr "" #: src/common/hexchat.c:804 msgid "WhoIs" msgstr "" #: src/common/hexchat.c:805 msgid "Send" msgstr "Enviar" #: src/common/hexchat.c:806 msgid "Chat" msgstr "Conversar" #: src/common/hexchat.c:807 src/fe-gtk/banlist.c:411 #: src/fe-gtk/ignoregui.c:383 src/fe-gtk/urlgrab.c:212 msgid "Clear" msgstr "Limpar" #: src/common/hexchat.c:808 msgid "Ping" msgstr "Ping" #: src/common/ignore.c:125 src/common/ignore.c:129 src/common/ignore.c:133 #: src/common/ignore.c:137 src/common/ignore.c:141 src/common/ignore.c:145 #: src/common/ignore.c:149 msgid "YES " msgstr "SIM " #: src/common/ignore.c:127 src/common/ignore.c:131 src/common/ignore.c:135 #: src/common/ignore.c:139 src/common/ignore.c:143 src/common/ignore.c:147 #: src/common/ignore.c:151 msgid "NO " msgstr "NÃO " #: src/common/ignore.c:382 #, c-format msgid "You are being CTCP flooded from %s, ignoring %s\n" msgstr "Você está recebendo um CTCP flood de %s, ignorando %s\n\n" #: src/common/ignore.c:407 #, c-format msgid "You are being MSG flooded from %s, setting gui_auto_open_dialog OFF.\n" msgstr "Você está recebendo um MSG flood de %s, configurando gui_auto_open_dialog OFF.\n" #: src/common/notify.c:478 #, c-format msgid " %-20s online\n" msgstr " %-20s ligou\n" #: src/common/notify.c:480 #, c-format msgid " %-20s offline\n" msgstr " %-20s desligou\n" #: src/common/outbound.c:72 msgid "No channel joined. Try /join #\n" msgstr "Não entrou em nenhum canal. Tente /join #\n" #: src/common/outbound.c:78 msgid "Not connected. Try /server []\n" msgstr "Não conectado. Tente /server [porta]\n" #: src/common/outbound.c:281 #, c-format msgid "Server %s already exists on network %s.\n" msgstr "Servidor %s já existe na rede %s.\n" #: src/common/outbound.c:287 #, c-format msgid "Added server %s to network %s.\n" msgstr "Servidor %s adicionado na rede %s.\n" #: src/common/outbound.c:373 #, c-format msgid "Already marked away: %s\n" msgstr "Já marcado como ausente: %s\n" #: src/common/outbound.c:446 msgid "Already marked back.\n" msgstr "Já marcado como de volta\n" #: src/common/outbound.c:1812 msgid "I need /bin/sh to run!\n" msgstr "Eu preciso de /bin/sh para executar!\n" #: src/common/outbound.c:2181 msgid "Commands Available:" msgstr "Comandos disponíveis:" #: src/common/outbound.c:2195 msgid "User defined commands:" msgstr "Comandos personalizados:" #: src/common/outbound.c:2211 msgid "Plugin defined commands:" msgstr "Comandos de plugin definidos:" #: src/common/outbound.c:2222 msgid "Type /HELP for more information, or /HELP -l" msgstr "" #: src/common/outbound.c:2306 #, c-format msgid "Unknown arg '%s' ignored." msgstr "Argumento desconhecido \"%s\" ignorado." #: src/common/outbound.c:3280 msgid "No such plugin found.\n" msgstr "Plugin não encontrado\n" #: src/common/outbound.c:3285 src/fe-gtk/plugingui.c:207 msgid "That plugin is refusing to unload.\n" msgstr "Este plugin está recusando a descarregar\n" #: src/common/outbound.c:3554 msgid "ADDBUTTON , adds a button under the user-list" msgstr "" #: src/common/outbound.c:3555 msgid "" "ADDSERVER , adds a new network with a new " "server to the network list" msgstr "" #: src/common/outbound.c:3557 msgid "ALLCHAN , sends a command to all channels you're in" msgstr "" #: src/common/outbound.c:3559 msgid "ALLCHANL , sends a command to all channels on the current server" msgstr "" #: src/common/outbound.c:3561 msgid "ALLSERV , sends a command to all servers you're in" msgstr "" #: src/common/outbound.c:3562 msgid "AWAY [], sets you away" msgstr "" #: src/common/outbound.c:3563 msgid "BACK, sets you back (not away)" msgstr "" #: src/common/outbound.c:3565 msgid "" "BAN [], bans everyone matching the mask from the current " "channel. If they are already on the channel this doesn't kick them (needs " "chanop)" msgstr "" #: src/common/outbound.c:3566 msgid "CHANOPT [-quiet] []" msgstr "" #: src/common/outbound.c:3567 msgid "" "CHARSET [], get or set the encoding used for the current " "connection" msgstr "" #: src/common/outbound.c:3568 msgid "CLEAR [ALL|HISTORY], Clears the current text window or command history" msgstr "" #: src/common/outbound.c:3569 msgid "CLOSE, Closes the current window/tab" msgstr "" #: src/common/outbound.c:3572 msgid "COUNTRY [-s] , finds a country code, eg: au = australia" msgstr "" #: src/common/outbound.c:3574 msgid "" "CTCP , send the CTCP message to nick, common messages are " "VERSION and USERINFO" msgstr "" #: src/common/outbound.c:3576 msgid "" "CYCLE [], parts the current or given channel and immediately " "rejoins" msgstr "" #: src/common/outbound.c:3578 msgid "" "\n" "DCC GET - accept an offered file\n" "DCC SEND [-maxcps=#] [file] - send a file to someone\n" "DCC PSEND [-maxcps=#] [file] - send a file using passive mode\n" "DCC LIST - show DCC list\n" "DCC CHAT - offer DCC CHAT to someone\n" "DCC PCHAT - offer DCC CHAT using passive mode\n" "DCC CLOSE example:\n" " /dcc close send johnsmith file.tar.gz" msgstr "" #: src/common/outbound.c:3590 msgid "" "DEHOP , removes chanhalf-op status from the nick on the current " "channel (needs chanop)" msgstr "" #: src/common/outbound.c:3592 msgid "DELBUTTON , deletes a button from under the user-list" msgstr "" #: src/common/outbound.c:3594 msgid "" "DEOP , removes chanop status from the nick on the current channel " "(needs chanop)" msgstr "" #: src/common/outbound.c:3596 msgid "" "DEVOICE , removes voice status from the nick on the current channel " "(needs chanop)" msgstr "" #: src/common/outbound.c:3597 msgid "DISCON, Disconnects from server" msgstr "" #: src/common/outbound.c:3598 msgid "DNS , Finds a users IP number" msgstr "" #: src/common/outbound.c:3599 msgid "ECHO , Prints text locally" msgstr "" #: src/common/outbound.c:3602 msgid "" "EXEC [-o] , runs the command. If -o flag is used then output is " "sent to current channel, else is printed to current text box" msgstr "" #: src/common/outbound.c:3604 msgid "EXECCONT, sends the process SIGCONT" msgstr "" #: src/common/outbound.c:3607 msgid "" "EXECKILL [-9], kills a running exec in the current session. If -9 is given " "the process is SIGKILL'ed" msgstr "" #: src/common/outbound.c:3609 msgid "EXECSTOP, sends the process SIGSTOP" msgstr "" #: src/common/outbound.c:3610 msgid "EXECWRITE, sends data to the processes stdin" msgstr "" #: src/common/outbound.c:3614 msgid "FLUSHQ, flushes the current server's send queue" msgstr "" #: src/common/outbound.c:3616 msgid "GATE [], proxies through a host, port defaults to 23" msgstr "" #: src/common/outbound.c:3620 msgid "GHOST [password], Kills a ghosted nickname" msgstr "" #: src/common/outbound.c:3625 msgid "HOP , gives chanhalf-op status to the nick (needs chanop)" msgstr "" #: src/common/outbound.c:3626 msgid "ID , identifies yourself to nickserv" msgstr "" #: src/common/outbound.c:3628 msgid "" "IGNORE \n" " mask - host mask to ignore, eg: *!*@*.aol.com\n" " types - types of data to ignore, one or all of:\n" " PRIV, CHAN, NOTI, CTCP, DCC, INVI, ALL\n" " options - NOSAVE, QUIET" msgstr "" #: src/common/outbound.c:3635 msgid "" "INVITE [], invites someone to a channel, by default the " "current channel (needs chanop)" msgstr "" #: src/common/outbound.c:3636 msgid "JOIN , joins the channel" msgstr "" #: src/common/outbound.c:3638 msgid "KICK , kicks the nick from the current channel (needs chanop)" msgstr "" #: src/common/outbound.c:3640 msgid "" "KICKBAN , bans then kicks the nick from the current channel (needs " "chanop)" msgstr "" #: src/common/outbound.c:3643 msgid "LAGCHECK, forces a new lag check" msgstr "" #: src/common/outbound.c:3645 msgid "" "LASTLOG [-h] [-m] [-r] [--] , searches for a string in the buffer\n" " Use -h to highlight the found string(s)\n" " Use -m to match case\n" " Use -r when string is a Regular Expression\n" " Use -- (double hyphen) to end options when searching for, say, the string '-r'" msgstr "" #: src/common/outbound.c:3651 msgid "LOAD [-e] , loads a plugin or script" msgstr "LOAD [-e] , carrega um plug-in ou script" #: src/common/outbound.c:3654 msgid "" "MDEHOP, Mass deop's all chanhalf-ops in the current channel (needs chanop)" msgstr "" #: src/common/outbound.c:3656 msgid "MDEOP, Mass deop's all chanops in the current channel (needs chanop)" msgstr "" #: src/common/outbound.c:3658 msgid "" "ME , sends the action to the current channel (actions are written in" " the 3rd person, like /me jumps)" msgstr "" #: src/common/outbound.c:3662 msgid "" "MKICK, Mass kicks everyone except you in the current channel (needs chanop)" msgstr "" #: src/common/outbound.c:3665 msgid "MOP, Mass op's all users in the current channel (needs chanop)" msgstr "" #: src/common/outbound.c:3666 msgid "MSG , sends a private message" msgstr "" #: src/common/outbound.c:3669 msgid "NAMES, Lists the nicks on the current channel" msgstr "" #: src/common/outbound.c:3671 msgid "NCTCP , Sends a CTCP notice" msgstr "" #: src/common/outbound.c:3672 msgid "NEWSERVER [-noconnect] []" msgstr "" #: src/common/outbound.c:3673 msgid "NICK , sets your nick" msgstr "" #: src/common/outbound.c:3676 msgid "" "NOTICE , sends a notice. Notices are a type of " "message that should be auto reacted to" msgstr "" #: src/common/outbound.c:3678 msgid "" "NOTIFY [-n network1[,network2,...]] [], displays your notify list or " "adds someone to it" msgstr "" #: src/common/outbound.c:3680 msgid "OP , gives chanop status to the nick (needs chanop)" msgstr "" #: src/common/outbound.c:3682 msgid "" "PART [] [], leaves the channel, by default the current one" msgstr "" #: src/common/outbound.c:3684 msgid "PING , CTCP pings nick or channel" msgstr "" #: src/common/outbound.c:3686 msgid "QUERY [-nofocus] , opens up a new privmsg window to someone" msgstr "" #: src/common/outbound.c:3688 msgid "QUIT [], disconnects from the current server" msgstr "" #: src/common/outbound.c:3690 msgid "QUOTE , sends the text in raw form to the server" msgstr "" #: src/common/outbound.c:3693 msgid "" "RECONNECT [-ssl] [] [] [], Can be called just as " "/RECONNECT to reconnect to the current server or with /RECONNECT ALL to " "reconnect to all the open servers" msgstr "" #: src/common/outbound.c:3696 msgid "" "RECONNECT [] [] [], Can be called just as /RECONNECT " "to reconnect to the current server or with /RECONNECT ALL to reconnect to " "all the open servers" msgstr "" #: src/common/outbound.c:3698 msgid "" "RECV , send raw data to xchat, as if it was received from the irc " "server" msgstr "" #: src/common/outbound.c:3701 msgid "SAY , sends the text to the object in the current window" msgstr "" #: src/common/outbound.c:3702 msgid "SEND []" msgstr "" #: src/common/outbound.c:3705 msgid "SERVCHAN [-ssl] , connects and joins a channel" msgstr "" #: src/common/outbound.c:3708 msgid "SERVCHAN , connects and joins a channel" msgstr "" #: src/common/outbound.c:3712 msgid "" "SERVER [-ssl] [] [], connects to a server, the " "default port is 6667 for normal connections, and 6697 for ssl connections" msgstr "" #: src/common/outbound.c:3715 msgid "" "SERVER [] [], connects to a server, the default port " "is 6667" msgstr "" #: src/common/outbound.c:3717 msgid "SET [-e] [-off|-on] [-quiet] []" msgstr "" #: src/common/outbound.c:3718 msgid "SETCURSOR [-|+], reposition the cursor in the inputbox" msgstr "" #: src/common/outbound.c:3719 msgid "SETTAB , change a tab's name, tab_trunc limit still applies" msgstr "" #: src/common/outbound.c:3720 msgid "SETTEXT , replace the text in the input box" msgstr "" #: src/common/outbound.c:3723 msgid "" "TOPIC [], sets the topic if one is given, else shows the current " "topic" msgstr "" #: src/common/outbound.c:3725 msgid "" "\n" "TRAY -f [] Blink tray between two icons.\n" "TRAY -f Set tray to a fixed icon.\n" "TRAY -i Blink tray with an internal icon.\n" "TRAY -t Set the tray tooltip.\n" "TRAY -b <text> Set the tray balloon." msgstr "" #: src/common/outbound.c:3732 msgid "UNBAN <mask> [<mask>...], unbans the specified masks." msgstr "" #: src/common/outbound.c:3733 msgid "UNIGNORE <mask> [QUIET]" msgstr "" #: src/common/outbound.c:3734 msgid "UNLOAD <name>, unloads a plugin or script" msgstr "UNLOAD <nome>, descarrega um plug-in ou script" #: src/common/outbound.c:3735 msgid "URL <url>, opens a URL in your browser" msgstr "" #: src/common/outbound.c:3737 msgid "" "USELECT [-a] [-s] <nick1> <nick2> etc, highlights nick(s) in channel " "userlist" msgstr "" #: src/common/outbound.c:3740 msgid "VOICE <nick>, gives voice status to someone (needs chanop)" msgstr "" #: src/common/outbound.c:3742 msgid "WALLCHAN <message>, writes the message to all channels" msgstr "" #: src/common/outbound.c:3744 msgid "" "WALLCHOP <message>, sends the message to all chanops on the current channel" msgstr "" #: src/common/outbound.c:3777 #, c-format msgid "Usage: %s\n" msgstr "Uso: %s\n" #: src/common/outbound.c:3782 msgid "" "\n" "No help available on that command.\n" msgstr "" #: src/common/outbound.c:3788 msgid "No such command.\n" msgstr "" #: src/common/outbound.c:4119 msgid "Bad arguments for user command.\n" msgstr "" #: src/common/outbound.c:4279 msgid "Too many recursive usercommands, aborting." msgstr "" #: src/common/outbound.c:4362 msgid "Unknown Command. Try /help\n" msgstr "" #: src/common/plugin.c:382 src/common/plugin.c:423 msgid "No xchat_plugin_init symbol; is this really an xchat plugin?" msgstr "" #: src/common/server.c:665 msgid "Are you sure this is a SSL capable server and port?\n" msgstr "" #: src/common/server.c:1033 #, c-format msgid "" "Cannot resolve hostname %s\n" "Check your IP Settings!\n" msgstr "" #: src/common/server.c:1038 msgid "Proxy traversal failed.\n" msgstr "" #: src/common/servlist.c:747 #, c-format msgid "Cycling to next server in %s...\n" msgstr "" #: src/common/servlist.c:1213 #, c-format msgid "" "Warning: \"%s\" character set is unknown. No conversion will be applied for " "network %s." msgstr "" #: src/common/textevents.h:6 msgid "%C18*%O$t%C18$1%O added to notify list." msgstr "" #: src/common/textevents.h:9 msgid "%C22*%O$t%C22$1%O Banlist:%C18 $2%O for%C24 $4%O by%C26 $3%O" msgstr "" #: src/common/textevents.h:12 msgid "%C22*%O$tCannot join%C22 $1 %O(%C20You are banned%O)." msgstr "" #: src/common/textevents.h:18 msgid "%C24*%O$t%C28$1%O is now known as%C18 $2%O" msgstr "" #: src/common/textevents.h:27 msgid "%C22*%O$t%C26$1%O sets ban on %C18$2%O" msgstr "" #: src/common/textevents.h:30 msgid "%C22*%O$tChannel %C22$1%O created" msgstr "" #: src/common/textevents.h:33 msgid "%C22*%O$t%C26$1%O removes channel half-operator status from %C18$2%O" msgstr "" #: src/common/textevents.h:36 msgid "%C22*%O$t%C26$1%O removes channel operator status from %C18$2%O" msgstr "" #: src/common/textevents.h:39 msgid "%C22*%O$t%C26$1%O removes voice from %C18$2%O" msgstr "" #: src/common/textevents.h:42 msgid "%C22*%O$t%C26 $1%C sets exempt on %C18$2%O" msgstr "" #: src/common/textevents.h:45 msgid "%C22*%O$t%C26$1%O gives channel half-operator status to %C18$2%O" msgstr "" #: src/common/textevents.h:48 msgid "%C22*%O$t%C26 $1%C sets invite on %C18$2%O" msgstr "" #: src/common/textevents.h:51 msgid "%UChannel Users Topic" msgstr "" #: src/common/textevents.h:57 msgid "%C22*%O$t%C26$1%O sets mode %C24$2$3%O on %C22$4%O" msgstr "" #: src/common/textevents.h:60 msgid "%C22*%O$tChannel %C22$1%O modes: %C24$2" msgstr "" #: src/common/textevents.h:69 msgid "%C22*%O$t%C26$1%O gives channel operator status to %C18$2%O" msgstr "" #: src/common/textevents.h:72 msgid "%C22*%O$t%C26$1%O removes exempt on %C18$2%O" msgstr "" #: src/common/textevents.h:75 msgid "%C22*%O$t%C26 $1%O removes invite on %C18$2%O" msgstr "" #: src/common/textevents.h:78 msgid "%C22*%O$t%C26$1%O removes channel keyword" msgstr "" #: src/common/textevents.h:81 msgid "%C22*%O$t%C26$1%O removes user limit" msgstr "" #: src/common/textevents.h:84 msgid "%C22*%O$t$1 sets channel keyword to %C24$2%O" msgstr "" #: src/common/textevents.h:87 msgid "%C22*%O$t%C26$1%O sets channel limit to %C24$2%O" msgstr "" #: src/common/textevents.h:90 msgid "%C22*%O$t%C26$1%O removes ban on %C24$2%O" msgstr "" #: src/common/textevents.h:93 msgid "%C22*%O$t%C26$1%O gives voice to %C18$2%O" msgstr "" #: src/common/textevents.h:96 msgid "%C23*%O$tConnected. Now logging in." msgstr "" #: src/common/textevents.h:99 msgid "%C23*%O$tConnecting to %C29$1%C (%C23$2:$3%O)" msgstr "" #: src/common/textevents.h:102 msgid "%C20*%O$tConnection failed (%C20$1%O)" msgstr "" #: src/common/textevents.h:105 msgid "%C24*%O$tReceived a CTCP %C24$1%C from %C18$2%O" msgstr "" #: src/common/textevents.h:108 msgid "%C24*%C$tReceived a CTCP %C24$1%C from %C18$2%C (to %C22$3%C)%O" msgstr "" #: src/common/textevents.h:111 msgid ">%C18$1%C<$tCTCP %C24$2%O" msgstr "" #: src/common/textevents.h:114 msgid "%C24*%O$tReceived a CTCP Sound %C24$1%C from %C18$2%O" msgstr "" #: src/common/textevents.h:117 msgid "%C24*%O$tReceived a CTCP Sound %C24$1%C from %C18$2%C (to %C22$3%O)" msgstr "" #: src/common/textevents.h:120 msgid "%C23*%O$tDCC CHAT to %C18$1%O aborted." msgstr "" #: src/common/textevents.h:123 msgid "" "%C24*%O$tDCC CHAT connection established to %C18$1%C %C30[%C24$2%C30]%O" msgstr "" #: src/common/textevents.h:126 msgid "%C20*%O$tDCC CHAT to %C18$1%O lost (%C20$4%O)" msgstr "" #: src/common/textevents.h:129 msgid "%C24*%O$tReceived a DCC CHAT offer from %C18$1%O" msgstr "" #: src/common/textevents.h:132 msgid "%C24*%O$tOffering DCC CHAT to %C18$1%O" msgstr "" #: src/common/textevents.h:135 msgid "%C24*%O$tAlready offering CHAT to %C18$1%O" msgstr "" #: src/common/textevents.h:138 msgid "%C20*%O$tDCC $1 connect attempt to %C18$2%O failed (%C20$3%O)" msgstr "" #: src/common/textevents.h:141 msgid "%C23*%O$tReceived '%C23$1%C' from %C18$2%O" msgstr "" #: src/common/textevents.h:144 #, c-format msgid "%C16,17 Type To/From Status Size Pos File " msgstr "" #: src/common/textevents.h:147 msgid "" "%C20*%O$tReceived a malformed DCC request from " "%C18$1%O.%010%C23*%O$tContents of packet: %C23$2%O" msgstr "" #: src/common/textevents.h:150 msgid "%C24*%O$tOffering '%C24$1%O' to %C18$2%O" msgstr "" #: src/common/textevents.h:153 msgid "%C23*%O$tNo such DCC offer." msgs<style>pre { line-height: 125%; } td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */</style><div class="highlight"><pre><span></span><span class="cm">/* X-Chat</span> <span class="cm"> * Copyright (C) 1998 Peter Zelezny.</span> <span class="cm"> *</span> <span class="cm"> * This program is free software; you can redistribute it and/or modify</span> <span class="cm"> * it under the terms of the GNU General Public License as published by</span> <span class="cm"> * the Free Software Foundation; either version 2 of the License, or</span> <span class="cm"> * (at your option) any later version.</span> <span class="cm"> *</span> <span class="cm"> * This program is distributed in the hope that it will be useful,</span> <span class="cm"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <span class="cm"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span> <span class="cm"> * GNU General Public License for more details.</span> <span class="cm"> *</span> <span class="cm"> * You should have received a copy of the GNU General Public License</span> <span class="cm"> * along with this program; if not, write to the Free Software</span> <span class="cm"> * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA</span> <span class="cm"> *</span> <span class="cm"> * MS Proxy (ISA server) support is (c) 2006 Pavel Fedin <sonic_amiga@rambler.ru></span> <span class="cm"> * based on Dante source code</span> <span class="cm"> * Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006</span> <span class="cm"> * Inferno Nettverk A/S, Norway. All rights reserved.</span> <span class="cm"> */</span> <span class="cm">/*#define DEBUG_MSPROXY*/</span> <span class="cp">#include</span><span class="w"> </span><span class="cpf"><stdio.h></span> <span class="cp">#include</span><span class="w"> </span><span class="cpf"><string.h></span> <span class="cp">#include</span><span class="w"> </span><span class="cpf"><stdlib.h></span> <span class="cp">#include</span><span class="w"> </span><span class="cpf"><fcntl.h></span> <span class="cp">#ifndef WIN32</span> <span class="cp">#include</span><span class="w"> </span><span class="cpf"><unistd.h></span> <span class="cp">#endif</span> <span class="cp">#define WANTSOCKET</span> <span class="cp">#define WANTARPA</span> <span class="cp">#include</span><span class="w"> </span><span class="cpf">"inet.h"</span> <span class="cp">#include</span><span class="w"> </span><span class="cpf">"xchat.h"</span> <span class="cp">#include</span><span class="w"> </span><span class="cpf">"network.h"</span> <span class="cp">#include</span><span class="w"> </span><span class="cpf">"xchatc.h"</span> <span class="cp">#include</span><span class="w"> </span><span class="cpf">"server.h"</span> <span class="cp">#include</span><span class="w"> </span><span class="cpf">"msproxy.h"</span> <span class="cp">#ifdef USE_MSPROXY</span> <span class="cp">#include</span><span class="w"> </span><span class="cpf"><ntlm.h></span> <span class="k">static</span><span class="w"> </span><span class="kt">int</span> <span class="nf">send_msprequest</span><span class="p">(</span><span class="n">s</span><span class="p">,</span><span class="w"> </span><span class="n">state</span><span class="p">,</span><span class="w"> </span><span class="n">request</span><span class="p">,</span><span class="w"> </span><span class="n">end</span><span class="p">)</span> <span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">s</span><span class="p">;</span> <span class="w"> </span><span class="k">struct</span><span class="w"> </span><span class="nc">msproxy_state_t</span><span class="w"> </span><span class="o">*</span><span class="n">state</span><span class="p">;</span> <span class="w"> </span><span class="k">struct</span><span class="w"> </span><span class="nc">msproxy_request_t</span><span class="w"> </span><span class="o">*</span><span class="n">request</span><span class="p">;</span> <span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">end</span><span class="p">;</span> <span class="p">{</span> <span class="w"> </span><span class="kt">ssize_t</span><span class="w"> </span><span class="n">w</span><span class="p">;</span> <span class="w"> </span><span class="kt">size_t</span><span class="w"> </span><span class="n">l</span><span class="p">;</span> <span class="w"> </span><span class="n">request</span><span class="o">-></span><span class="n">magic25</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htonl</span><span class="p">(</span><span class="n">MSPROXY_VERSION</span><span class="p">);</span> <span class="w"> </span><span class="n">request</span><span class="o">-></span><span class="n">serverack</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">seq_recv</span><span class="p">;</span> <span class="w"> </span><span class="cm">/* don't start incrementing sequence until we are acking packet #2. */</span> <span class="w"> </span><span class="n">request</span><span class="o">-></span><span class="n">sequence</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="kt">unsigned</span><span class="w"> </span><span class="kt">char</span><span class="p">)(</span><span class="n">request</span><span class="o">-></span><span class="n">serverack</span><span class="w"> </span><span class="o">>=</span><span class="w"> </span><span class="mi">2</span><span class="w"> </span><span class="o">?</span><span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">seq_sent</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="mi">0</span><span class="p">);</span> <span class="w"> </span><span class="n">memcpy</span><span class="p">(</span><span class="n">request</span><span class="o">-></span><span class="n">RWSP</span><span class="p">,</span><span class="w"> </span><span class="s">"RWSP"</span><span class="p">,</span><span class="w"> </span><span class="k">sizeof</span><span class="p">(</span><span class="n">request</span><span class="o">-></span><span class="n">RWSP</span><span class="p">));</span> <span class="w"> </span><span class="n">l</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">end</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="p">(</span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="p">)</span><span class="n">request</span><span class="p">;</span> <span class="w"> </span><span class="cm">/* all requests must be atleast MSPROXY_MINLENGTH it seems. */</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">l</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">MSPROXY_MINLENGTH</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="n">bzero</span><span class="p">(</span><span class="n">end</span><span class="p">,</span><span class="w"> </span><span class="p">(</span><span class="kt">size_t</span><span class="p">)(</span><span class="n">MSPROXY_MINLENGTH</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">l</span><span class="p">));</span> <span class="w"> </span><span class="n">l</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">MSPROXY_MINLENGTH</span><span class="p">;</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">((</span><span class="n">w</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">send</span><span class="p">(</span><span class="n">s</span><span class="p">,</span><span class="w"> </span><span class="n">request</span><span class="p">,</span><span class="w"> </span><span class="n">l</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">))</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="n">l</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="cp">#ifdef DEBUG_MSPROXY</span> <span class="w"> </span><span class="n">printf</span><span class="w"> </span><span class="p">(</span><span class="s">"send_msprequest(): send() failed (%d bytes sent instead of %d</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="w"> </span><span class="n">w</span><span class="p">,</span><span class="w"> </span><span class="n">l</span><span class="p">);</span> <span class="w"> </span><span class="n">perror</span><span class="w"> </span><span class="p">(</span><span class="s">"Error is"</span><span class="p">);</span> <span class="cp">#endif</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">-1</span><span class="p">;</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">seq_sent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">request</span><span class="o">-></span><span class="n">sequence</span><span class="p">;</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">w</span><span class="p">;</span> <span class="p">}</span> <span class="k">static</span><span class="w"> </span><span class="kt">int</span> <span class="n">recv_mspresponse</span><span class="p">(</span><span class="n">s</span><span class="p">,</span><span class="w"> </span><span class="n">state</span><span class="p">,</span><span class="w"> </span><span class="n">response</span><span class="p">)</span> <span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">s</span><span class="p">;</span> <span class="w"> </span><span class="k">struct</span><span class="w"> </span><span class="nc">msproxy_state_t</span><span class="w"> </span><span class="o">*</span><span class="n">state</span><span class="p">;</span> <span class="w"> </span><span class="k">struct</span><span class="w"> </span><span class="nc">msproxy_response_t</span><span class="w"> </span><span class="o">*</span><span class="n">response</span><span class="p">;</span> <span class="p">{</span> <span class="w"> </span><span class="kt">ssize_t</span><span class="w"> </span><span class="n">r</span><span class="p">;</span> <span class="w"> </span><span class="k">do</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">((</span><span class="n">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">recv</span><span class="w"> </span><span class="p">(</span><span class="n">s</span><span class="p">,</span><span class="w"> </span><span class="n">response</span><span class="p">,</span><span class="w"> </span><span class="k">sizeof</span><span class="w"> </span><span class="p">(</span><span class="o">*</span><span class="n">response</span><span class="p">),</span><span class="w"> </span><span class="mi">0</span><span class="p">))</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">MSPROXY_MINLENGTH</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="cp">#ifdef DEBUG_MSPROXY</span> <span class="w"> </span><span class="n">printf</span><span class="w"> </span><span class="p">(</span><span class="s">"recv_mspresponse(): expected to read atleast %d, read %d</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="w"> </span><span class="n">MSPROXY_MINLENGTH</span><span class="p">,</span><span class="w"> </span><span class="n">r</span><span class="p">);</span> <span class="cp">#endif</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">-1</span><span class="p">;</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">state</span><span class="o">-></span><span class="n">seq_recv</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="p">)</span> <span class="w"> </span><span class="k">break</span><span class="p">;</span><span class="w"> </span><span class="cm">/* not started incrementing yet. */</span> <span class="cp">#ifdef DEBUG_MSPROXY</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">response</span><span class="o">-></span><span class="n">sequence</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">seq_recv</span><span class="p">)</span> <span class="w"> </span><span class="n">printf</span><span class="w"> </span><span class="p">(</span><span class="s">"seq_recv: %d, dup response, seqnumber: 0x%x</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">seq_recv</span><span class="p">,</span><span class="w"> </span><span class="n">response</span><span class="o">-></span><span class="n">sequence</span><span class="p">);</span> <span class="cp">#endif</span> <span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="n">response</span><span class="o">-></span><span class="n">sequence</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">seq_recv</span><span class="p">);</span> <span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">seq_recv</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">response</span><span class="o">-></span><span class="n">sequence</span><span class="p">;</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">r</span><span class="p">;</span> <span class="p">}</span> <span class="kt">int</span> <span class="n">traverse_msproxy</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">sok</span><span class="p">,</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">serverAddr</span><span class="p">,</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">port</span><span class="p">,</span><span class="w"> </span><span class="k">struct</span><span class="w"> </span><span class="nc">msproxy_state_t</span><span class="w"> </span><span class="o">*</span><span class="n">state</span><span class="p">,</span><span class="w"> </span><span class="n">netstore</span><span class="w"> </span><span class="o">*</span><span class="n">ns_proxy</span><span class="p">,</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">csok4</span><span class="p">,</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">csok6</span><span class="p">,</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="o">*</span><span class="n">csok</span><span class="p">,</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="n">bound</span><span class="p">)</span> <span class="p">{</span> <span class="w"> </span><span class="k">struct</span><span class="w"> </span><span class="nc">msproxy_request_t</span><span class="w"> </span><span class="n">req</span><span class="p">;</span> <span class="w"> </span><span class="k">struct</span><span class="w"> </span><span class="nc">msproxy_response_t</span><span class="w"> </span><span class="n">res</span><span class="p">;</span> <span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">data</span><span class="p">,</span><span class="w"> </span><span class="o">*</span><span class="n">p</span><span class="p">;</span> <span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="n">hostname</span><span class="p">[</span><span class="n">NT_MAXNAMELEN</span><span class="p">];</span> <span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="n">ntdomain</span><span class="p">[</span><span class="n">NT_MAXNAMELEN</span><span class="p">];</span> <span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="n">challenge</span><span class="p">[</span><span class="mi">8</span><span class="p">];</span> <span class="w"> </span><span class="n">netstore</span><span class="w"> </span><span class="o">*</span><span class="n">ns_client</span><span class="p">;</span> <span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">clientport</span><span class="p">;</span> <span class="w"> </span><span class="n">guint32</span><span class="w"> </span><span class="n">destaddr</span><span class="p">;</span> <span class="w"> </span><span class="n">guint32</span><span class="w"> </span><span class="n">flags</span><span class="p">;</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="o">!</span><span class="n">prefs</span><span class="p">.</span><span class="n">proxy_auth</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="o">!</span><span class="n">prefs</span><span class="p">.</span><span class="n">proxy_user</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="o">!</span><span class="n">prefs</span><span class="p">.</span><span class="n">proxy_pass</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="w"> </span><span class="p">)</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="cm">/* MS proxy protocol implementation currently doesn't support IPv6 */</span> <span class="w"> </span><span class="n">destaddr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">net_getsockaddr_v4</span><span class="w"> </span><span class="p">(</span><span class="n">ns_proxy</span><span class="p">);</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="o">!</span><span class="n">destaddr</span><span class="p">)</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">seq_recv</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span> <span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">seq_sent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span> <span class="cp">#ifdef DEBUG_MSPROXY</span> <span class="w"> </span><span class="n">printf</span><span class="w"> </span><span class="p">(</span><span class="s">"Connecting to %s:%d via MS proxy</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="w"> </span><span class="n">serverAddr</span><span class="p">,</span><span class="w"> </span><span class="n">port</span><span class="p">);</span> <span class="cp">#endif</span> <span class="w"> </span><span class="n">gethostname</span><span class="w"> </span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span><span class="w"> </span><span class="n">NT_MAXNAMELEN</span><span class="p">);</span> <span class="w"> </span><span class="n">p</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">strchr</span><span class="w"> </span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span><span class="w"> </span><span class="sc">'.'</span><span class="p">);</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">p</span><span class="p">)</span> <span class="w"> </span><span class="o">*</span><span class="n">p</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="sc">'\0'</span><span class="p">;</span> <span class="w"> </span><span class="n">bzero</span><span class="w"> </span><span class="p">(</span><span class="o">&</span><span class="n">req</span><span class="p">,</span><span class="w"> </span><span class="k">sizeof</span><span class="p">(</span><span class="n">req</span><span class="p">));</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">clientid</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htonl</span><span class="p">(</span><span class="mh">0x0a000000</span><span class="p">);</span><span class="w"> </span><span class="cm">/* Initial client ID is always 0x0a */</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">command</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htons</span><span class="p">(</span><span class="n">MSPROXY_HELLO</span><span class="p">);</span><span class="w"> </span><span class="cm">/* HELLO command */</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">hello</span><span class="p">.</span><span class="n">magic5</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htons</span><span class="p">(</span><span class="mh">0x4b00</span><span class="p">);</span><span class="w"> </span><span class="cm">/* Fill in magic values */</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">hello</span><span class="p">.</span><span class="n">magic10</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htons</span><span class="p">(</span><span class="mh">0x1400</span><span class="p">);</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">hello</span><span class="p">.</span><span class="n">magic15</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htons</span><span class="p">(</span><span class="mh">0x0400</span><span class="p">);</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">hello</span><span class="p">.</span><span class="n">magic20</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htons</span><span class="p">(</span><span class="mh">0x5704</span><span class="p">);</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">hello</span><span class="p">.</span><span class="n">magic25</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htons</span><span class="p">(</span><span class="mh">0x0004</span><span class="p">);</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">hello</span><span class="p">.</span><span class="n">magic30</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htons</span><span class="p">(</span><span class="mh">0x0100</span><span class="p">);</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">hello</span><span class="p">.</span><span class="n">magic35</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htons</span><span class="p">(</span><span class="mh">0x4a02</span><span class="p">);</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">hello</span><span class="p">.</span><span class="n">magic40</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htons</span><span class="p">(</span><span class="mh">0x3000</span><span class="p">);</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">hello</span><span class="p">.</span><span class="n">magic45</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htons</span><span class="p">(</span><span class="mh">0x4400</span><span class="p">);</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">hello</span><span class="p">.</span><span class="n">magic50</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htons</span><span class="p">(</span><span class="mh">0x3900</span><span class="p">);</span> <span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">hello</span><span class="p">.</span><span class="n">data</span><span class="p">;</span> <span class="w"> </span><span class="n">strcpy</span><span class="w"> </span><span class="p">(</span><span class="n">data</span><span class="p">,</span><span class="w"> </span><span class="n">prefs</span><span class="p">.</span><span class="n">proxy_user</span><span class="p">);</span><span class="w"> </span><span class="cm">/* Append a username */</span> <span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">strlen</span><span class="w"> </span><span class="p">(</span><span class="n">prefs</span><span class="p">.</span><span class="n">proxy_user</span><span class="p">)</span><span class="o">+</span><span class="mi">2</span><span class="p">;</span><span class="w"> </span><span class="cm">/* +2 automatically creates second empty string */</span> <span class="w"> </span><span class="n">strcpy</span><span class="w"> </span><span class="p">(</span><span class="n">data</span><span class="p">,</span><span class="w"> </span><span class="n">MSPROXY_EXECUTABLE</span><span class="p">);</span><span class="w"> </span><span class="cm">/* Append an application name */</span> <span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">strlen</span><span class="w"> </span><span class="p">(</span><span class="n">MSPROXY_EXECUTABLE</span><span class="p">)</span><span class="o">+</span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="n">strcpy</span><span class="w"> </span><span class="p">(</span><span class="n">data</span><span class="p">,</span><span class="w"> </span><span class="n">hostname</span><span class="p">);</span><span class="w"> </span><span class="cm">/* Append a hostname */</span> <span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">strlen</span><span class="w"> </span><span class="p">(</span><span class="n">hostname</span><span class="p">)</span><span class="o">+</span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">send_msprequest</span><span class="p">(</span><span class="n">sok</span><span class="p">,</span><span class="w"> </span><span class="n">state</span><span class="p">,</span><span class="w"> </span><span class="o">&</span><span class="n">req</span><span class="p">,</span><span class="w"> </span><span class="n">data</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">-1</span><span class="p">)</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">recv_mspresponse</span><span class="p">(</span><span class="n">sok</span><span class="p">,</span><span class="w"> </span><span class="n">state</span><span class="p">,</span><span class="w"> </span><span class="o">&</span><span class="n">res</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">-1</span><span class="p">)</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">strcmp</span><span class="p">(</span><span class="n">res</span><span class="p">.</span><span class="n">RWSP</span><span class="p">,</span><span class="w"> </span><span class="s">"RWSP"</span><span class="p">)</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="mi">0</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="cp">#ifdef DEBUG_MSPROXY</span> <span class="w"> </span><span class="n">printf</span><span class="w"> </span><span class="p">(</span><span class="s">"Received mailformed packet (no RWSP signature)</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span> <span class="cp">#endif</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">ntohs</span><span class="p">(</span><span class="n">res</span><span class="p">.</span><span class="n">command</span><span class="p">)</span><span class="w"> </span><span class="o">>></span><span class="w"> </span><span class="mi">8</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="mh">0x10</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="cp">#ifdef DEBUG_MSPROXY</span> <span class="w"> </span><span class="n">printf</span><span class="w"> </span><span class="p">(</span><span class="s">"expected res.command = 10??, is %x"</span><span class="p">,</span><span class="w"> </span><span class="n">ntohs</span><span class="p">(</span><span class="n">res</span><span class="p">.</span><span class="n">command</span><span class="p">));</span> <span class="cp">#endif</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">clientid</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htonl</span><span class="p">(</span><span class="n">rand</span><span class="p">());</span> <span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">serverid</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">res</span><span class="p">.</span><span class="n">serverid</span><span class="p">;</span> <span class="cp">#ifdef DEBUG_MSPROXY</span> <span class="w"> </span><span class="n">printf</span><span class="w"> </span><span class="p">(</span><span class="s">"clientid: 0x%x, serverid: 0x%0x</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">clientid</span><span class="p">,</span><span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">serverid</span><span class="p">);</span> <span class="w"> </span><span class="n">printf</span><span class="w"> </span><span class="p">(</span><span class="s">"packet #2</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span> <span class="cp">#endif</span> <span class="w"> </span><span class="cm">/* almost identical. */</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">clientid</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">clientid</span><span class="p">;</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">serverid</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">serverid</span><span class="p">;</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">send_msprequest</span><span class="p">(</span><span class="n">sok</span><span class="p">,</span><span class="w"> </span><span class="n">state</span><span class="p">,</span><span class="w"> </span><span class="o">&</span><span class="n">req</span><span class="p">,</span><span class="w"> </span><span class="n">data</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">-1</span><span class="p">)</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">recv_mspresponse</span><span class="p">(</span><span class="n">sok</span><span class="p">,</span><span class="w"> </span><span class="n">state</span><span class="p">,</span><span class="w"> </span><span class="o">&</span><span class="n">res</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">-1</span><span class="p">)</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">res</span><span class="p">.</span><span class="n">serverid</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">serverid</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="cp">#ifdef DEBUG_MSPROXY</span> <span class="w"> </span><span class="n">printf</span><span class="w"> </span><span class="p">(</span><span class="s">"expected serverid = 0x%x, is 0x%x</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="n">state</span><span class="o">-></span><span class="n">serverid</span><span class="p">,</span><span class="w"> </span><span class="n">res</span><span class="p">.</span><span class="n">serverid</span><span class="p">);</span> <span class="cp">#endif</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">res</span><span class="p">.</span><span class="n">sequence</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="mh">0x01</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="cp">#ifdef DEBUG_MSPROXY</span> <span class="w"> </span><span class="n">printf</span><span class="w"> </span><span class="p">(</span><span class="s">"expected res.sequence = 0x01, is 0x%x</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="w"> </span><span class="n">res</span><span class="p">.</span><span class="n">sequence</span><span class="p">);</span> <span class="cp">#endif</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">ntohs</span><span class="p">(</span><span class="n">res</span><span class="p">.</span><span class="n">command</span><span class="p">)</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="n">MSPROXY_USERINFO_ACK</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="cp">#ifdef DEBUG_MSPROXY</span> <span class="w"> </span><span class="n">printf</span><span class="w"> </span><span class="p">(</span><span class="s">"expected res.command = 0x%x, is 0x%x</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="w"> </span><span class="n">MSPROXY_USERINFO_ACK</span><span class="p">,</span><span class="w"> </span><span class="n">ntohs</span><span class="p">(</span><span class="n">res</span><span class="p">.</span><span class="n">command</span><span class="p">));</span> <span class="cp">#endif</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="p">}</span> <span class="cp">#ifdef DEBUG_MSPROXY</span> <span class="w"> </span><span class="n">printf</span><span class="w"> </span><span class="p">(</span><span class="s">"packet #3</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span> <span class="cp">#endif</span> <span class="w"> </span><span class="n">bzero</span><span class="p">(</span><span class="o">&</span><span class="n">req</span><span class="p">,</span><span class="w"> </span><span class="k">sizeof</span><span class="p">(</span><span class="n">req</span><span class="p">));</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">clientid</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">clientid</span><span class="p">;</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">serverid</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">serverid</span><span class="p">;</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">command</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htons</span><span class="p">(</span><span class="n">MSPROXY_AUTHENTICATE</span><span class="p">);</span> <span class="w"> </span><span class="n">memcpy</span><span class="p">(</span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth</span><span class="p">.</span><span class="n">NTLMSSP</span><span class="p">,</span><span class="w"> </span><span class="s">"NTLMSSP"</span><span class="p">,</span><span class="w"> </span><span class="k">sizeof</span><span class="p">(</span><span class="s">"NTLMSSP"</span><span class="p">));</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth</span><span class="p">.</span><span class="n">bindaddr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htonl</span><span class="p">(</span><span class="mh">0x02000000</span><span class="p">);</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth</span><span class="p">.</span><span class="n">msgtype</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htonl</span><span class="p">(</span><span class="mh">0x01000000</span><span class="p">);</span> <span class="w"> </span><span class="cm">/* NTLM flags: 0x80000000 Negotiate LAN Manager key</span> <span class="cm"> 0x10000000 Negotiate sign</span> <span class="cm"> 0x04000000 Request target</span> <span class="cm"> 0x02000000 Negotiate OEM</span> <span class="cm"> 0x00800000 Always sign</span> <span class="cm"> 0x00020000 Negotiate NTLM</span> <span class="cm"> */</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth</span><span class="p">.</span><span class="n">flags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htonl</span><span class="p">(</span><span class="mh">0x06020000</span><span class="p">);</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">send_msprequest</span><span class="p">(</span><span class="n">sok</span><span class="p">,</span><span class="w"> </span><span class="n">state</span><span class="p">,</span><span class="w"> </span><span class="o">&</span><span class="n">req</span><span class="p">,</span><span class="w"> </span><span class="o">&</span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth</span><span class="p">.</span><span class="n">data</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">-1</span><span class="p">)</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">recv_mspresponse</span><span class="p">(</span><span class="n">sok</span><span class="p">,</span><span class="w"> </span><span class="n">state</span><span class="p">,</span><span class="w"> </span><span class="o">&</span><span class="n">res</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">-1</span><span class="p">)</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">res</span><span class="p">.</span><span class="n">serverid</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">serverid</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="cp">#ifdef DEBUG_MSPROXY</span> <span class="w"> </span><span class="n">printf</span><span class="w"> </span><span class="p">(</span><span class="s">"expected serverid = 0x%x, is 0x%x</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">serverid</span><span class="p">,</span><span class="w"> </span><span class="n">res</span><span class="p">.</span><span class="n">serverid</span><span class="p">);</span> <span class="cp">#endif</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">ntohs</span><span class="p">(</span><span class="n">res</span><span class="p">.</span><span class="n">command</span><span class="p">)</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="n">MSPROXY_AUTHENTICATE_ACK</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="cp">#ifdef DEBUG_MSPROXY</span> <span class="w"> </span><span class="n">printf</span><span class="w"> </span><span class="p">(</span><span class="s">"expected res.command = 0x%x, is 0x%x</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="w"> </span><span class="n">MSPROXY_AUTHENTICATE_ACK</span><span class="p">,</span><span class="w"> </span><span class="n">ntohs</span><span class="p">(</span><span class="n">res</span><span class="p">.</span><span class="n">command</span><span class="p">));</span> <span class="cp">#endif</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="n">flags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">res</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth</span><span class="p">.</span><span class="n">flags</span><span class="w"> </span><span class="o">&</span><span class="w"> </span><span class="n">htonl</span><span class="p">(</span><span class="mh">0x00020000</span><span class="p">);</span><span class="w"> </span><span class="cm">/* Remember if the server supports NTLM */</span> <span class="w"> </span><span class="n">memcpy</span><span class="p">(</span><span class="n">challenge</span><span class="p">,</span><span class="w"> </span><span class="o">&</span><span class="n">res</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth</span><span class="p">.</span><span class="n">challenge</span><span class="p">,</span><span class="w"> </span><span class="k">sizeof</span><span class="p">(</span><span class="n">challenge</span><span class="p">));</span> <span class="w"> </span><span class="n">memcpy</span><span class="p">(</span><span class="n">ntdomain</span><span class="p">,</span><span class="w"> </span><span class="o">&</span><span class="n">res</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth</span><span class="p">.</span><span class="n">NTLMSSP</span><span class="p">[</span><span class="n">res</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth</span><span class="p">.</span><span class="n">target</span><span class="p">.</span><span class="n">offset</span><span class="p">],</span><span class="w"> </span><span class="n">res</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth</span><span class="p">.</span><span class="n">target</span><span class="p">.</span><span class="n">len</span><span class="p">);</span> <span class="w"> </span><span class="n">ntdomain</span><span class="p">[</span><span class="n">res</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth</span><span class="p">.</span><span class="n">target</span><span class="p">.</span><span class="n">len</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span> <span class="cp">#ifdef DEBUG_MSPROXY</span> <span class="w"> </span><span class="n">printf</span><span class="w"> </span><span class="p">(</span><span class="s">"ntdomain: </span><span class="se">\"</span><span class="s">%s</span><span class="se">\"\n</span><span class="s">"</span><span class="p">,</span><span class="w"> </span><span class="n">ntdomain</span><span class="p">);</span> <span class="w"> </span><span class="n">printf</span><span class="w"> </span><span class="p">(</span><span class="s">"packet #4</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span> <span class="cp">#endif</span> <span class="w"> </span><span class="n">bzero</span><span class="p">(</span><span class="o">&</span><span class="n">req</span><span class="p">,</span><span class="w"> </span><span class="k">sizeof</span><span class="p">(</span><span class="n">req</span><span class="p">));</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">clientid</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">clientid</span><span class="p">;</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">serverid</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">serverid</span><span class="p">;</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">command</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htons</span><span class="p">(</span><span class="n">MSPROXY_AUTHENTICATE_2</span><span class="p">);</span><span class="w"> </span><span class="cm">/* Authentication response */</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">magic3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htons</span><span class="p">(</span><span class="mh">0x0200</span><span class="p">);</span><span class="w"> </span><span class="cm">/* Something */</span> <span class="w"> </span><span class="n">memcpy</span><span class="p">(</span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">NTLMSSP</span><span class="p">,</span><span class="w"> </span><span class="s">"NTLMSSP"</span><span class="p">,</span><span class="w"> </span><span class="k">sizeof</span><span class="p">(</span><span class="s">"NTLMSSP"</span><span class="p">));</span><span class="w"> </span><span class="cm">/* Start of NTLM message */</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">msgtype</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htonl</span><span class="p">(</span><span class="mh">0x03000000</span><span class="p">);</span><span class="w"> </span><span class="cm">/* Message type 2 */</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">flags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">flags</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">htonl</span><span class="p">(</span><span class="mh">0x02000000</span><span class="p">);</span><span class="w"> </span><span class="cm">/* Choose authentication method */</span> <span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">data</span><span class="p">;</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">flags</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">lm_resp</span><span class="p">.</span><span class="n">len</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="cm">/* We are here if NTLM is supported, */</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">lm_resp</span><span class="p">.</span><span class="n">alloc</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="cm">/* Do not fill in insecure LM response */</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">lm_resp</span><span class="p">.</span><span class="n">offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">NTLMSSP</span><span class="p">;</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">ntlm_resp</span><span class="p">.</span><span class="n">len</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">24</span><span class="p">;</span><span class="w"> </span><span class="cm">/* Fill in NTLM response security buffer */</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">ntlm_resp</span><span class="p">.</span><span class="n">alloc</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">24</span><span class="p">;</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">ntlm_resp</span><span class="p">.</span><span class="n">offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">NTLMSSP</span><span class="p">;</span> <span class="w"> </span><span class="n">ntlm_smb_nt_encrypt</span><span class="p">(</span><span class="n">prefs</span><span class="p">.</span><span class="n">proxy_pass</span><span class="p">,</span><span class="w"> </span><span class="n">challenge</span><span class="p">,</span><span class="w"> </span><span class="n">data</span><span class="p">);</span><span class="w"> </span><span class="cm">/* Append an NTLM response */</span> <span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="mi">24</span><span class="p">;</span><span class="w"> </span> <span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">lm_resp</span><span class="p">.</span><span class="n">len</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">24</span><span class="p">;</span><span class="w"> </span><span class="cm">/* Fill in LM response security buffer */</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">lm_resp</span><span class="p">.</span><span class="n">alloc</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">24</span><span class="p">;</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">lm_resp</span><span class="p">.</span><span class="n">offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">NTLMSSP</span><span class="p">;</span> <span class="w"> </span><span class="n">ntlm_smb_encrypt</span><span class="p">(</span><span class="n">prefs</span><span class="p">.</span><span class="n">proxy_pass</span><span class="p">,</span><span class="w"> </span><span class="n">challenge</span><span class="p">,</span><span class="w"> </span><span class="n">data</span><span class="p">);</span><span class="w"> </span><span class="cm">/* Append an LM response */</span> <span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="mi">24</span><span class="p">;</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">ntlm_resp</span><span class="p">.</span><span class="n">len</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="cm">/* NTLM response is empty */</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">ntlm_resp</span><span class="p">.</span><span class="n">alloc</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">ntlm_resp</span><span class="p">.</span><span class="n">offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">NTLMSSP</span><span class="p">;</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">ntdomain_buf</span><span class="p">.</span><span class="n">len</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">strlen</span><span class="p">(</span><span class="n">ntdomain</span><span class="p">);</span><span class="w"> </span><span class="cm">/* Domain name */</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">ntdomain_buf</span><span class="p">.</span><span class="n">alloc</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">ntdomain_buf</span><span class="p">.</span><span class="n">len</span><span class="p">;</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">ntdomain_buf</span><span class="p">.</span><span class="n">offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">NTLMSSP</span><span class="p">;</span> <span class="w"> </span><span class="n">strcpy</span><span class="p">(</span><span class="n">data</span><span class="p">,</span><span class="w"> </span><span class="n">ntdomain</span><span class="p">);</span> <span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">ntdomain_buf</span><span class="p">.</span><span class="n">len</span><span class="p">;</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">username_buf</span><span class="p">.</span><span class="n">len</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">strlen</span><span class="p">(</span><span class="n">prefs</span><span class="p">.</span><span class="n">proxy_user</span><span class="p">);</span><span class="w"> </span><span class="cm">/* Username */</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">username_buf</span><span class="p">.</span><span class="n">alloc</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">username_buf</span><span class="p">.</span><span class="n">len</span><span class="p">;</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">username_buf</span><span class="p">.</span><span class="n">offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">NTLMSSP</span><span class="p">;</span> <span class="w"> </span><span class="n">strcpy</span><span class="p">(</span><span class="n">data</span><span class="p">,</span><span class="w"> </span><span class="n">prefs</span><span class="p">.</span><span class="n">proxy_user</span><span class="p">);</span> <span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">username_buf</span><span class="p">.</span><span class="n">len</span><span class="p">;</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">clienthost_buf</span><span class="p">.</span><span class="n">len</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">strlen</span><span class="p">(</span><span class="n">hostname</span><span class="p">);</span><span class="w"> </span><span class="cm">/* Hostname */</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">clienthost_buf</span><span class="p">.</span><span class="n">alloc</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">clienthost_buf</span><span class="p">.</span><span class="n">len</span><span class="p">;</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">clienthost_buf</span><span class="p">.</span><span class="n">offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">NTLMSSP</span><span class="p">;</span> <span class="w"> </span><span class="n">strcpy</span><span class="p">(</span><span class="n">data</span><span class="p">,</span><span class="w"> </span><span class="n">hostname</span><span class="p">);</span> <span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">clienthost_buf</span><span class="p">.</span><span class="n">len</span><span class="p">;</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">sessionkey_buf</span><span class="p">.</span><span class="n">len</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="cm">/* Session key (we don't use it) */</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">sessionkey_buf</span><span class="p">.</span><span class="n">alloc</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">sessionkey_buf</span><span class="p">.</span><span class="n">offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">auth2</span><span class="p">.</span><span class="n">NTLMSSP</span><span class="p">;</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">send_msprequest</span><span class="p">(</span><span class="n">sok</span><span class="p">,</span><span class="w"> </span><span class="n">state</span><span class="p">,</span><span class="w"> </span><span class="o">&</span><span class="n">req</span><span class="p">,</span><span class="w"> </span><span class="n">data</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">-1</span><span class="p">)</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">recv_mspresponse</span><span class="p">(</span><span class="n">sok</span><span class="p">,</span><span class="w"> </span><span class="n">state</span><span class="p">,</span><span class="w"> </span><span class="o">&</span><span class="n">res</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">-1</span><span class="p">)</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">res</span><span class="p">.</span><span class="n">serverid</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">serverid</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="cp">#ifdef DEBUG_MSPROXY</span> <span class="w"> </span><span class="n">printf</span><span class="w"> </span><span class="p">(</span><span class="s">"expected res.serverid = 0x%x, is 0x%x</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">serverid</span><span class="p">,</span><span class="w"> </span><span class="n">res</span><span class="p">.</span><span class="n">serverid</span><span class="p">);</span> <span class="cp">#endif</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">res</span><span class="p">.</span><span class="n">clientack</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="mh">0x01</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="cp">#ifdef DEBUG_MSPROXY</span> <span class="w"> </span><span class="n">printf</span><span class="w"> </span><span class="p">(</span><span class="s">"expected res.clientack = 0x01, is 0x%x</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="w"> </span><span class="n">res</span><span class="p">.</span><span class="n">clientack</span><span class="p">);</span> <span class="cp">#endif</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">ntohs</span><span class="p">(</span><span class="n">res</span><span class="p">.</span><span class="n">command</span><span class="p">)</span><span class="w"> </span><span class="o">>></span><span class="w"> </span><span class="mi">8</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="mh">0x47</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="cp">#ifdef DEBUG_MSPROXY</span> <span class="w"> </span><span class="n">printf</span><span class="w"> </span><span class="p">(</span><span class="s">"expected res.command = 47??, is 0x%x</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="w"> </span><span class="n">ntohs</span><span class="p">(</span><span class="n">res</span><span class="p">.</span><span class="n">command</span><span class="p">));</span> <span class="cp">#endif</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">ntohs</span><span class="p">(</span><span class="n">res</span><span class="p">.</span><span class="n">command</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">MSPROXY_AUTHENTICATE_2_NAK</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="cp">#ifdef DEBUG_MSPROXY</span> <span class="w"> </span><span class="n">printf</span><span class="w"> </span><span class="p">(</span><span class="s">"Authentication failed</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span> <span class="cp">#endif</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">-1</span><span class="p">;</span> <span class="w"> </span><span class="p">}</span> <span class="cp">#ifdef DEBUG_MSPROXY</span> <span class="w"> </span><span class="n">printf</span><span class="w"> </span><span class="p">(</span><span class="s">"packet #5</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span> <span class="cp">#endif</span> <span class="w"> </span><span class="n">bzero</span><span class="p">(</span><span class="o">&</span><span class="n">req</span><span class="p">,</span><span class="w"> </span><span class="k">sizeof</span><span class="p">(</span><span class="n">req</span><span class="p">));</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">clientid</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">clientid</span><span class="p">;</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">serverid</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-></span><span class="n">serverid</span><span class="p">;</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">command</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htons</span><span class="p">(</span><span class="n">MSPROXY_CONNECT</span><span class="p">);</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">connect</span><span class="p">.</span><span class="n">magic2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htons</span><span class="p">(</span><span class="mh">0x0200</span><span class="p">);</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">connect</span><span class="p">.</span><span class="n">magic6</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htons</span><span class="p">(</span><span class="mh">0x0200</span><span class="p">);</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">connect</span><span class="p">.</span><span class="n">destport</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">htons</span><span class="p">(</span><span class="n">port</span><span class="p">);</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">connect</span><span class="p">.</span><span class="n">destaddr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">destaddr</span><span class="p">;</span> <span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">connect</span><span class="p">.</span><span class="n">executable</span><span class="p">;</span> <span class="w"> </span><span class="n">strcpy</span><span class="p">(</span><span class="n">data</span><span class="p">,</span><span class="w"> </span><span class="n">MSPROXY_EXECUTABLE</span><span class="p">);</span> <span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">strlen</span><span class="p">(</span><span class="n">MSPROXY_EXECUTABLE</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="cm">/*</span> <span class="cm"> * need to tell server what port we will connect from, so we bind our sockets.</span> <span class="cm"> */</span> <span class="w"> </span><span class="n">ns_client</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">net_store_new</span><span class="w"> </span><span class="p">();</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="o">!</span><span class="n">bound</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="n">net_store_fill_any</span><span class="w"> </span><span class="p">(</span><span class="n">ns_client</span><span class="p">);</span> <span class="w"> </span><span class="n">net_bind</span><span class="p">(</span><span class="n">ns_client</span><span class="p">,</span><span class="w"> </span><span class="n">csok4</span><span class="p">,</span><span class="w"> </span><span class="n">csok6</span><span class="p">);</span> <span class="cp">#ifdef DEBUG_MSPROXY</span> <span class="w"> </span><span class="n">perror</span><span class="w"> </span><span class="p">(</span><span class="s">"bind() result"</span><span class="p">);</span> <span class="cp">#endif</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="n">clientport</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">net_getsockport</span><span class="p">(</span><span class="n">csok4</span><span class="p">,</span><span class="w"> </span><span class="n">csok6</span><span class="p">);</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">clientport</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">-1</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="cp">#ifdef DEBUG_MSPROXY</span> <span class="w"> </span><span class="n">printf</span><span class="w"> </span><span class="p">(</span><span class="s">"Unable to obtain source port</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span> <span class="cp">#endif</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="n">req</span><span class="p">.</span><span class="n">packet</span><span class="p">.</span><span class="n">connect</span><span class="p">.</span><span class="n">srcport</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">clientport</span><span class="p">;</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">send_msprequest</span><span class="p">(</span><span class="n">sok</span><span class="p">,</span><span class="w"> </span><span class="n">state</span><span class="p">,</span><span class="w"> </span><span class="o">&</span><span class="n">req</span><span class="p">,</span><span class="w"> </span><span class="n">data</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">-1</span><span class="p">)</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">recv_mspresponse</span><span class="p">(</span><span class="n">sok</span><span class="p">,</span><span class="w"> </span><span class="n">state</span><span class="p">,</span><span class="w"> </span><span class="o">&</span><span class="n">res</span><span class="p">)</span><span c